Skip to content

Commit

Permalink
leds_test: fix stuck active on pause or after TEST_MODE_BLACK
Browse files Browse the repository at this point in the history
  • Loading branch information
SpComb committed Jan 6, 2025
1 parent b9ee7b6 commit ca83de5
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions main/leds_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void reset_leds_test()
continue;
}

// will be reset to 0 by leds_test_update()
state->test->mode = TEST_MODE_BLACK;
state->test->auto_mode = false;

Expand Down Expand Up @@ -120,7 +121,7 @@ TickType_t leds_test_wait(struct leds_state *state)

bool leds_test_active(struct leds_state *state, EventBits_t bits)
{
if (state->test->mode) {
if (state->test->mode && state->test->frame_tick) {
return true;
}

Expand All @@ -146,18 +147,26 @@ int leds_test_update(struct leds_state *state, EventBits_t bits)
return -1;
} else if (frame_ticks) {
// tick for next frame
LOG_DEBUG("mode=%d auto=%d frame=%d frame_tick=%d -> wait frame_ticks=%d", state->test->mode, state->test->auto_mode, state->test->frame, state->test->frame_tick, frame_ticks);

state->test->frame++;
state->test->frame_tick += frame_ticks;
} else if (!state->test->auto_mode) {
// pause
state->test->frame_tick = 0;
} else if (state->test->mode < TEST_MODE_BLACK) {
} else if (state->test->mode == TEST_MODE_BLACK) {
// end
LOG_DEBUG("mode=%d auto=%d frame=%d frame_tick=%d -> reset", state->test->mode, state->test->auto_mode, state->test->frame, state->test->frame_tick);

leds_test_reset(state);
} else if (state->test->auto_mode) {
// advance to next mode
LOG_DEBUG("mode=%d auto=%d frame=%d frame_tick=%d -> next mode", state->test->mode, state->test->auto_mode, state->test->frame, state->test->frame_tick);

state->test->mode++;
state->test->frame = 0;
} else {
// end
leds_test_reset(state);
// pause
LOG_DEBUG("mode=%d auto=%d frame=%d frame_tick=%d -> pause", state->test->mode, state->test->auto_mode, state->test->frame, state->test->frame_tick);

state->test->frame_tick = 0;
}

if (state->artnet) {
Expand Down

0 comments on commit ca83de5

Please sign in to comment.