Pages: 1 [2]   Go Down
Author Topic: Universal Countdown Clock  (Read 3520 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 3
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i want to thank you for all your help. i did make a small change to your code:

Code:
TimeStamp calcDiff(TimeStamp now, const TimeStamp &future)
{
    byte current_month = now.mm;
    unsigned long sec_now = now.ss + ((unsigned long)now.min * 60) + ((unsigned long)now.hh * 3600);
    unsigned long sec_future = future.ss + ((unsigned long)future.min * 60) + ((unsigned long)future.hh * 3600);

    if (sec_future < sec_now)
    {
        sec_future += 86400;
        ++now.dd;
    }

    if (future.dd < now.dd)
    {
        now.dd = DAYS_IN_MONTH[now.mm-1] - now.dd + future.dd;
        ++now.mm;
    } else {
        now.dd = future.dd - now.dd;
    }

    if (future.mm < now.mm)
    {       
        now.mm = future.mm + 12 - now.mm;
        if ((current_month + now.mm) > 12){
          now.dd -= (DAYS_IN_MONTH[current_month-1] - DAYS_IN_MONTH[(current_month + now.mm - 12)-1]);
        }else{
          now.dd -= (DAYS_IN_MONTH[current_month-1] - DAYS_IN_MONTH[(current_month + now.mm)-1]);
        }
        ++now.yy;
    } else {
        now.mm = future.mm - now.mm;
    }

    sec_now = sec_future - sec_now;
    now.yy = future.yy - now.yy;
    now.hh = sec_now / 3600;
    now.min = (sec_now - ((unsigned long)now.hh * 3600)) / 60;
    now.ss = sec_now % 60;

    return now;
}

the changes were made when the remaining months were being calculated, and if future.mm < now.mm, some adjustments to the days needs to be done.

here is the resulting output from your code after some tests:

Code:
Current Time/Date: -  8 / 18 / 2013 : - 18 : 3 : 0
Time Until 1 / 10 / 2014 : - 0 : 0 : 0
0 years, 4 month, 22 days
5 hours, 57 minutes, 0 seconds


Current Time/Date: -  8 / 18 / 2013 : - 18 : 3 : 0
Time Until 1 / 10 / 2014 : - 20 : 0 : 0
0 years, 4 month, 23 days
1 hours, 57 minutes, 0 seconds


Current Time/Date: -  8 / 18 / 2013 : - 18 : 3 : 0
Time Until 1 / 20 / 2014 : - 0 : 0 : 0
0 years, 5 month, 1 days
5 hours, 57 minutes, 0 seconds


Current Time/Date: -  8 / 18 / 2013 : - 18 : 3 : 0
Time Until 1 / 20 / 2014 : - 20 : 0 : 0
0 years, 5 month, 2 days
1 hours, 57 minutes, 0 seconds


Current Time/Date: -  8 / 18 / 2013 : - 18 : 3 : 0
Time Until 2 / 10 / 2014 : - 0 : 0 : 0
0 years, 5 month, 22 days
5 hours, 57 minutes, 0 seconds


Current Time/Date: -  2 / 18 / 2013 : - 18 : 3 : 0
Time Until 3 / 10 / 2014 : - 0 : 0 : 0
1 years, 0 month, 19 days
5 hours, 57 minutes, 0 seconds

thanks again for your help, and reminding me of the beauty of using "struct" to create a more easy to use variable structure.
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have the web-based code done




do not mind the "\002" text. i used a HTML editor program to preview the page, and the code uses the "\002" to know when it needs to inject a system variable in the HTML page.
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

even after working on the web-pages, i stumbled upon the awesome GUI library here:

http://forum.arduino.cc/index.php?topic=164788.0

as a result, i have decided to use a touch screen interface for all user-configuration, so no Ethernet connection will be needed.

i have begun the layout process of the GUI




Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

for starters, i just ordered my Arduino Due, 7" CTE screen, the CTE Due shield, and RTC module. when they arrive, i will get started on working on the guts of my project  smiley-mr-green
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i got my due, RTC, and 24LC256 EEPROM. i can access the RTC without issues, and i can write everything i need to EEPROM, including the string variables i am going to need for people's names used for the birthday countdowns and custom countdowns. now i am just waiting on the screen which will likely be another week or so.

i have written around 75% of my code in preparations for when i get the screen, and hopefully everything will work smiley-wink

i will post additional updates as i get them.
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i got the screen, everything physically works. i used the CTE image importer tool to upload background images for the different holidays. My code works fairly well. right now i am working out bugs more than anything, and to get the settings entered into each screen to save correctly. i will post a video soon showing it in action.
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 104
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i got around 80% of the project working. the pre-defined holidays all countdown properly, and all their respective settings successfully save to and load from EEPROM. the user settings for the pre-defined holidays can all be successfully edited. the screen brightness can be configured. in addition, the user can configure when the screen turns on and off at night to save energy. if the screen is off, and the user touches the screen, the screen comes back on, stays on for as long as the user is interacting with the screen and will wait for 60 seconds of no interaction and turn back off.

i have uploaded a video of the project in action.
http://youtu.be/B7OmzQwGaJU

i have some bugs where if a holiday is disabled, it interferes with the correct operation of the remaining enabled countdowns. i need to get the "save" and "test" buttons on the holiday setting screens to display the right image, as i selected the wrong images. i need to get the "test" functionality working where the user will be able to click the "test" button to get a display of what their font and background colors will look like. i need to code the birthdays, anniversary, and custom countdowns. i think i will be done coding around the end of next week.
Logged

Czech Republic
Offline Offline
Sr. Member
****
Karma: 3
Posts: 311
Absolute Beginner, yet.
Newbie in Arduino
since May 2013
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i have uploaded a video of the project in action.
http://youtu.be/B7OmzQwGaJU
Looks good. (You have small typo: Minuets)
Logged

Arduino Uno R3, Arduino Mega 2560 R3, Ethermega (R3), and some Ethernet Shields (R3), Chronodots, TMP36 sensors, DS18B20 sensors, LCDs/TFTs, RS232C to learn and play...

Pages: 1 [2]   Go Up
Jump to: