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

Commit da8c822

Browse files
mperror.c: Move noticing of the next heartbeat transition (#236)
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]>
1 parent e6f4eb6 commit da8c822

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

esp32/util/mperror.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,18 @@ bool mperror_heartbeat_signal (void) {
130130
mperror_heart_beat.do_disable = false;
131131
} else if (mperror_heart_beat.enabled) {
132132
if (!mperror_heart_beat.beating) {
133-
if ((mperror_heart_beat.on_time = mp_hal_ticks_ms_non_blocking()) - mperror_heart_beat.off_time > MPERROR_HEARTBEAT_OFF_MS) {
133+
if (mp_hal_ticks_ms_non_blocking() > mperror_heart_beat.off_time) {
134134
led_info.color.value = MPERROR_HEARTBEAT_COLOR;
135-
led_set_color(&led_info, false, false);
135+
led_set_color(&led_info, true, false);
136136
mperror_heart_beat.beating = true;
137+
mperror_heart_beat.on_time = mp_hal_ticks_ms_non_blocking() + MPERROR_HEARTBEAT_ON_MS;
137138
}
138139
} else {
139-
if ((mperror_heart_beat.off_time = mp_hal_ticks_ms_non_blocking()) - mperror_heart_beat.on_time > MPERROR_HEARTBEAT_ON_MS) {
140+
if (mp_hal_ticks_ms_non_blocking() > mperror_heart_beat.on_time) {
140141
led_info.color.value = 0;
141-
led_set_color(&led_info, false, false);
142+
led_set_color(&led_info, true, false);
142143
mperror_heart_beat.beating = false;
144+
mperror_heart_beat.off_time = mp_hal_ticks_ms_non_blocking() + MPERROR_HEARTBEAT_OFF_MS;
143145
}
144146
}
145147
}

0 commit comments

Comments
 (0)