poll and update time
This commit is contained in:
parent
b5134bb498
commit
2b2cd122f7
12
main.c
12
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
|
||||
|
Loading…
Reference in New Issue
Block a user