diff --git a/src/ButtonThread.h b/src/ButtonThread.h index 1b86f092..a1b68709 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -147,7 +147,11 @@ class ButtonThread : public concurrency::OSThread static void userButtonPressed() { // DEBUG_MSG("press!\n"); - powerFSM.trigger(EVENT_PRESS); +#ifdef BUTTON_PIN + if ((BUTTON_PIN != radioConfig.preferences.rotary1_pin_press) || !radioConfig.preferences.canned_message_module_enabled) { + powerFSM.trigger(EVENT_PRESS); + } +#endif } static void userButtonPressedLong() { diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 802f8665..0106cff4 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -279,6 +279,12 @@ void PowerFSM_setup() powerFSM.add_transition(&stateON, &stateSHUTDOWN, EVENT_SHUTDOWN, NULL, "Shutdown"); powerFSM.add_transition(&stateSERIAL, &stateSHUTDOWN, EVENT_SHUTDOWN, NULL, "Shutdown"); + // Inputbroker + powerFSM.add_transition(&stateLS, &stateON, EVENT_INPUT, NULL, "Input Device"); + powerFSM.add_transition(&stateNB, &stateON, EVENT_INPUT, NULL, "Input Device"); + powerFSM.add_transition(&stateDARK, &stateON, EVENT_INPUT, NULL, "Input Device"); + powerFSM.add_transition(&stateON, &stateON, EVENT_INPUT, NULL, "Input Device"); // restarts the sleep timer + powerFSM.add_transition(&stateDARK, &stateON, EVENT_BLUETOOTH_PAIR, NULL, "Bluetooth pairing"); powerFSM.add_transition(&stateON, &stateON, EVENT_BLUETOOTH_PAIR, NULL, "Bluetooth pairing"); diff --git a/src/PowerFSM.h b/src/PowerFSM.h index 2515534b..63506337 100644 --- a/src/PowerFSM.h +++ b/src/PowerFSM.h @@ -20,6 +20,7 @@ #define EVENT_POWER_DISCONNECTED 14 #define EVENT_FIRMWARE_UPDATE 15 // We just received a new firmware update packet from the phone #define EVENT_SHUTDOWN 16 //force a full shutdown now (not just sleep) +#define EVENT_INPUT 17 // input broker wants something, we need to wake up and enable screen extern Fsm powerFSM; extern State statePOWER, stateSERIAL; diff --git a/src/input/InputBroker.cpp b/src/input/InputBroker.cpp index 85e5a087..09e04602 100644 --- a/src/input/InputBroker.cpp +++ b/src/input/InputBroker.cpp @@ -1,4 +1,5 @@ #include "InputBroker.h" +#include "PowerFSM.h" // needed for event trigger InputBroker *inputBroker; @@ -13,6 +14,7 @@ void InputBroker::registerSource(Observable *source) int InputBroker::handleInputEvent(const InputEvent *event) { + powerFSM.trigger(EVENT_INPUT); this->notifyObservers(event); return 0; } \ No newline at end of file diff --git a/src/input/RotaryEncoderInterruptBase.cpp b/src/input/RotaryEncoderInterruptBase.cpp index 6330233b..290e8fb3 100644 --- a/src/input/RotaryEncoderInterruptBase.cpp +++ b/src/input/RotaryEncoderInterruptBase.cpp @@ -54,7 +54,7 @@ int32_t RotaryEncoderInterruptBase::runOnce() } else if (this->action == ROTARY_ACTION_CCW) { - DEBUG_MSG("Rotary event CW\n"); + DEBUG_MSG("Rotary event CCW\n"); e.inputEvent = this->_eventCcw; } @@ -84,7 +84,7 @@ void RotaryEncoderInterruptBase::intAHandler() return; } this->rotaryLevelA = currentLevelA; - intHandler( + this->rotaryStateCCW = intHandler( currentLevelA == HIGH, this->rotaryLevelB, ROTARY_ACTION_CCW, diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 6bb048ac..1db82e90 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -1,5 +1,6 @@ #include "configuration.h" #include "CannedMessageModule.h" +#include "PowerFSM.h" // neede for button bypass #include "MeshService.h" #include "FSCommon.h" #include "mesh/generated/cannedmessages.pb.h" @@ -140,8 +141,13 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) if (event->inputEvent == static_cast(InputEventChar_KEY_SELECT)) { DEBUG_MSG("Canned message event Select\n"); - this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT; - validEvent = true; + // when inactive, call the onebutton shortpress instead. Activate Module only on up/down + if ((this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) { + powerFSM.trigger(EVENT_PRESS); + }else{ + this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT; + validEvent = true; + } } if (validEvent)