From 6d834789663393e00bec585aae4526f453b53199 Mon Sep 17 00:00:00 2001 From: amandel Date: Fri, 8 Jan 2021 21:24:18 +0100 Subject: [PATCH] Do not start upload timer if button was never released resolves #203 --- src/OpenBikeSensorFirmware.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/OpenBikeSensorFirmware.cpp b/src/OpenBikeSensorFirmware.cpp index 60a7b521..ddcc499a 100644 --- a/src/OpenBikeSensorFirmware.cpp +++ b/src/OpenBikeSensorFirmware.cpp @@ -248,7 +248,9 @@ void setup() { ESP_ERROR_CHECK_WITHOUT_ABORT( esp_bt_mem_release(ESP_BT_MODE_BTDM)); // no bluetooth at all here. - delay(300); + buttonStateChanged = 0; + lastButtonState = buttonState; + delay(200); startServer(&cfg); OtaInit(esp_chipid); while (true) { @@ -411,7 +413,7 @@ void handleButtonInServerMode() { buttonStateChanged = now; } if (!configServerWasConnectedViaHttp() && - buttonState == HIGH) { + buttonState == HIGH && buttonStateChanged != 0) { const uint32_t buttonPressedMs = now - buttonStateChanged; displayTest->drawProgressBar(5, buttonPressedMs, BUTTON_PRESS_TIME_FOR_AUTO_UPLOAD_MS); if (buttonPressedMs > BUTTON_PRESS_TIME_FOR_AUTO_UPLOAD_MS) {