usability fixes, fix t114 build src filter
This commit is contained in:
@@ -60,10 +60,10 @@ void Button::update() {
|
|||||||
_state = IDLE;
|
_state = IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle long press
|
// Handle long press while button is held
|
||||||
if (_state == PRESSED && (now - _pressTime) > BUTTON_LONG_PRESS_TIME_MS) {
|
if (_state == PRESSED && (now - _pressTime) > BUTTON_LONG_PRESS_TIME_MS) {
|
||||||
triggerEvent(LONG_PRESS);
|
triggerEvent(LONG_PRESS);
|
||||||
_state = IDLE; // Prevent multiple long press events
|
_state = IDLE; // Prevent multiple press events
|
||||||
_clickCount = 0;
|
_clickCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ void Button::handleStateChange() {
|
|||||||
} else {
|
} else {
|
||||||
// Long press already handled in update()
|
// Long press already handled in update()
|
||||||
_state = IDLE;
|
_state = IDLE;
|
||||||
_clickCount = 0; // Reset click count after long press
|
_clickCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// Button timing configuration
|
// Button timing configuration
|
||||||
#define BUTTON_DEBOUNCE_TIME_MS 50 // Debounce time in ms
|
#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_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
|
#define BUTTON_READ_INTERVAL_MS 10 // How often to read the button
|
||||||
|
|
||||||
class Button {
|
class Button {
|
||||||
@@ -33,7 +33,7 @@ public:
|
|||||||
void onDoublePress(EventCallback callback) { _onDoublePress = callback; }
|
void onDoublePress(EventCallback callback) { _onDoublePress = callback; }
|
||||||
void onTriplePress(EventCallback callback) { _onTriplePress = callback; }
|
void onTriplePress(EventCallback callback) { _onTriplePress = callback; }
|
||||||
void onLongPress(EventCallback callback) { _onLongPress = callback; }
|
void onLongPress(EventCallback callback) { _onLongPress = callback; }
|
||||||
void onAnyPress(EventCallback callback) { _onAnyPress = callback; } // New method
|
void onAnyPress(EventCallback callback) { _onAnyPress = callback; }
|
||||||
|
|
||||||
// State getters
|
// State getters
|
||||||
bool isPressed() const { return _currentState == _activeState; }
|
bool isPressed() const { return _currentState == _activeState; }
|
||||||
|
|||||||
@@ -308,11 +308,13 @@ void UITask::loop() {
|
|||||||
|
|
||||||
void UITask::handleButtonAnyPress() {
|
void UITask::handleButtonAnyPress() {
|
||||||
MESH_DEBUG_PRINTLN("UITask: any press triggered");
|
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 != NULL) {
|
||||||
if (!_display->isOn()) {
|
_displayWasOn = _display->isOn(); // Track display state before any action
|
||||||
|
if (!_displayWasOn) {
|
||||||
_display->turnOn();
|
_display->turnOn();
|
||||||
}
|
}
|
||||||
_need_refresh = true;
|
|
||||||
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
|
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -320,12 +322,17 @@ void UITask::handleButtonAnyPress() {
|
|||||||
void UITask::handleButtonShortPress() {
|
void UITask::handleButtonShortPress() {
|
||||||
MESH_DEBUG_PRINTLN("UITask: short press triggered");
|
MESH_DEBUG_PRINTLN("UITask: short press triggered");
|
||||||
if (_display != NULL) {
|
if (_display != NULL) {
|
||||||
if (_display->isOn()) {
|
// Only clear message preview if display was already on before button press
|
||||||
// If display is on and showing message preview, clear it
|
if (_displayWasOn) {
|
||||||
|
// If display was on and showing message preview, clear it
|
||||||
if (_origin[0] && _msg[0]) {
|
if (_origin[0] && _msg[0]) {
|
||||||
clearMsgPreview();
|
clearMsgPreview();
|
||||||
|
} else {
|
||||||
|
// Otherwise, refresh the display
|
||||||
|
_need_refresh = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Note: Display turn-on and auto-off timer extension are handled by handleButtonAnyPress
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class UITask {
|
|||||||
char _msg[80];
|
char _msg[80];
|
||||||
int _msgcount;
|
int _msgcount;
|
||||||
bool _need_refresh = true;
|
bool _need_refresh = true;
|
||||||
|
bool _displayWasOn = false; // Track display state before button press
|
||||||
|
|
||||||
// Button handlers
|
// Button handlers
|
||||||
#if defined(PIN_USER_BTN) || defined(PIN_USER_BTN_ANA)
|
#if defined(PIN_USER_BTN) || defined(PIN_USER_BTN_ANA)
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ build_flags =
|
|||||||
build_src_filter = ${Heltec_t114.build_src_filter}
|
build_src_filter = ${Heltec_t114.build_src_filter}
|
||||||
+<helpers/nrf52/T114Board.cpp>
|
+<helpers/nrf52/T114Board.cpp>
|
||||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||||
+<../examples/companion_radio/main.cpp>
|
+<../examples/companion_radio>
|
||||||
+<../examples/companion_radio/UITask.cpp>
|
|
||||||
+<helpers/ui/ST7789Display.cpp>
|
+<helpers/ui/ST7789Display.cpp>
|
||||||
+<helpers/ui/OLEDDisplay.cpp>
|
+<helpers/ui/OLEDDisplay.cpp>
|
||||||
+<helpers/ui/OLEDDisplayFonts.cpp>
|
+<helpers/ui/OLEDDisplayFonts.cpp>
|
||||||
|
|||||||
Reference in New Issue
Block a user