From ca83de5eda2d9edaa12cace83dcbefc7bb35dd9c Mon Sep 17 00:00:00 2001 From: Tero Marttila Date: Mon, 6 Jan 2025 20:26:08 +0200 Subject: [PATCH] leds_test: fix stuck active on pause or after TEST_MODE_BLACK --- main/leds_test.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/main/leds_test.c b/main/leds_test.c index 7f6e67ae..d5632636 100644 --- a/main/leds_test.c +++ b/main/leds_test.c @@ -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; @@ -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; } @@ -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) {