mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 06:02:05 +00:00
Pull OneButton handling from PowerFSM and add MUI switch (#6973)
This commit is contained in:
parent
8fc0f1aa13
commit
b177329813
@ -253,12 +253,6 @@ static void onIdle()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void screenPress()
|
|
||||||
{
|
|
||||||
if (screen)
|
|
||||||
screen->onPress();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void bootEnter()
|
static void bootEnter()
|
||||||
{
|
{
|
||||||
LOG_DEBUG("State: BOOT");
|
LOG_DEBUG("State: BOOT");
|
||||||
@ -302,9 +296,9 @@ void PowerFSM_setup()
|
|||||||
powerFSM.add_transition(&stateLS, &stateON, EVENT_PRESS, NULL, "Press");
|
powerFSM.add_transition(&stateLS, &stateON, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&stateNB, &stateON, EVENT_PRESS, NULL, "Press");
|
powerFSM.add_transition(&stateNB, &stateON, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&stateDARK, isPowered() ? &statePOWER : &stateON, EVENT_PRESS, NULL, "Press");
|
powerFSM.add_transition(&stateDARK, isPowered() ? &statePOWER : &stateON, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&statePOWER, &statePOWER, EVENT_PRESS, screenPress, "Press");
|
powerFSM.add_transition(&statePOWER, &statePOWER, EVENT_PRESS, NULL, "Press");
|
||||||
powerFSM.add_transition(&stateON, &stateON, EVENT_PRESS, screenPress, "Press"); // reenter On to restart our timers
|
powerFSM.add_transition(&stateON, &stateON, EVENT_PRESS, NULL, "Press"); // reenter On to restart our timers
|
||||||
powerFSM.add_transition(&stateSERIAL, &stateSERIAL, EVENT_PRESS, screenPress,
|
powerFSM.add_transition(&stateSERIAL, &stateSERIAL, EVENT_PRESS, NULL,
|
||||||
"Press"); // Allow button to work while in serial API
|
"Press"); // Allow button to work while in serial API
|
||||||
|
|
||||||
// Handle critically low power battery by forcing deep sleep
|
// Handle critically low power battery by forcing deep sleep
|
||||||
|
@ -1824,10 +1824,25 @@ int Screen::handleInputEvent(const InputEvent *event)
|
|||||||
|
|
||||||
// If no modules are using the input, move between frames
|
// If no modules are using the input, move between frames
|
||||||
if (!inputIntercepted) {
|
if (!inputIntercepted) {
|
||||||
if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT))
|
if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) {
|
||||||
showPrevFrame();
|
showPrevFrame();
|
||||||
else if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT))
|
} else if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT)) {
|
||||||
showNextFrame();
|
showNextFrame();
|
||||||
|
} else if (event->inputEvent ==
|
||||||
|
static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT)) {
|
||||||
|
#if HAS_TFT
|
||||||
|
if (this->ui->getUiState()->currentFrame == framesetInfo.positions.memory) {
|
||||||
|
showOverlayBanner("Switch to MUI?\nYES\nNO", 30000, 2, [](int selected) -> void {
|
||||||
|
if (selected == 0) {
|
||||||
|
config.display.displaymode = meshtastic_Config_DisplayConfig_DisplayMode_COLOR;
|
||||||
|
config.bluetooth.enabled = false;
|
||||||
|
service->reloadConfig(SEGMENT_CONFIG);
|
||||||
|
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
|||||||
if (isSelect) {
|
if (isSelect) {
|
||||||
// When inactive, call the onebutton shortpress instead. Activate module only on up/down
|
// When inactive, call the onebutton shortpress instead. Activate module only on up/down
|
||||||
powerFSM.trigger(EVENT_PRESS);
|
powerFSM.trigger(EVENT_PRESS);
|
||||||
return 1; // Let caller know we handled it
|
return 0; // Main button press no longer runs through powerFSM
|
||||||
}
|
}
|
||||||
// Let LEFT/RIGHT pass through so frame navigation works
|
// Let LEFT/RIGHT pass through so frame navigation works
|
||||||
if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT) ||
|
if (event->inputEvent == static_cast<char>(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT) ||
|
||||||
|
@ -7,9 +7,8 @@
|
|||||||
#define SENSOR_PORT_NUM 2
|
#define SENSOR_PORT_NUM 2
|
||||||
#define SENSOR_BAUD_RATE 115200
|
#define SENSOR_BAUD_RATE 115200
|
||||||
|
|
||||||
#if !HAS_TFT
|
|
||||||
#define BUTTON_PIN 38
|
#define BUTTON_PIN 38
|
||||||
#endif
|
|
||||||
// #define BUTTON_NEED_PULLUP
|
// #define BUTTON_NEED_PULLUP
|
||||||
|
|
||||||
// #define BATTERY_PIN 27 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
// #define BATTERY_PIN 27 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
|
||||||
|
Loading…
Reference in New Issue
Block a user