Skip to content

Commit

Permalink
Additional code review change
Browse files Browse the repository at this point in the history
  • Loading branch information
voloved committed Aug 24, 2024
1 parent c6f2bff commit d5a8c57
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions movement/movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,10 +681,15 @@ static void debounce_btn_press(uint8_t pin, uint8_t *debounce_ticks, uint16_t *d
*down_timestamp = 0;
}

static void disable_if_needed(uint8_t *ticks) {
if (*ticks > 0 && --*ticks == 0)
_movement_disable_fast_tick_if_possible();
}

static void movement_disable_if_debounce_complete(void) {
if (movement_state.debounce_ticks_light > 0 && --movement_state.debounce_ticks_light == 0) _movement_disable_fast_tick_if_possible();
if (movement_state.debounce_ticks_alarm > 0 && --movement_state.debounce_ticks_alarm == 0) _movement_disable_fast_tick_if_possible();
if (movement_state.debounce_ticks_mode > 0 && --movement_state.debounce_ticks_mode == 0) _movement_disable_fast_tick_if_possible();
disable_if_needed(&movement_state.debounce_ticks_light);
disable_if_needed(&movement_state.debounce_ticks_alarm);
disable_if_needed(&movement_state.debounce_ticks_mode);
}

void cb_light_btn_interrupt(void) {
Expand Down

0 comments on commit d5a8c57

Please sign in to comment.