mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-20 03:52:39 +00:00
Add longLong button press
This commit is contained in:
parent
52feb9c98d
commit
63336a851b
@ -29,16 +29,18 @@ 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, uint16_t longPressTime,
|
||||
input_broker_event doublePress, input_broker_event triplePress, input_broker_event shortLong,
|
||||
input_broker_event doublePress, input_broker_event longLongPress, uint16_t longLongPressTime, input_broker_event triplePress, input_broker_event shortLong,
|
||||
bool touchQuirk)
|
||||
{
|
||||
if (inputBroker)
|
||||
inputBroker->registerSource(this);
|
||||
_longPressTime = longPressTime;
|
||||
_longLongPressTime = longLongPressTime;
|
||||
_pinNum = pinNumber;
|
||||
_activeLow = activeLow;
|
||||
_touchQuirk = touchQuirk;
|
||||
_intRoutine = intRoutine;
|
||||
_longLongPress = longLongPress;
|
||||
|
||||
userButton = OneButton(pinNumber, activeLow, activePullup);
|
||||
|
||||
@ -141,7 +143,7 @@ int32_t ButtonThread::runOnce()
|
||||
|
||||
// Progressive lead-up sound system
|
||||
if (buttonCurrentlyPressed && (millis() - buttonPressStartTime) >= BUTTON_LEADUP_MS &&
|
||||
(millis() - buttonPressStartTime) < _longPressTime) {
|
||||
(millis() - buttonPressStartTime) < _longLongPressTime) {
|
||||
|
||||
// Start the progressive sequence if not already active
|
||||
if (!leadUpSequenceActive) {
|
||||
@ -274,6 +276,10 @@ int32_t ButtonThread::runOnce()
|
||||
case BUTTON_EVENT_LONG_RELEASED: {
|
||||
|
||||
LOG_INFO("LONG PRESS RELEASE");
|
||||
if (_longLongPress != INPUT_BROKER_NONE && (millis() - buttonPressStartTime) >= _longLongPressTime) {
|
||||
evt.inputEvent = _longLongPress;
|
||||
this->notifyObservers(&evt);
|
||||
}
|
||||
// Reset combination tracking
|
||||
waitingForLongPress = false;
|
||||
|
||||
|
@ -30,7 +30,8 @@ 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,
|
||||
uint16_t longPressTime = 500, input_broker_event doublePress = INPUT_BROKER_NONE,
|
||||
uint16_t longPressTime = 500, input_broker_event doublePress = INPUT_BROKER_NONE,
|
||||
input_broker_event longLongPress = INPUT_BROKER_NONE, uint16_t longLongPressTime = 5000,
|
||||
input_broker_event triplePress = INPUT_BROKER_NONE, input_broker_event shortLong = INPUT_BROKER_NONE,
|
||||
bool touchQuirk = false);
|
||||
|
||||
@ -68,12 +69,15 @@ class ButtonThread : public Observable<const InputEvent *>, public concurrency::
|
||||
private:
|
||||
input_broker_event _singlePress = INPUT_BROKER_NONE;
|
||||
input_broker_event _longPress = INPUT_BROKER_NONE;
|
||||
input_broker_event _longLongPress = INPUT_BROKER_NONE;
|
||||
|
||||
input_broker_event _doublePress = INPUT_BROKER_NONE;
|
||||
input_broker_event _triplePress = INPUT_BROKER_NONE;
|
||||
input_broker_event _shortLong = INPUT_BROKER_NONE;
|
||||
|
||||
voidFuncPtr _intRoutine = nullptr;
|
||||
uint16_t _longPressTime = 500;
|
||||
uint16_t _longLongPressTime = 5000;
|
||||
int _pinNum = 0;
|
||||
bool _activeLow = true;
|
||||
bool _touchQuirk = false;
|
||||
|
@ -996,7 +996,7 @@ void setup()
|
||||
BaseType_t higherWake = 0;
|
||||
mainDelay.interruptFromISR(&higherWake);
|
||||
},
|
||||
INPUT_BROKER_USER_PRESS, INPUT_BROKER_SELECT);
|
||||
INPUT_BROKER_USER_PRESS, INPUT_BROKER_SELECT, INPUT_BROKER_SHUTDOWN);
|
||||
else
|
||||
UserButtonThread->initButton(
|
||||
_pinNum, BUTTON_ACTIVE_LOW, BUTTON_ACTIVE_PULLUP, pullup_sense,
|
||||
|
Loading…
Reference in New Issue
Block a user