Improve display of large hour times

This commit is contained in:
Thomas Kolb 2024-05-20 14:26:27 +02:00
parent c1b0c2322d
commit c9b70b29f8

View file

@ -75,13 +75,20 @@ static void show_time(uint32_t time_ms)
sseg_set_char(0, '0' + days / 10, false);
sseg_set_char(1, '0' + days % 10, blinking_dot_on);
sseg_set_char(2, 'd', false);
} else if(time_ms >= 99 * ONE_HOUR / 10) { // 9.9 hours .. 9.9 days
} else if(time_ms >= 2*ONE_DAY) { // 2 days .. 9.9 days
// show days with one decimal
uint32_t decidays = (time_ms + ONE_DAY/20) * 10 / ONE_DAY;
sseg_set_char(0, '0' + decidays / 10, blinking_dot_on);
sseg_set_char(1, '0' + decidays % 10, false);
sseg_set_char(2, 'd', false);
} else if(time_ms >= 99 * ONE_HOUR / 10) { // 9.9 hours .. 2.0 days
// show integer hours
uint32_t hours = (time_ms + ONE_HOUR/2) / ONE_HOUR;
sseg_set_char(0, '0' + hours / 10, false);
sseg_set_char(1, '0' + hours % 10, blinking_dot_on);
sseg_set_char(2, 'H', false);
} else if(time_ms >= 1000 * ONE_SECOND) { // 1000 seconds (0.27 hours) .. 9.9 hours
// show hours with one decimal
uint32_t decihours = (time_ms + ONE_HOUR/20) * 10 / ONE_HOUR;
@ -244,8 +251,8 @@ static void update_countdown_fsm(uint32_t time_ms)
m_countdown_off_time *= 2;
}
if(m_countdown_off_time > 10 * ONE_HOUR) {
m_countdown_off_time = 10 * ONE_HOUR;
if((m_countdown_off_time - time_ms) > 10 * ONE_HOUR) {
m_countdown_off_time = time_ms + 10 * ONE_HOUR;
}
}
@ -364,9 +371,10 @@ int main()
buttons_init();
sseg_init();
sseg_set_char(0, 'Z', false);
sseg_set_char(1, 'A', false);
sseg_set_char(2, 'M', false);
// display test
sseg_set_char(0, '8', true);
sseg_set_char(1, '8', true);
sseg_set_char(2, '8', true);
buzzer_on(1000);
@ -386,6 +394,12 @@ int main()
sleep_ms(400);
sseg_set_char(0, 'Z', false);
sseg_set_char(1, 'A', false);
sseg_set_char(2, 'M', false);
sleep_ms(2000);
configure_ms_trig_alarm();
arm_ms_trig_alarm();