From d12e533a547d95a3ac340d59aa0dd6f6765de3f5 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Tue, 2 May 2023 08:37:07 -0600 Subject: fixed bug: channel change could stick when activating a config menu from battcheck (the blink function changed the channel, then the config menu saved it, then the blink function restored it, then the config menu restored it to the value it saved, which was wrong) --- spaghetti-monster/fsm-misc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'spaghetti-monster') diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 1c40b81..dacca85 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -33,15 +33,29 @@ uint8_t blink_digit(uint8_t num) { if (!num) { ontime = 8; num ++; } #ifdef BLINK_CHANNEL + // channel is set per blink, to prevent issues + // if another mode interrupts us (like a config menu) uint8_t old_channel = CH_MODE; - set_channel_mode(BLINK_CHANNEL); #endif for (; num>0; num--) { // TODO: allow setting a blink channel mode per build target + #ifdef BLINK_CHANNEL + set_channel_mode(BLINK_CHANNEL); + #endif set_level(BLINK_BRIGHTNESS); + #ifdef BLINK_CHANNEL + CH_MODE = old_channel; + #endif nice_delay_ms(ontime); + + #ifdef BLINK_CHANNEL + set_channel_mode(BLINK_CHANNEL); + #endif set_level(0); + #ifdef BLINK_CHANNEL + CH_MODE = old_channel; + #endif nice_delay_ms(BLINK_SPEED * 3 / 12); } -- cgit v1.2.3