show uptime instead of time
This commit is contained in:
parent
2cda97cbb7
commit
a84484d215
13
main.c
13
main.c
|
@ -162,10 +162,8 @@ void main(void)
|
||||||
nvic_enable_irq(NVIC_RTC_IRQ); // allow the RTC to interrupt
|
nvic_enable_irq(NVIC_RTC_IRQ); // allow the RTC to interrupt
|
||||||
printf("OK\n");
|
printf("OK\n");
|
||||||
|
|
||||||
// get date and time
|
uint32_t ticks_time = rtc_get_counter_val(); // get time from internal RTC (since first start/power up)
|
||||||
uint32_t ticks_time = 0;
|
printf("uptime: %02lu:%02lu:%02lu\n", ticks_time/(60*60), (ticks_time%(60*60))/60, (ticks_time%60)); // display time
|
||||||
ticks_time = rtc_get_counter_val(); // get time/date from internal RTC
|
|
||||||
printf("current time: %02lu:%02lu:%02lu\n", ticks_time/(60*60), (ticks_time%(60*60))/60, (ticks_time%60)); // display time
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// setup PZEM electricity meter
|
// setup PZEM electricity meter
|
||||||
|
@ -277,14 +275,11 @@ void main(void)
|
||||||
}
|
}
|
||||||
while (rtc_internal_tick_flag) { // the internal RTC ticked
|
while (rtc_internal_tick_flag) { // the internal RTC ticked
|
||||||
rtc_internal_tick_flag = false; // reset flag
|
rtc_internal_tick_flag = false; // reset flag
|
||||||
//led_toggle(); // toggle LED (good to indicate if main function is stuck
|
led_toggle(); // toggle LED (good to indicate if main function is stuck)
|
||||||
ticks_time = rtc_get_counter_val(); // copy time from internal RTC for processing
|
ticks_time = rtc_get_counter_val(); // copy time from internal RTC for processing
|
||||||
action = true; // action has been performed
|
action = true; // action has been performed
|
||||||
if (ticks_time!=0 && (ticks_time%(24*60*60))==0) { // one day passed
|
|
||||||
rtc_set_counter_val(0); // reset counter
|
|
||||||
}
|
|
||||||
if ((ticks_time%(60))==0) { // one minute passed
|
if ((ticks_time%(60))==0) { // one minute passed
|
||||||
printf("%02lu:%02lu:%02lu\n", ticks_time/(60*60), (ticks_time%(60*60))/60, (ticks_time%60)); // display external time
|
printf("uptime %02lu:%02lu:%02lu\n", ticks_time/(60*60), (ticks_time%(60*60))/60, (ticks_time%60)); // display external time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (action) { // go to sleep if nothing had to be done, else recheck for activity
|
if (action) { // go to sleep if nothing had to be done, else recheck for activity
|
||||||
|
|
Loading…
Reference in New Issue