mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-05 21:24:34 +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();
|
showNextFrame();
|
||||||
} else if (event->inputEvent == INPUT_BROKER_SELECT) {
|
} else if (event->inputEvent == INPUT_BROKER_SELECT) {
|
||||||
if (this->ui->getUiState()->currentFrame == framesetInfo.positions.home) {
|
if (this->ui->getUiState()->currentFrame == framesetInfo.positions.home) {
|
||||||
static const char **optionsArrayPtr;
|
menuHandler::homeBaseMenu();
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#if HAS_TFT
|
#if HAS_TFT
|
||||||
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.memory) {
|
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.memory) {
|
||||||
static const char *optionsArray[] = {"Yes", "No"};
|
menuHandler::switchToMUIMenu();
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#else
|
#else
|
||||||
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.memory) {
|
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.memory) {
|
||||||
static const char *optionsArray[] = {"All Enabled", "Disabled", "Notifications", "System Only"};
|
menuHandler::BuzzerModeMenu();
|
||||||
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);
|
|
||||||
#endif
|
#endif
|
||||||
#if HAS_GPS
|
#if HAS_GPS
|
||||||
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.gps && gps) {
|
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.gps && gps) {
|
||||||
static const char *optionsArray[] = {"Back", "Enabled", "Disabled"};
|
menuHandler::GPSToggleMenu();
|
||||||
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
|
|
||||||
#endif
|
#endif
|
||||||
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.clock) {
|
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.clock) {
|
||||||
menuHandler::clockMenu();
|
menuHandler::clockMenu();
|
||||||
@ -1322,25 +1271,7 @@ int Screen::handleInputEvent(const InputEvent *event)
|
|||||||
} else if (framesetInfo.positions.firstFavorite != 255 &&
|
} else if (framesetInfo.positions.firstFavorite != 255 &&
|
||||||
this->ui->getUiState()->currentFrame >= framesetInfo.positions.firstFavorite &&
|
this->ui->getUiState()->currentFrame >= framesetInfo.positions.firstFavorite &&
|
||||||
this->ui->getUiState()->currentFrame <= framesetInfo.positions.lastFavorite) {
|
this->ui->getUiState()->currentFrame <= framesetInfo.positions.lastFavorite) {
|
||||||
int options;
|
menuHandler::favoriteBaseMenu();
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else if (event->inputEvent == INPUT_BROKER_BACK) {
|
} else if (event->inputEvent == INPUT_BROKER_BACK) {
|
||||||
showPrevFrame();
|
showPrevFrame();
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#if HAS_SCREEN
|
#if HAS_SCREEN
|
||||||
#include "ClockRenderer.h"
|
#include "ClockRenderer.h"
|
||||||
|
#include "GPS.h"
|
||||||
#include "MenuHandler.h"
|
#include "MenuHandler.h"
|
||||||
#include "MeshRadio.h"
|
#include "MeshRadio.h"
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
|
#include "buzz.h"
|
||||||
#include "graphics/Screen.h"
|
#include "graphics/Screen.h"
|
||||||
|
#include "graphics/draw/UIRenderer.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "modules/CannedMessageModule.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()
|
void menuHandler::handleMenuSwitch()
|
||||||
{
|
{
|
||||||
switch (menuQueue) {
|
switch (menuQueue) {
|
||||||
|
@ -15,6 +15,11 @@ class menuHandler
|
|||||||
static void TwelveHourPicker();
|
static void TwelveHourPicker();
|
||||||
static void ClockFacePicker();
|
static void ClockFacePicker();
|
||||||
static void messageResponseMenu();
|
static void messageResponseMenu();
|
||||||
|
static void homeBaseMenu();
|
||||||
|
static void favoriteBaseMenu();
|
||||||
|
static void GPSToggleMenu();
|
||||||
|
static void BuzzerModeMenu();
|
||||||
|
static void switchToMUIMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
Loading…
Reference in New Issue
Block a user