From 45fa527eb649dbf2c04bcdb17bfa76cb55a2cb6f Mon Sep 17 00:00:00 2001 From: DriftKingTW Date: Sat, 9 Dec 2023 20:04:30 +0800 Subject: [PATCH] feat: long press function for config buttons --- src/main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ea0eb2a..510d010 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -889,16 +889,26 @@ void loop() { // Read CFG Buttons if (digitalRead(CFG_BTN_PIN_1) == ACTIVE) { resetIdle(); - switchBootMode(); + int longPressCounter = 0; while (digitalRead(CFG_BTN_PIN_1) == ACTIVE) { delay(10); + if (longPressCounter > 100) { + switchBootMode(); + } + longPressCounter++; } + isCaffeinated = !isCaffeinated; } else if (digitalRead(CFG_BTN_PIN_2) == ACTIVE) { resetIdle(); - isUsbMode = !isUsbMode; + int longPressCounter = 0; while (digitalRead(CFG_BTN_PIN_2) == ACTIVE) { delay(10); + if (longPressCounter > 100) { + goSleeping(); + } + longPressCounter++; } + isUsbMode = !isUsbMode; } }