Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
mperror.c: Move noticing of the next heartbeat transition (#236)
Browse files Browse the repository at this point in the history
The place at which the time for the next transition is noticed
moves from the start of the respective block to it's end, when
the RGB led has switched.

Co-authored-by: robert-hh <[email protected]>
  • Loading branch information
geza-pycom and robert-hh authored Apr 10, 2021
1 parent e6f4eb6 commit da8c822
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions esp32/util/mperror.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,18 @@ bool mperror_heartbeat_signal (void) {
mperror_heart_beat.do_disable = false;
} else if (mperror_heart_beat.enabled) {
if (!mperror_heart_beat.beating) {
if ((mperror_heart_beat.on_time = mp_hal_ticks_ms_non_blocking()) - mperror_heart_beat.off_time > MPERROR_HEARTBEAT_OFF_MS) {
if (mp_hal_ticks_ms_non_blocking() > mperror_heart_beat.off_time) {
led_info.color.value = MPERROR_HEARTBEAT_COLOR;
led_set_color(&led_info, false, false);
led_set_color(&led_info, true, false);
mperror_heart_beat.beating = true;
mperror_heart_beat.on_time = mp_hal_ticks_ms_non_blocking() + MPERROR_HEARTBEAT_ON_MS;
}
} else {
if ((mperror_heart_beat.off_time = mp_hal_ticks_ms_non_blocking()) - mperror_heart_beat.on_time > MPERROR_HEARTBEAT_ON_MS) {
if (mp_hal_ticks_ms_non_blocking() > mperror_heart_beat.on_time) {
led_info.color.value = 0;
led_set_color(&led_info, false, false);
led_set_color(&led_info, true, false);
mperror_heart_beat.beating = false;
mperror_heart_beat.off_time = mp_hal_ticks_ms_non_blocking() + MPERROR_HEARTBEAT_OFF_MS;
}
}
}
Expand Down

0 comments on commit da8c822

Please sign in to comment.