mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-03 12:20:43 +00:00
Migrate the rest of the menus to MenuHandler.*
This commit is contained in:
parent
a33672db4f
commit
07cd16d2df
@ -1249,68 +1249,17 @@ int Screen::handleInputEvent(const InputEvent *event)
|
||||
showNextFrame();
|
||||
} else if (event->inputEvent == INPUT_BROKER_SELECT) {
|
||||
if (this->ui->getUiState()->currentFrame == framesetInfo.positions.home) {
|
||||
static const char **optionsArrayPtr;
|
||||
int options;
|
||||
static const char *optionsArray_kb[] = {"Back", "Sleep Screen", "New Preset Msg", "New Freetext Msg"};
|
||||
static const char *optionsArray_nokb[] = {"Back", "Sleep Screen", "New Preset Msg"};
|
||||
if (kb_found) {
|
||||
optionsArrayPtr = optionsArray_kb;
|
||||
options = 4;
|
||||
} else {
|
||||
optionsArrayPtr = optionsArray_nokb;
|
||||
options = 3;
|
||||
}
|
||||
showOverlayBanner("Action?", 30000, optionsArrayPtr, options, [](int selected) -> void {
|
||||
if (selected == 1) {
|
||||
screen->setOn(false);
|
||||
} else if (selected == 2) {
|
||||
cannedMessageModule->LaunchWithDestination(NODENUM_BROADCAST);
|
||||
} else if (selected == 3) {
|
||||
cannedMessageModule->LaunchFreetextWithDestination(NODENUM_BROADCAST);
|
||||
}
|
||||
});
|
||||
menuHandler::homeBaseMenu();
|
||||
#if HAS_TFT
|
||||
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.memory) {
|
||||
static const char *optionsArray[] = {"Yes", "No"};
|
||||
showOverlayBanner("Switch to MUI?", 30000, optionsArray, 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);
|
||||
}
|
||||
});
|
||||
menuHandler::switchToMUIMenu();
|
||||
#else
|
||||
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.memory) {
|
||||
static const char *optionsArray[] = {"All Enabled", "Disabled", "Notifications", "System Only"};
|
||||
showOverlayBanner(
|
||||
"Beeps Mode", 30000, optionsArray, 4,
|
||||
[](int selected) -> void {
|
||||
config.device.buzzer_mode = (meshtastic_Config_DeviceConfig_BuzzerMode)selected;
|
||||
service->reloadConfig(SEGMENT_CONFIG);
|
||||
},
|
||||
config.device.buzzer_mode);
|
||||
menuHandler::BuzzerModeMenu();
|
||||
#endif
|
||||
#if HAS_GPS
|
||||
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.gps && gps) {
|
||||
static const char *optionsArray[] = {"Back", "Enabled", "Disabled"};
|
||||
showOverlayBanner(
|
||||
"Toggle GPS", 30000, optionsArray, 3,
|
||||
[](int selected) -> void {
|
||||
if (selected == 1) {
|
||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
||||
playGPSEnableBeep();
|
||||
gps->enable();
|
||||
service->reloadConfig(SEGMENT_CONFIG);
|
||||
} else if (selected == 2) {
|
||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_DISABLED;
|
||||
playGPSDisableBeep();
|
||||
gps->disable();
|
||||
service->reloadConfig(SEGMENT_CONFIG);
|
||||
}
|
||||
},
|
||||
config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED ? 1
|
||||
: 2); // set inital selection
|
||||
menuHandler::GPSToggleMenu();
|
||||
#endif
|
||||
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.clock) {
|
||||
menuHandler::clockMenu();
|
||||
@ -1322,25 +1271,7 @@ int Screen::handleInputEvent(const InputEvent *event)
|
||||
} else if (framesetInfo.positions.firstFavorite != 255 &&
|
||||
this->ui->getUiState()->currentFrame >= framesetInfo.positions.firstFavorite &&
|
||||
this->ui->getUiState()->currentFrame <= framesetInfo.positions.lastFavorite) {
|
||||
int options;
|
||||
static const char **optionsArrayPtr;
|
||||
|
||||
if (kb_found) {
|
||||
static const char *optionsArray[] = {"Back", "New Preset Msg", "New Freetext Msg"};
|
||||
optionsArrayPtr = optionsArray;
|
||||
options = 3;
|
||||
} else {
|
||||
static const char *optionsArray[] = {"Back", "New Preset Msg"};
|
||||
optionsArrayPtr = optionsArray;
|
||||
options = 2;
|
||||
}
|
||||
showOverlayBanner("Message Node?", 30000, optionsArrayPtr, options, [](int selected) -> void {
|
||||
if (selected == 1) {
|
||||
cannedMessageModule->LaunchWithDestination(graphics::UIRenderer::currentFavoriteNodeNum);
|
||||
} else if (selected == 2) {
|
||||
cannedMessageModule->LaunchFreetextWithDestination(graphics::UIRenderer::currentFavoriteNodeNum);
|
||||
}
|
||||
});
|
||||
menuHandler::favoriteBaseMenu();
|
||||
}
|
||||
} else if (event->inputEvent == INPUT_BROKER_BACK) {
|
||||
showPrevFrame();
|
||||
|
@ -1,11 +1,14 @@
|
||||
#include "configuration.h"
|
||||
#if HAS_SCREEN
|
||||
#include "ClockRenderer.h"
|
||||
#include "GPS.h"
|
||||
#include "MenuHandler.h"
|
||||
#include "MeshRadio.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "buzz.h"
|
||||
#include "graphics/Screen.h"
|
||||
#include "graphics/draw/UIRenderer.h"
|
||||
#include "main.h"
|
||||
#include "modules/CannedMessageModule.h"
|
||||
|
||||
@ -237,6 +240,99 @@ void menuHandler::messageResponseMenu()
|
||||
});
|
||||
}
|
||||
|
||||
void menuHandler::homeBaseMenu()
|
||||
{
|
||||
static const char **optionsArrayPtr;
|
||||
int options;
|
||||
static const char *optionsArray_kb[] = {"Back", "Sleep Screen", "New Preset Msg", "New Freetext Msg"};
|
||||
static const char *optionsArray_nokb[] = {"Back", "Sleep Screen", "New Preset Msg"};
|
||||
if (kb_found) {
|
||||
optionsArrayPtr = optionsArray_kb;
|
||||
options = 4;
|
||||
} else {
|
||||
optionsArrayPtr = optionsArray_nokb;
|
||||
options = 3;
|
||||
}
|
||||
screen->showOverlayBanner("Action?", 30000, optionsArrayPtr, options, [](int selected) -> void {
|
||||
if (selected == 1) {
|
||||
screen->setOn(false);
|
||||
} else if (selected == 2) {
|
||||
cannedMessageModule->LaunchWithDestination(NODENUM_BROADCAST);
|
||||
} else if (selected == 3) {
|
||||
cannedMessageModule->LaunchFreetextWithDestination(NODENUM_BROADCAST);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void menuHandler::favoriteBaseMenu()
|
||||
{
|
||||
int options;
|
||||
static const char **optionsArrayPtr;
|
||||
|
||||
if (kb_found) {
|
||||
static const char *optionsArray[] = {"Back", "New Preset Msg", "New Freetext Msg"};
|
||||
optionsArrayPtr = optionsArray;
|
||||
options = 3;
|
||||
} else {
|
||||
static const char *optionsArray[] = {"Back", "New Preset Msg"};
|
||||
optionsArrayPtr = optionsArray;
|
||||
options = 2;
|
||||
}
|
||||
screen->showOverlayBanner("Message Node?", 30000, optionsArrayPtr, options, [](int selected) -> void {
|
||||
if (selected == 1) {
|
||||
cannedMessageModule->LaunchWithDestination(graphics::UIRenderer::currentFavoriteNodeNum);
|
||||
} else if (selected == 2) {
|
||||
cannedMessageModule->LaunchFreetextWithDestination(graphics::UIRenderer::currentFavoriteNodeNum);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void menuHandler::GPSToggleMenu()
|
||||
{
|
||||
static const char *optionsArray[] = {"Back", "Enabled", "Disabled"};
|
||||
screen->showOverlayBanner(
|
||||
"Toggle GPS", 30000, optionsArray, 3,
|
||||
[](int selected) -> void {
|
||||
if (selected == 1) {
|
||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_ENABLED;
|
||||
playGPSEnableBeep();
|
||||
gps->enable();
|
||||
service->reloadConfig(SEGMENT_CONFIG);
|
||||
} else if (selected == 2) {
|
||||
config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_DISABLED;
|
||||
playGPSDisableBeep();
|
||||
gps->disable();
|
||||
service->reloadConfig(SEGMENT_CONFIG);
|
||||
}
|
||||
},
|
||||
config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_ENABLED ? 1 : 2); // set inital selection
|
||||
}
|
||||
|
||||
void menuHandler::BuzzerModeMenu()
|
||||
{
|
||||
static const char *optionsArray[] = {"All Enabled", "Disabled", "Notifications", "System Only"};
|
||||
screen->showOverlayBanner(
|
||||
"Beeps Mode", 30000, optionsArray, 4,
|
||||
[](int selected) -> void {
|
||||
config.device.buzzer_mode = (meshtastic_Config_DeviceConfig_BuzzerMode)selected;
|
||||
service->reloadConfig(SEGMENT_CONFIG);
|
||||
},
|
||||
config.device.buzzer_mode);
|
||||
}
|
||||
|
||||
void menuHandler::switchToMUIMenu()
|
||||
{
|
||||
static const char *optionsArray[] = {"Yes", "No"};
|
||||
screen->showOverlayBanner("Switch to MUI?", 30000, optionsArray, 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void menuHandler::handleMenuSwitch()
|
||||
{
|
||||
switch (menuQueue) {
|
||||
|
@ -15,6 +15,11 @@ class menuHandler
|
||||
static void TwelveHourPicker();
|
||||
static void ClockFacePicker();
|
||||
static void messageResponseMenu();
|
||||
static void homeBaseMenu();
|
||||
static void favoriteBaseMenu();
|
||||
static void GPSToggleMenu();
|
||||
static void BuzzerModeMenu();
|
||||
static void switchToMUIMenu();
|
||||
};
|
||||
|
||||
} // namespace graphics
|
Loading…
Reference in New Issue
Block a user