diff options
author | Damien George <damien@micropython.org> | 2021-04-29 23:48:58 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-04-30 00:32:12 +1000 |
commit | 885b246ca91592ba48637a8519dd4fbd576ad38a (patch) | |
tree | 316bc2ad472815eed10209a449d0f8101aa7c00a | |
parent | a72b8443cae183ecd5396d3ae963984f4d2e1cdc (diff) |
stm32/boardctrl: Show first reset-mode state on LEDs when selecting.
Commit 1e297c88989592258965b69cb740039e26c7636c introduced a bug where the
very first reset-mode state on the LEDs was not shown, because prior to
that commit the first reset-mode state was the same as the initial LED
state (green on, others off) and update_reset_mode() was called after
setting this initial LED state.
This is fixed in this commit by changing the update_reset_mode() loop so
that it displays the current reset mode before doing the delay.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | ports/stm32/boardctrl.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/ports/stm32/boardctrl.c b/ports/stm32/boardctrl.c index ce04914ea..8cc519d8e 100644 --- a/ports/stm32/boardctrl.c +++ b/ports/stm32/boardctrl.c @@ -51,20 +51,21 @@ STATIC uint update_reset_mode(uint reset_mode) { // The original method used on the pyboard is appropriate if you have 2 // or more LEDs. #if defined(MICROPY_HW_LED2) - for (uint i = 0; i < 3000; i++) { - if (!switch_get()) { - break; - } - mp_hal_delay_ms(20); - if (i % 30 == 29) { - if (++reset_mode > BOARDCTRL_RESET_MODE_FACTORY_FILESYSTEM) { - reset_mode = BOARDCTRL_RESET_MODE_NORMAL; + for (uint i = 0; i < 100; i++) { + led_state(2, reset_mode & 1); + led_state(3, reset_mode & 2); + led_state(4, reset_mode & 4); + for (uint j = 0; j < 30; ++j) { + mp_hal_delay_ms(20); + if (!switch_get()) { + goto select_mode; } - led_state(2, reset_mode & 1); - led_state(3, reset_mode & 2); - led_state(4, reset_mode & 4); + } + if (++reset_mode > BOARDCTRL_RESET_MODE_FACTORY_FILESYSTEM) { + reset_mode = BOARDCTRL_RESET_MODE_NORMAL; } } + select_mode: // flash the selected reset mode for (uint i = 0; i < 6; i++) { led_state(2, 0); |