From fe5b5ebf15753f2b44774ce80d7f601e86061953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 24 Mar 2022 22:17:06 +0100 Subject: [PATCH 1/6] Adjust rotary defines to new universal names --- src/input/RotaryEncoderInterruptImpl1.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/input/RotaryEncoderInterruptImpl1.cpp b/src/input/RotaryEncoderInterruptImpl1.cpp index 74d318084..dcc26b052 100644 --- a/src/input/RotaryEncoderInterruptImpl1.cpp +++ b/src/input/RotaryEncoderInterruptImpl1.cpp @@ -17,15 +17,15 @@ void RotaryEncoderInterruptImpl1::init() return; } - uint8_t pinA = radioConfig.preferences.rotary1_pin_a; - uint8_t pinB = radioConfig.preferences.rotary1_pin_b; - uint8_t pinPress = radioConfig.preferences.rotary1_pin_press; + uint8_t pinA = radioConfig.preferences.inputbroker_pin_a; + uint8_t pinB = radioConfig.preferences.inputbroker_pin_b; + uint8_t pinPress = radioConfig.preferences.inputbroker_pin_press; char eventCw = - static_cast(radioConfig.preferences.rotary1_event_cw); + static_cast(radioConfig.preferences.inputbroker_event_cw); char eventCcw = - static_cast(radioConfig.preferences.rotary1_event_ccw); + static_cast(radioConfig.preferences.inputbroker_event_ccw); char eventPressed = - static_cast(radioConfig.preferences.rotary1_event_press); + static_cast(radioConfig.preferences.inputbroker_event_press); //radioConfig.preferences.ext_notification_module_output RotaryEncoderInterruptBase::init( From ad2cec2579326042c8e0bf1f5930493deba85429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 25 Mar 2022 11:38:01 +0100 Subject: [PATCH 2/6] Update Protobuf Submodule to Master --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index 1fca6b8e5..b682faf1c 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 1fca6b8e50fcf84a6a34a5605c9e8c5fea96123d +Subproject commit b682faf1c987039ba0b055b1522d4147649cb544 From 3e8ca1f38170dcfd591db067f109b7d0f999e31d Mon Sep 17 00:00:00 2001 From: caveman99 Date: Fri, 25 Mar 2022 10:40:54 +0000 Subject: [PATCH 3/6] [create-pull-request] automated change --- src/mesh/generated/admin.pb.h | 2 +- src/mesh/generated/radioconfig.pb.h | 47 +++++++++++++++-------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/mesh/generated/admin.pb.h b/src/mesh/generated/admin.pb.h index fc9a20d56..6230efbe2 100644 --- a/src/mesh/generated/admin.pb.h +++ b/src/mesh/generated/admin.pb.h @@ -125,7 +125,7 @@ extern const pb_msgdesc_t AdminMessage_msg; #define AdminMessage_fields &AdminMessage_msg /* Maximum encoded size of messages (where known) */ -#define AdminMessage_size 608 +#define AdminMessage_size 611 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index 5a101787e..0efd9cedb 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -171,12 +171,13 @@ typedef struct _RadioConfig_UserPreferences { bool is_lora_tx_disabled; bool is_power_saving; bool rotary1_enabled; - uint32_t rotary1_pin_a; - uint32_t rotary1_pin_b; - uint32_t rotary1_pin_press; - InputEventChar rotary1_event_cw; - InputEventChar rotary1_event_ccw; - InputEventChar rotary1_event_press; + uint32_t inputbroker_pin_a; + uint32_t inputbroker_pin_b; + uint32_t inputbroker_pin_press; + InputEventChar inputbroker_event_cw; + InputEventChar inputbroker_event_ccw; + InputEventChar inputbroker_event_press; + bool updown1_enabled; bool canned_message_module_enabled; char canned_message_module_allow_input_source[16]; bool canned_message_module_send_bell; @@ -227,9 +228,9 @@ extern "C" { /* Initializer values for message structs */ #define RadioConfig_init_default {false, RadioConfig_UserPreferences_init_default} -#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _Role_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_TelemetrySensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", 0, 0, 0, 0} +#define RadioConfig_UserPreferences_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _Role_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_TelemetrySensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, 0, "", 0, 0, 0, 0} #define RadioConfig_init_zero {false, RadioConfig_UserPreferences_init_zero} -#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _Role_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_TelemetrySensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, "", 0, 0, 0, 0} +#define RadioConfig_UserPreferences_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, _RegionCode_MIN, _ChargeCurrent_MIN, 0, _Role_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, _GpsCoordinateFormat_MIN, 0, 0, 0, 0, 0, {0, 0, 0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _RadioConfig_UserPreferences_TelemetrySensorType_MIN, 0, 0, 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0, 0, 0, 0, _InputEventChar_MIN, _InputEventChar_MIN, _InputEventChar_MIN, 0, 0, "", 0, 0, 0, 0} /* Field tags (for use in manual encoding/decoding) */ #define RadioConfig_UserPreferences_position_broadcast_secs_tag 1 @@ -303,12 +304,13 @@ extern "C" { #define RadioConfig_UserPreferences_is_lora_tx_disabled_tag 157 #define RadioConfig_UserPreferences_is_power_saving_tag 158 #define RadioConfig_UserPreferences_rotary1_enabled_tag 160 -#define RadioConfig_UserPreferences_rotary1_pin_a_tag 161 -#define RadioConfig_UserPreferences_rotary1_pin_b_tag 162 -#define RadioConfig_UserPreferences_rotary1_pin_press_tag 163 -#define RadioConfig_UserPreferences_rotary1_event_cw_tag 164 -#define RadioConfig_UserPreferences_rotary1_event_ccw_tag 165 -#define RadioConfig_UserPreferences_rotary1_event_press_tag 166 +#define RadioConfig_UserPreferences_inputbroker_pin_a_tag 161 +#define RadioConfig_UserPreferences_inputbroker_pin_b_tag 162 +#define RadioConfig_UserPreferences_inputbroker_pin_press_tag 163 +#define RadioConfig_UserPreferences_inputbroker_event_cw_tag 164 +#define RadioConfig_UserPreferences_inputbroker_event_ccw_tag 165 +#define RadioConfig_UserPreferences_inputbroker_event_press_tag 166 +#define RadioConfig_UserPreferences_updown1_enabled_tag 167 #define RadioConfig_UserPreferences_canned_message_module_enabled_tag 170 #define RadioConfig_UserPreferences_canned_message_module_allow_input_source_tag 171 #define RadioConfig_UserPreferences_canned_message_module_send_bell_tag 173 @@ -396,12 +398,13 @@ X(a, STATIC, SINGULAR, STRING, mqtt_password, 156) \ X(a, STATIC, SINGULAR, BOOL, is_lora_tx_disabled, 157) \ X(a, STATIC, SINGULAR, BOOL, is_power_saving, 158) \ X(a, STATIC, SINGULAR, BOOL, rotary1_enabled, 160) \ -X(a, STATIC, SINGULAR, UINT32, rotary1_pin_a, 161) \ -X(a, STATIC, SINGULAR, UINT32, rotary1_pin_b, 162) \ -X(a, STATIC, SINGULAR, UINT32, rotary1_pin_press, 163) \ -X(a, STATIC, SINGULAR, UENUM, rotary1_event_cw, 164) \ -X(a, STATIC, SINGULAR, UENUM, rotary1_event_ccw, 165) \ -X(a, STATIC, SINGULAR, UENUM, rotary1_event_press, 166) \ +X(a, STATIC, SINGULAR, UINT32, inputbroker_pin_a, 161) \ +X(a, STATIC, SINGULAR, UINT32, inputbroker_pin_b, 162) \ +X(a, STATIC, SINGULAR, UINT32, inputbroker_pin_press, 163) \ +X(a, STATIC, SINGULAR, UENUM, inputbroker_event_cw, 164) \ +X(a, STATIC, SINGULAR, UENUM, inputbroker_event_ccw, 165) \ +X(a, STATIC, SINGULAR, UENUM, inputbroker_event_press, 166) \ +X(a, STATIC, SINGULAR, BOOL, updown1_enabled, 167) \ X(a, STATIC, SINGULAR, BOOL, canned_message_module_enabled, 170) \ X(a, STATIC, SINGULAR, STRING, canned_message_module_allow_input_source, 171) \ X(a, STATIC, SINGULAR, BOOL, canned_message_module_send_bell, 173) \ @@ -419,8 +422,8 @@ extern const pb_msgdesc_t RadioConfig_UserPreferences_msg; #define RadioConfig_UserPreferences_fields &RadioConfig_UserPreferences_msg /* Maximum encoded size of messages (where known) */ -#define RadioConfig_size 605 -#define RadioConfig_UserPreferences_size 602 +#define RadioConfig_size 608 +#define RadioConfig_UserPreferences_size 605 #ifdef __cplusplus } /* extern "C" */ From e32085070755cbc947b7e4dfd8fb80967cb9349b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 25 Mar 2022 12:27:14 +0100 Subject: [PATCH 4/6] Resolve Conflicts between PIN_BUtton and the Rotary Select and keep screen powered during plugin operation. Forward Port from 1.2 firmware fix. --- src/ButtonThread.h | 6 +++++- src/PowerFSM.cpp | 6 ++++++ src/PowerFSM.h | 1 + src/input/InputBroker.cpp | 2 ++ src/input/RotaryEncoderInterruptBase.cpp | 4 ++-- src/modules/CannedMessageModule.cpp | 10 ++++++++-- 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/ButtonThread.h b/src/ButtonThread.h index 1b86f0924..a1b687095 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 802f8665d..0106cff47 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 2515534b5..63506337d 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 85e5a087f..09e04602d 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 6330233bb..290e8fb3e 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 6bb048acf..1db82e903 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) From 98792f0c05b303c5046d414ab03ed9f7b8dd5ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 25 Mar 2022 12:52:11 +0100 Subject: [PATCH 5/6] fix option name --- src/ButtonThread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ButtonThread.h b/src/ButtonThread.h index a1b687095..cf5885abc 100644 --- a/src/ButtonThread.h +++ b/src/ButtonThread.h @@ -148,7 +148,7 @@ class ButtonThread : public concurrency::OSThread { // DEBUG_MSG("press!\n"); #ifdef BUTTON_PIN - if ((BUTTON_PIN != radioConfig.preferences.rotary1_pin_press) || !radioConfig.preferences.canned_message_module_enabled) { + if ((BUTTON_PIN != radioConfig.preferences.inputbroker_pin_press) || !radioConfig.preferences.canned_message_module_enabled) { powerFSM.trigger(EVENT_PRESS); } #endif From aec626f5e0e3ac16142284bc0fc5b82fd7d8c986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 26 Mar 2022 08:54:37 +0100 Subject: [PATCH 6/6] Update proto to HEAD --- proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto b/proto index b682faf1c..1542d4736 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit b682faf1c987039ba0b055b1522d4147649cb544 +Subproject commit 1542d47362f3980c77ceb43ed6e3796ad7c61c46