From 5e160b21c78927dd36134a4c6d5f7b08a0603565 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Fri, 10 May 2024 01:14:58 +1200 Subject: [PATCH] T-Echo screen and button performance (#3840) * Make button timing configurable per variant * Adjust button timing for T-Echo Easier multi-clicks for features like "toggle backlight" (4x click) * Fewer full-refreshes for T-Echo display Disables ghost pixel tracking: T-Echo ghost pixels are fairly faint. --- src/ButtonThread.cpp | 10 +++++----- src/ButtonThread.h | 15 +++++++++++++-- variants/t-echo/platformio.ini | 2 +- variants/t-echo/variant.h | 3 +++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index 97cce7bc2..aaead62be 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -52,8 +52,8 @@ ButtonThread::ButtonThread() : OSThread("Button") #if defined(BUTTON_PIN) || defined(ARCH_PORTDUINO) userButton.attachClick(userButtonPressed); - userButton.setClickMs(250); - userButton.setPressMs(c_longPressTime); + userButton.setClickMs(BUTTON_CLICK_MS); + userButton.setPressMs(BUTTON_LONGPRESS_MS); userButton.setDebounceMs(1); userButton.attachDoubleClick(userButtonDoublePressed); userButton.attachMultiClick(userButtonMultiPressed, this); // Reference to instance: get click count from non-static OneButton @@ -70,8 +70,8 @@ ButtonThread::ButtonThread() : OSThread("Button") pinMode(BUTTON_PIN_ALT, INPUT_PULLUP_SENSE); #endif userButtonAlt.attachClick(userButtonPressed); - userButtonAlt.setClickMs(250); - userButtonAlt.setPressMs(c_longPressTime); + userButtonAlt.setClickMs(BUTTON_CLICK_MS); + userButtonAlt.setPressMs(BUTTON_LONGPRESS_MS); userButtonAlt.setDebounceMs(1); userButtonAlt.attachDoubleClick(userButtonDoublePressed); userButtonAlt.attachLongPressStart(userButtonPressedLongStart); @@ -80,7 +80,7 @@ ButtonThread::ButtonThread() : OSThread("Button") #ifdef BUTTON_PIN_TOUCH userButtonTouch = OneButton(BUTTON_PIN_TOUCH, true, true); - userButtonTouch.setPressMs(400); + userButtonTouch.setPressMs(BUTTON_TOUCH_MS); userButtonTouch.attachLongPressStart(touchPressedLongStart); // Better handling with longpress than click? #endif diff --git a/src/ButtonThread.h b/src/ButtonThread.h index 07c7ccff7..d7a9201a3 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -4,11 +4,22 @@ #include "concurrency/OSThread.h" #include "configuration.h" +#ifndef BUTTON_CLICK_MS +#define BUTTON_CLICK_MS 250 +#endif + +#ifndef BUTTON_LONGPRESS_MS +#define BUTTON_LONGPRESS_MS 5000 +#endif + +#ifndef BUTTON_TOUCH_MS +#define BUTTON_TOCH_MS 400 +#endif + class ButtonThread : public concurrency::OSThread { public: - static const uint32_t c_longPressTime = 5000; // shutdown after 5s - static const uint32_t c_holdOffTime = 30000; // hold off 30s after boot + static const uint32_t c_holdOffTime = 30000; // hold off 30s after boot enum ButtonEventType { BUTTON_EVENT_NONE, diff --git a/variants/t-echo/platformio.ini b/variants/t-echo/platformio.ini index 9ff60be3f..c036a39a2 100644 --- a/variants/t-echo/platformio.ini +++ b/variants/t-echo/platformio.ini @@ -15,7 +15,7 @@ build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo -DEINK_LIMIT_FASTREFRESH=20 ; How many consecutive fast-refreshes are permitted -DEINK_LIMIT_RATE_BACKGROUND_SEC=30 ; Minimum interval between BACKGROUND updates -DEINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates - -DEINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated +; -DEINK_LIMIT_GHOSTING_PX=2000 ; (Optional) How much image ghosting is tolerated -DEINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached. build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo> lib_deps = diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index 2abeed16d..1c263a61a 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -65,6 +65,9 @@ extern "C" { #define PIN_BUTTON2 (0 + 18) // 0.18 is labeled on the board as RESET but we configure it in the bootloader as a regular GPIO #define PIN_BUTTON_TOUCH (0 + 11) // 0.11 is the soft touch button on T-Echo +#define BUTTON_CLICK_MS 400 +#define BUTTON_TOUCH_MS 200 + /* * Analog pins */