mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-04 12:44:40 +00:00
Move BLE toggle menu option and add confirmation for canned messages in L1 (#7516)
* Move bluetooth to system menu and add confirmation for canned messages * Cruft * Handle else * Warn * Fixed screen reset
This commit is contained in:
parent
10bd10b9d1
commit
88655ffc44
@ -14,7 +14,9 @@
|
|||||||
#include "modules/AdminModule.h"
|
#include "modules/AdminModule.h"
|
||||||
#include "modules/CannedMessageModule.h"
|
#include "modules/CannedMessageModule.h"
|
||||||
#include "modules/KeyVerificationModule.h"
|
#include "modules/KeyVerificationModule.h"
|
||||||
|
|
||||||
#include "modules/TraceRouteModule.h"
|
#include "modules/TraceRouteModule.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
extern uint16_t TFT_MESH;
|
extern uint16_t TFT_MESH;
|
||||||
|
|
||||||
@ -118,6 +120,22 @@ void menuHandler::TwelveHourPicker()
|
|||||||
screen->showOverlayBanner(bannerOptions);
|
screen->showOverlayBanner(bannerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reusable confirmation prompt function
|
||||||
|
void menuHandler::showConfirmationBanner(const char *message, std::function<void()> onConfirm)
|
||||||
|
{
|
||||||
|
static const char *confirmOptions[] = {"No", "Yes"};
|
||||||
|
BannerOverlayOptions confirmBanner;
|
||||||
|
confirmBanner.message = message;
|
||||||
|
confirmBanner.optionsArrayPtr = confirmOptions;
|
||||||
|
confirmBanner.optionsCount = 2;
|
||||||
|
confirmBanner.bannerCallback = [onConfirm](int confirmSelected) -> void {
|
||||||
|
if (confirmSelected == 1) {
|
||||||
|
onConfirm();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
screen->showOverlayBanner(confirmBanner);
|
||||||
|
}
|
||||||
|
|
||||||
void menuHandler::ClockFacePicker()
|
void menuHandler::ClockFacePicker()
|
||||||
{
|
{
|
||||||
static const char *optionsArray[] = {"Back", "Digital", "Analog"};
|
static const char *optionsArray[] = {"Back", "Digital", "Analog"};
|
||||||
@ -294,7 +312,7 @@ void menuHandler::messageResponseMenu()
|
|||||||
|
|
||||||
void menuHandler::homeBaseMenu()
|
void menuHandler::homeBaseMenu()
|
||||||
{
|
{
|
||||||
enum optionsNumbers { Back, Backlight, Position, Preset, Freetext, Bluetooth, Sleep, enumEnd };
|
enum optionsNumbers { Back, Backlight, Position, Preset, Freetext, Sleep, enumEnd };
|
||||||
|
|
||||||
static const char *optionsArray[enumEnd] = {"Back"};
|
static const char *optionsArray[enumEnd] = {"Back"};
|
||||||
static int optionsEnumArray[enumEnd] = {Back};
|
static int optionsEnumArray[enumEnd] = {Back};
|
||||||
@ -316,8 +334,6 @@ void menuHandler::homeBaseMenu()
|
|||||||
optionsArray[options] = "New Freetext Msg";
|
optionsArray[options] = "New Freetext Msg";
|
||||||
optionsEnumArray[options++] = Freetext;
|
optionsEnumArray[options++] = Freetext;
|
||||||
}
|
}
|
||||||
optionsArray[options] = "Bluetooth Toggle";
|
|
||||||
optionsEnumArray[options++] = Bluetooth;
|
|
||||||
|
|
||||||
BannerOverlayOptions bannerOptions;
|
BannerOverlayOptions bannerOptions;
|
||||||
bannerOptions.message = "Home Action";
|
bannerOptions.message = "Home Action";
|
||||||
@ -342,9 +358,6 @@ void menuHandler::homeBaseMenu()
|
|||||||
cannedMessageModule->LaunchWithDestination(NODENUM_BROADCAST);
|
cannedMessageModule->LaunchWithDestination(NODENUM_BROADCAST);
|
||||||
} else if (selected == Freetext) {
|
} else if (selected == Freetext) {
|
||||||
cannedMessageModule->LaunchFreetextWithDestination(NODENUM_BROADCAST);
|
cannedMessageModule->LaunchFreetextWithDestination(NODENUM_BROADCAST);
|
||||||
} else if (selected == Bluetooth) {
|
|
||||||
menuQueue = bluetooth_toggle_menu;
|
|
||||||
screen->runNow();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
screen->showOverlayBanner(bannerOptions);
|
screen->showOverlayBanner(bannerOptions);
|
||||||
@ -381,7 +394,7 @@ void menuHandler::textMessageBaseMenu()
|
|||||||
|
|
||||||
void menuHandler::systemBaseMenu()
|
void menuHandler::systemBaseMenu()
|
||||||
{
|
{
|
||||||
enum optionsNumbers { Back, Notifications, ScreenOptions, PowerMenu, Test, enumEnd };
|
enum optionsNumbers { Back, Notifications, ScreenOptions, Bluetooth, PowerMenu, Test, enumEnd };
|
||||||
static const char *optionsArray[enumEnd] = {"Back"};
|
static const char *optionsArray[enumEnd] = {"Back"};
|
||||||
static int optionsEnumArray[enumEnd] = {Back};
|
static int optionsEnumArray[enumEnd] = {Back};
|
||||||
int options = 1;
|
int options = 1;
|
||||||
@ -394,6 +407,9 @@ void menuHandler::systemBaseMenu()
|
|||||||
optionsEnumArray[options++] = ScreenOptions;
|
optionsEnumArray[options++] = ScreenOptions;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
optionsArray[options] = "Bluetooth Toggle";
|
||||||
|
optionsEnumArray[options++] = Bluetooth;
|
||||||
|
|
||||||
optionsArray[options] = "Reboot/Shutdown";
|
optionsArray[options] = "Reboot/Shutdown";
|
||||||
optionsEnumArray[options++] = PowerMenu;
|
optionsEnumArray[options++] = PowerMenu;
|
||||||
|
|
||||||
@ -420,6 +436,9 @@ void menuHandler::systemBaseMenu()
|
|||||||
} else if (selected == Test) {
|
} else if (selected == Test) {
|
||||||
menuHandler::menuQueue = menuHandler::test_menu;
|
menuHandler::menuQueue = menuHandler::test_menu;
|
||||||
screen->runNow();
|
screen->runNow();
|
||||||
|
} else if (selected == Bluetooth) {
|
||||||
|
menuQueue = bluetooth_toggle_menu;
|
||||||
|
screen->runNow();
|
||||||
} else if (selected == Back && !test_enabled) {
|
} else if (selected == Back && !test_enabled) {
|
||||||
test_count++;
|
test_count++;
|
||||||
if (test_count > 4) {
|
if (test_count > 4) {
|
||||||
|
@ -43,6 +43,7 @@ class menuHandler
|
|||||||
|
|
||||||
static void LoraRegionPicker(uint32_t duration = 30000);
|
static void LoraRegionPicker(uint32_t duration = 30000);
|
||||||
static void handleMenuSwitch(OLEDDisplay *display);
|
static void handleMenuSwitch(OLEDDisplay *display);
|
||||||
|
static void showConfirmationBanner(const char *message, std::function<void()> onConfirm);
|
||||||
static void clockMenu();
|
static void clockMenu();
|
||||||
static void TZPicker();
|
static void TZPicker();
|
||||||
static void TwelveHourPicker();
|
static void TwelveHourPicker();
|
||||||
|
@ -595,8 +595,27 @@ bool CannedMessageModule::handleMessageSelectorInput(const InputEvent *event, bo
|
|||||||
// Normal canned message selection
|
// Normal canned message selection
|
||||||
if (runState == CANNED_MESSAGE_RUN_STATE_INACTIVE || runState == CANNED_MESSAGE_RUN_STATE_DISABLED) {
|
if (runState == CANNED_MESSAGE_RUN_STATE_INACTIVE || runState == CANNED_MESSAGE_RUN_STATE_DISABLED) {
|
||||||
} else {
|
} else {
|
||||||
|
// Show confirmation dialog before sending canned message
|
||||||
|
NodeNum destNode = dest;
|
||||||
|
ChannelIndex chan = channel;
|
||||||
|
#if CANNED_MESSAGE_ADD_CONFIRMATION
|
||||||
|
graphics::menuHandler::showConfirmationBanner("Send message?", [this, destNode, chan, current]() {
|
||||||
|
this->sendText(destNode, chan, current, false);
|
||||||
|
payload = runState;
|
||||||
|
runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
||||||
|
currentMessageIndex = -1;
|
||||||
|
|
||||||
|
// Notify UI to regenerate frame set and redraw
|
||||||
|
UIFrameEvent e;
|
||||||
|
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET;
|
||||||
|
notifyObservers(&e);
|
||||||
|
screen->forceDisplay();
|
||||||
|
});
|
||||||
|
#else
|
||||||
payload = runState;
|
payload = runState;
|
||||||
runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT;
|
runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT;
|
||||||
|
#endif
|
||||||
|
// Do not immediately set runState; wait for confirmation
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1711,7 +1730,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
|||||||
// Text: split by words and wrap inside word if needed
|
// Text: split by words and wrap inside word if needed
|
||||||
String text = token.second;
|
String text = token.second;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
while (pos < text.length()) {
|
while (pos < static_cast<int>(text.length())) {
|
||||||
// Find next space (or end)
|
// Find next space (or end)
|
||||||
int spacePos = text.indexOf(' ', pos);
|
int spacePos = text.indexOf(' ', pos);
|
||||||
int endPos = (spacePos == -1) ? text.length() : spacePos + 1; // Include space
|
int endPos = (spacePos == -1) ? text.length() : spacePos + 1; // Include space
|
||||||
|
@ -162,6 +162,8 @@ static const uint8_t SCL = PIN_WIRE_SCL;
|
|||||||
|
|
||||||
#define CANNED_MESSAGE_MODULE_ENABLE 1
|
#define CANNED_MESSAGE_MODULE_ENABLE 1
|
||||||
|
|
||||||
|
#define CANNED_MESSAGE_ADD_CONFIRMATION 1
|
||||||
|
|
||||||
// trackball
|
// trackball
|
||||||
#define HAS_TRACKBALL 1
|
#define HAS_TRACKBALL 1
|
||||||
#define TB_UP 25
|
#define TB_UP 25
|
||||||
|
Loading…
Reference in New Issue
Block a user