From 806f943116f4df8a666b6bd7182bfcbe5cf3c13a Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 22 Feb 2019 15:47:34 +0100 Subject: [PATCH] bootloader: require only left button to start the bootloader --- bootloader/bootloader.c | 6 ++---- buttons.c | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/bootloader/bootloader.c b/bootloader/bootloader.c index 85baf84333..2497b13856 100644 --- a/bootloader/bootloader.c +++ b/bootloader/bootloader.c @@ -119,11 +119,9 @@ int main(void) mpu_config_bootloader(); #ifndef APPVER - // at least one button is unpressed - uint16_t state = gpio_port_read(BTN_PORT); - int unpressed = ((state & BTN_PIN_YES) == BTN_PIN_YES || (state & BTN_PIN_NO) == BTN_PIN_NO); + bool left_pressed = (buttonRead() & BTN_PIN_NO) == 0; - if (firmware_present_new() && unpressed) { + if (firmware_present_new() && !left_pressed) { oledClear(); oledDrawBitmap(40, 0, &bmp_logo64_empty); diff --git a/buttons.c b/buttons.c index a6e64b5ad6..f416736c38 100644 --- a/buttons.c +++ b/buttons.c @@ -29,10 +29,9 @@ uint16_t buttonRead(void) { void buttonUpdate() { - uint16_t state; static uint16_t last_state = BTN_PIN_YES | BTN_PIN_NO; - state = buttonRead(); + uint16_t state = buttonRead(); if ((state & BTN_PIN_YES) == 0) { // Yes button is down if ((last_state & BTN_PIN_YES) == 0) { // last Yes was down