Skip to content

Commit d58919b

Browse files
committed
Fix delay function for higher delays
The fix done in 0f63ba4 was incorrect and broke button press count for higher delays.
1 parent 8f448da commit d58919b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib/user-io.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ uint8_t delay(uint16_t led_on_time_ms, uint16_t led_off_time_ms,
116116
uint16_t led_cycle_time_ms = led_on_time_ms + led_off_time_ms;
117117
uint16_t led_cycle_pos = 1;
118118
struct button_info info = {0, 0};
119+
uint16_t remaining = delay_ms;
119120

120-
while (delay_ms > 0) {
121+
while (remaining > 0) {
121122
if (led_on_time_ms != 0) {
122123
if (led_cycle_pos == 1) {
123124
PORTB |= PORTB_LED;
@@ -130,7 +131,7 @@ uint8_t delay(uint16_t led_on_time_ms, uint16_t led_off_time_ms,
130131

131132
track_button(&info);
132133

133-
delay_ms -= 1;
134+
remaining -= 1;
134135
led_cycle_pos += 1;
135136
}
136137

0 commit comments

Comments
 (0)