use DCF77 to update time at boot and every hour
This commit is contained in:
parent
c2cd9a238e
commit
53235e5394
4
main.c
4
main.c
@ -439,7 +439,7 @@ int main(void)
|
||||
nvic_enable_irq(NVIC_RTC_IRQ); // allow the RTC to interrupt
|
||||
#endif
|
||||
rtc_dcf77_setup(); // setup DCF77 module
|
||||
rtc_dcf77_on(); // switch on DCF77 module
|
||||
rtc_dcf77_on(); // switch on DCF77 module to get correct time
|
||||
printf("OK\n");
|
||||
|
||||
// setup WS2812b LEDs
|
||||
@ -564,6 +564,7 @@ int main(void)
|
||||
rtc_set_counter_val(ticks_time); // set new time to internal RTC
|
||||
#endif
|
||||
printf("DCF77 time: 20%02u-%02u-%02u %02u:%02u:00\n", dcf77_time[5], dcf77_time[4], dcf77_time[2], dcf77_time[1], dcf77_time[0]); // display time
|
||||
rtc_dcf77_off(); // switch DCF77 off since we have correct time
|
||||
} else {
|
||||
printf("DCF77 time: error\n");
|
||||
}
|
||||
@ -588,6 +589,7 @@ int main(void)
|
||||
printf("%02lu:%02lu:%02lu\n", ticks_time/ticks_hour, (ticks_time%ticks_hour)/ticks_minute, (ticks_time%ticks_minute)/ticks_second); // display external time
|
||||
}
|
||||
if ((ticks_time%ticks_hour)==0) { // one hours passed
|
||||
rtc_dcf77_on(); // switch DCF77 on to update/correct time
|
||||
clock_hours(); // show hour markers
|
||||
}
|
||||
if (ticks_time>=ticks_midday*2) { // one day passed
|
||||
|
Loading…
Reference in New Issue
Block a user