usability fixes, fix t114 build src filter

This commit is contained in:
JQ 2025-05-30 20:32:49 -07:00
parent 0b97b23025
commit db8e72791c
5 changed files with 18 additions and 11 deletions

View file

@ -60,10 +60,10 @@ void Button::update() {
_state = IDLE;
}
// Handle long press
// Handle long press while button is held
if (_state == PRESSED && (now - _pressTime) > BUTTON_LONG_PRESS_TIME_MS) {
triggerEvent(LONG_PRESS);
_state = IDLE; // Prevent multiple long press events
_state = IDLE; // Prevent multiple press events
_clickCount = 0;
}
}
@ -97,7 +97,7 @@ void Button::handleStateChange() {
} else {
// Long press already handled in update()
_state = IDLE;
_clickCount = 0; // Reset click count after long press
_clickCount = 0;
}
}
}

View file

@ -6,7 +6,7 @@
// Button timing configuration
#define BUTTON_DEBOUNCE_TIME_MS 50 // Debounce time in ms
#define BUTTON_CLICK_TIMEOUT_MS 500 // Max time between clicks for multi-click
#define BUTTON_LONG_PRESS_TIME_MS 5000 // Time to trigger long press (5 seconds)
#define BUTTON_LONG_PRESS_TIME_MS 3000 // Time to trigger long press (3 seconds)
#define BUTTON_READ_INTERVAL_MS 10 // How often to read the button
class Button {
@ -33,7 +33,7 @@ public:
void onDoublePress(EventCallback callback) { _onDoublePress = callback; }
void onTriplePress(EventCallback callback) { _onTriplePress = callback; }
void onLongPress(EventCallback callback) { _onLongPress = callback; }
void onAnyPress(EventCallback callback) { _onAnyPress = callback; } // New method
void onAnyPress(EventCallback callback) { _onAnyPress = callback; }
// State getters
bool isPressed() const { return _currentState == _activeState; }

View file

@ -308,11 +308,13 @@ void UITask::loop() {
void UITask::handleButtonAnyPress() {
MESH_DEBUG_PRINTLN("UITask: any press triggered");
// called on any button press before other events, to wake up the display quickly
// do not refresh the display here, as it may block the button handler
if (_display != NULL) {
if (!_display->isOn()) {
_displayWasOn = _display->isOn(); // Track display state before any action
if (!_displayWasOn) {
_display->turnOn();
}
_need_refresh = true;
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
}
}
@ -320,12 +322,17 @@ void UITask::handleButtonAnyPress() {
void UITask::handleButtonShortPress() {
MESH_DEBUG_PRINTLN("UITask: short press triggered");
if (_display != NULL) {
if (_display->isOn()) {
// If display is on and showing message preview, clear it
// Only clear message preview if display was already on before button press
if (_displayWasOn) {
// If display was on and showing message preview, clear it
if (_origin[0] && _msg[0]) {
clearMsgPreview();
} else {
// Otherwise, refresh the display
_need_refresh = true;
}
}
// Note: Display turn-on and auto-off timer extension are handled by handleButtonAnyPress
}
}

View file

@ -35,6 +35,7 @@ class UITask {
char _msg[80];
int _msgcount;
bool _need_refresh = true;
bool _displayWasOn = false; // Track display state before button press
// Button handlers
#if defined(PIN_USER_BTN) || defined(PIN_USER_BTN_ANA)

View file

@ -79,8 +79,7 @@ build_flags =
build_src_filter = ${Heltec_t114.build_src_filter}
+<helpers/nrf52/T114Board.cpp>
+<helpers/nrf52/SerialBLEInterface.cpp>
+<../examples/companion_radio/main.cpp>
+<../examples/companion_radio/UITask.cpp>
+<../examples/companion_radio>
+<helpers/ui/ST7789Display.cpp>
+<helpers/ui/OLEDDisplay.cpp>
+<helpers/ui/OLEDDisplayFonts.cpp>