Skip to content

Commit abc2cfa

Browse files
microbit-carlosmbrossard
authored andcommitted
microbitv2: Remove unused RESET_MID_PRESS button state.
1 parent fd21a11 commit abc2cfa

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

source/board/microbitv2/microbitv2.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,24 +176,17 @@ void handle_reset_button()
176176
reset_pressed = 0;
177177
power_led_sleep_state_on = PWR_LED_SLEEP_STATE_DEFAULT;
178178

179-
if (gpio_reset_count <= RESET_SHORT_PRESS) {
180-
main_shutdown_state = MAIN_LED_BLINK_ONCE;
181-
}
182-
else if (gpio_reset_count < RESET_MID_PRESS) {
179+
if (gpio_reset_count < RESET_SHORT_PRESS) {
183180
// Indicate button has been released to stop to cancel the shutdown
184181
main_shutdown_state = MAIN_LED_BLINK_ONCE;
185182
}
186-
else if (gpio_reset_count >= RESET_MID_PRESS) {
183+
else if (gpio_reset_count >= RESET_SHORT_PRESS) {
187184
// Indicate the button has been released when shutdown is requested
188185
main_shutdown_state = MAIN_USER_EVENT;
189186
}
190187
} else if (reset_pressed && gpio_get_reset_btn_fwrd()) {
191188
// Reset button is still pressed
192-
if (gpio_reset_count <= RESET_SHORT_PRESS) {
193-
// Enter the shutdown pending state to begin LED dimming
194-
main_shutdown_state = MAIN_SHUTDOWN_PENDING;
195-
}
196-
else if (gpio_reset_count < RESET_MID_PRESS) {
189+
if (gpio_reset_count < RESET_SHORT_PRESS) {
197190
// Enter the shutdown pending state to begin LED dimming
198191
main_shutdown_state = MAIN_SHUTDOWN_PENDING;
199192
}
@@ -253,7 +246,7 @@ void board_30ms_hook()
253246
break;
254247
case MAIN_SHUTDOWN_PENDING:
255248
// Fade the PWM until the board is about to be shut down
256-
shutdown_led_dc = PWR_LED_INIT_FADE_BRIGHTNESS - gpio_reset_count * (PWR_LED_INIT_FADE_BRIGHTNESS - PWR_LED_FADEOUT_MIN_BRIGHTNESS)/(RESET_MID_PRESS);
249+
shutdown_led_dc = PWR_LED_INIT_FADE_BRIGHTNESS - gpio_reset_count * (PWR_LED_INIT_FADE_BRIGHTNESS - PWR_LED_FADEOUT_MIN_BRIGHTNESS)/(RESET_SHORT_PRESS);
257250
break;
258251
case MAIN_SHUTDOWN_REACHED:
259252
// Hold LED in min brightness

source/board/microbitv2/microbitv2.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
#define AUTOMATIC_SLEEP_DEFAULT true
3434

3535
// define the reset button presses
36-
#define RESET_SHORT_PRESS 10 // x 30ms debounce time = 300ms
37-
#define RESET_MID_PRESS 80 // x 30ms debounce time = 2400ms
36+
#define RESET_SHORT_PRESS 80 // x 30ms debounce time = 2400ms
3837
#define RESET_LONG_PRESS 120 // x 30ms debounce time = 3600ms
3938
#define RESET_MAX_LENGTH_PRESS RESET_LONG_PRESS
4039

0 commit comments

Comments
 (0)