From 2b2cd122f7501cdd67e888df5b7c0ec6d96f6085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Fri, 25 Mar 2016 14:15:48 +0100 Subject: [PATCH] poll and update time --- main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.c b/main.c index ca74b48..58781ce 100644 --- a/main.c +++ b/main.c @@ -305,6 +305,18 @@ int main(void) //rtc_write_time(0,52,9,4,23,3,2016); //rtc_oscillator_enable(); + uint8_t current_seconds = rtc_read_seconds(); // read seconds to check if time changed + while (true) { // infinite loop + uint8_t new_seconds = rtc_read_seconds(); // read seconds to check if time changed + if (new_seconds!=current_seconds) { // show new time + current_seconds = new_seconds; // save new seconds + rtc_time = rtc_read_time(); // get RTC time/date + current_time = rtc_time[2]*ticks_hour+rtc_time[1]*ticks_minute+rtc_time[0]*ticks_second; // calculate current time + clock_set_time(current_time); // set time + printf("it is now %02lu:%02lu:%02lu\n", current_time/ticks_hour, (current_time%ticks_hour)/ticks_minute, (current_time%ticks_minute)/ticks_second); // display time + } + } + printf("input commands\n"); bool action = false; // if an action has been performed don't go to sleep button_flag = false; // reset button flag