mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-15 09:32:08 +00:00
LonPressTime now configurable
This commit is contained in:
parent
bc934e3659
commit
d25d513e40
@ -28,11 +28,13 @@ ButtonThread::ButtonThread(const char *name) : OSThread(name)
|
||||
}
|
||||
|
||||
bool ButtonThread::initButton(uint8_t pinNumber, bool activeLow, bool activePullup, uint32_t pullupSense, voidFuncPtr intRoutine,
|
||||
input_broker_event singlePress, input_broker_event longPress, input_broker_event doublePress,
|
||||
input_broker_event triplePress, input_broker_event shortLong, bool touchQuirk)
|
||||
input_broker_event singlePress, input_broker_event longPress, uint16_t longPressTime,
|
||||
input_broker_event doublePress, input_broker_event triplePress, input_broker_event shortLong,
|
||||
bool touchQuirk)
|
||||
{
|
||||
if (inputBroker)
|
||||
inputBroker->registerSource(this);
|
||||
_longPressTime = longPressTime;
|
||||
_pinNum = pinNumber;
|
||||
_activeLow = activeLow;
|
||||
_touchQuirk = touchQuirk;
|
||||
@ -97,9 +99,9 @@ bool ButtonThread::initButton(uint8_t pinNumber, bool activeLow, bool activePull
|
||||
userButton.setDebounceMs(1);
|
||||
if (screen) {
|
||||
userButton.setClickMs(20);
|
||||
userButton.setPressMs(BUTTON_LONGPRESS_MS);
|
||||
userButton.setPressMs(_longPressTime);
|
||||
} else {
|
||||
userButton.setPressMs(BUTTON_LONGPRESS_MS * 3);
|
||||
userButton.setPressMs(_longPressTime);
|
||||
userButton.setClickMs(BUTTON_CLICK_MS);
|
||||
}
|
||||
attachButtonInterrupts();
|
||||
@ -139,7 +141,7 @@ int32_t ButtonThread::runOnce()
|
||||
|
||||
// Progressive lead-up sound system
|
||||
if (buttonCurrentlyPressed && (millis() - buttonPressStartTime) >= BUTTON_LEADUP_MS &&
|
||||
(millis() - buttonPressStartTime) < BUTTON_LONGPRESS_MS) {
|
||||
(millis() - buttonPressStartTime) < _longPressTime) {
|
||||
|
||||
// Start the progressive sequence if not already active
|
||||
if (!leadUpSequenceActive) {
|
||||
|
@ -11,15 +11,6 @@ typedef void (*voidFuncPtr)(void);
|
||||
#define BUTTON_CLICK_MS 250
|
||||
#endif
|
||||
|
||||
#ifdef HAS_SCREEN
|
||||
#undef BUTTON_LONGPRESS_MS
|
||||
#define BUTTON_LONGPRESS_MS 500
|
||||
#else
|
||||
#ifndef BUTTON_LONGPRESS_MS
|
||||
#define BUTTON_LONGPRESS_MS 5000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BUTTON_TOUCH_MS
|
||||
#define BUTTON_TOUCH_MS 400
|
||||
#endif
|
||||
@ -39,8 +30,9 @@ class ButtonThread : public Observable<const InputEvent *>, public concurrency::
|
||||
static const uint32_t c_holdOffTime = 30000; // hold off 30s after boot
|
||||
bool initButton(uint8_t pinNumber, bool activeLow, bool activePullup, uint32_t pullupSense, voidFuncPtr intRoutine,
|
||||
input_broker_event singlePress, input_broker_event longPress = INPUT_BROKER_NONE,
|
||||
input_broker_event doublePress = INPUT_BROKER_NONE, input_broker_event triplePress = INPUT_BROKER_NONE,
|
||||
input_broker_event shortLong = INPUT_BROKER_NONE, bool touchQuirk = false);
|
||||
uint16_t longPressTime = 500, input_broker_event doublePress = INPUT_BROKER_NONE,
|
||||
input_broker_event triplePress = INPUT_BROKER_NONE, input_broker_event shortLong = INPUT_BROKER_NONE,
|
||||
bool touchQuirk = false);
|
||||
|
||||
enum ButtonEventType {
|
||||
BUTTON_EVENT_NONE,
|
||||
@ -81,6 +73,7 @@ class ButtonThread : public Observable<const InputEvent *>, public concurrency::
|
||||
input_broker_event _shortLong = INPUT_BROKER_NONE;
|
||||
|
||||
voidFuncPtr _intRoutine = nullptr;
|
||||
uint16_t _longPressTime = 500;
|
||||
int _pinNum = 0;
|
||||
bool _activeLow = true;
|
||||
bool _touchQuirk = false;
|
||||
|
@ -924,7 +924,7 @@ void setup()
|
||||
BaseType_t higherWake = 0;
|
||||
mainDelay.interruptFromISR(&higherWake);
|
||||
},
|
||||
INPUT_BROKER_BACK);
|
||||
INPUT_BROKER_BACK, INPUT_BROKER_SHUTDOWN, 4000);
|
||||
#endif
|
||||
|
||||
#if defined(BUTTON_PIN)
|
||||
@ -962,7 +962,7 @@ void setup()
|
||||
BaseType_t higherWake = 0;
|
||||
mainDelay.interruptFromISR(&higherWake);
|
||||
},
|
||||
INPUT_BROKER_USER_PRESS, INPUT_BROKER_SHUTDOWN, INPUT_BROKER_SEND_PING, INPUT_BROKER_GPS_TOGGLE);
|
||||
INPUT_BROKER_USER_PRESS, INPUT_BROKER_SHUTDOWN, 5000, INPUT_BROKER_SEND_PING, INPUT_BROKER_GPS_TOGGLE);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user