Go Down

Topic: Universal Countdown Clock (Read 4 times) previous topic - next topic

wallaceb

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

Code: [Select]
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: [Select]
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.

wallaceb

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.

wallaceb

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





wallaceb

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:

wallaceb

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 ;)

i will post additional updates as i get them.

Go Up