Ignore button jitters in bootloader mode

This commit is contained in:
wh201906 2024-01-03 15:39:50 +08:00
parent 6f49cc0224
commit 00686a91d0
No known key found for this signature in database
2 changed files with 10 additions and 2 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased]
- Fixed bootloader - Ignore jitters when pressing the button (@wh201906)
## [Steamboat Willie.4.17768][2024-01-03]
- Changed `mem spiffs dump -t` - now supports downloading direct into trace buffer (@hazardousvoltage)

View file

@ -252,10 +252,17 @@ static void flash_mode(void) {
}
}
if (g_common_area.flags.button_pressed && BUTTON_PRESS() == false) {
bool button_state = BUTTON_PRESS();
// ~10ms, prevent jitter
delay_loop(3333);
if (button_state != BUTTON_PRESS()) {
// in jitter state, ignore
continue;
}
if (g_common_area.flags.button_pressed && button_state == false) {
g_common_area.flags.button_pressed = 0;
}
if (!g_common_area.flags.button_pressed && BUTTON_PRESS()) {
if (!g_common_area.flags.button_pressed && button_state) {
/* Perform a reset to leave flash mode */
g_common_area.flags.button_pressed = 1;
usb_disable();