Added Node Config menu with Lora Region Picker

This commit is contained in:
HarukiToreda
2025-12-14 15:53:44 -05:00
parent 87114f4052
commit d9dab0cd6c
5 changed files with 54 additions and 14 deletions

View File

@@ -4,11 +4,15 @@
#include "RTC.h"
#include "DisplayFormatters.h"
#include "MeshService.h"
#include "Router.h"
#include "airtime.h"
#include "main.h"
#include "mesh/generated/meshtastic/deviceonly.pb.h"
#include "power.h"
#include <RadioLibInterface.h>
#include <target_specific.h>
#if !MESHTASTIC_EXCLUDE_GPS
#include "GPS.h"
@@ -434,6 +438,7 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
{
items.clear();
items.shrink_to_fit();
nodeConfigLabels.clear();
switch (page) {
case ROOT:
@@ -444,6 +449,7 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
items.push_back(MenuItem("Send", MenuPage::SEND));
items.push_back(MenuItem("Options", MenuPage::OPTIONS));
// items.push_back(MenuItem("Display Off", MenuPage::EXIT)); // TODO
items.push_back(MenuItem("Node Config", MenuPage::NODE_CONFIG));
items.push_back(MenuItem("Save & Shut Down", MenuAction::SHUTDOWN));
items.push_back(MenuItem("Exit", MenuPage::EXIT));
break;
@@ -507,6 +513,40 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
populateRecentsPage();
break;
case NODE_CONFIG:
items.push_back(MenuItem("LoRa", MenuPage::NODE_CONFIG_LORA));
items.push_back(MenuItem("Exit", MenuPage::EXIT));
break;
case NODE_CONFIG_LORA: {
// Region
const char *region = myRegion ? myRegion->name : "Unset";
nodeConfigLabels.emplace_back("Region: " + std::string(region));
items.push_back(MenuItem(nodeConfigLabels.back().c_str(), MenuAction::NO_ACTION, MenuPage::REGION));
// Role
const char *role = DisplayFormatters::getDeviceRole(config.device.role);
nodeConfigLabels.emplace_back("Role: " + std::string(role));
items.push_back(MenuItem(nodeConfigLabels.back().c_str(), MenuAction::NO_ACTION, MenuPage::NODE_CONFIG_LORA));
// Preset
const char *preset =
DisplayFormatters::getModemPresetDisplayName(config.lora.modem_preset, false, config.lora.use_preset);
nodeConfigLabels.emplace_back("Preset: " + std::string(preset));
items.push_back(MenuItem(nodeConfigLabels.back().c_str(), MenuAction::NO_ACTION, MenuPage::NODE_CONFIG_LORA));
// Frequency
char freqBuf[32];
float freq = RadioLibInterface::instance->getFreq();
snprintf(freqBuf, sizeof(freqBuf), "Freq: %.3f MHz", freq);
nodeConfigLabels.emplace_back(freqBuf);
items.push_back(MenuItem(nodeConfigLabels.back().c_str(), MenuAction::NO_ACTION, MenuPage::NODE_CONFIG_LORA));
items.push_back(MenuItem("Exit", MenuPage::EXIT));
break;
}
case REGION:
items.push_back(MenuItem("Exit", MenuPage::EXIT));
items.push_back(MenuItem("US", MenuAction::SET_REGION_US, MenuPage::EXIT));

View File

@@ -59,7 +59,8 @@ class MenuApplet : public SystemApplet, public concurrency::OSThread
uint16_t systemInfoPanelHeight = 0; // Need to know before we render
std::vector<MenuItem> items; // MenuItems for the current page. Filled by ShowPage
std::vector<MenuItem> items; // MenuItems for the current page. Filled by ShowPage
std::vector<std::string> nodeConfigLabels; // Persistent labels for Node Config pages
// Data for selecting and sending canned messages via the menu
// Placed into a sub-class for organization only

View File

@@ -20,11 +20,13 @@ enum MenuPage : uint8_t {
SEND,
CANNEDMESSAGE_RECIPIENT, // Select destination for a canned message
OPTIONS,
NODE_CONFIG,
NODE_CONFIG_LORA,
APPLETS,
AUTOSHOW,
RECENTS, // Select length of "recentlyActiveSeconds"
REGION,
EXIT, // Dismiss the menu applet
EXIT, // Dismiss the menu applet
};
} // namespace NicheGraphics::InkHUD

View File

@@ -100,9 +100,8 @@ void InkHUD::TipsApplet::onRender()
setFont(fontSmall);
int16_t cursorY = h + fontSmall.lineHeight();
const char *body =
"Before removing power, please shut down from InkHUD menu, or a client app.\n\n"
"This ensures data is saved.";
const char *body = "Before removing power, please shut down from InkHUD menu, or a client app.\n\n"
"This ensures data is saved.";
uint16_t bodyH = getWrappedTextHeight(0, width(), body);
printWrapped(0, cursorY, width(), body);
@@ -121,9 +120,8 @@ void InkHUD::TipsApplet::onRender()
setFont(fontSmall);
int16_t cursorY = h + fontSmall.lineHeight();
const char *body =
"Configure & control display with the InkHUD menu. "
"Optional features, layout, rotation, and more.";
const char *body = "Configure & control display with the InkHUD menu. "
"Optional features, layout, rotation, and more.";
uint16_t bodyH = getWrappedTextHeight(0, width(), body);
printWrapped(0, cursorY, width(), body);
@@ -165,9 +163,8 @@ void InkHUD::TipsApplet::onRender()
setFont(fontSmall);
int16_t cursorY = h + fontSmall.lineHeight();
const char *body =
"To rotate the display, use the InkHUD menu. "
"Long-press the user button > Options > Rotate.";
const char *body = "To rotate the display, use the InkHUD menu. "
"Long-press the user button > Options > Rotate.";
uint16_t bh = getWrappedTextHeight(0, width(), body);
printWrapped(0, cursorY, width(), body);

View File

@@ -756,12 +756,12 @@ This mapping of emoji to control characters is fairly arbitrary. Selection was i
| `0x03` | 🙂 |
| `0x04` | 😆 |
| `0x05` | 👋 |
| `0x06` | ☀ |
| `0x06` | ☀ |
| ~~`0x07`~~ | (bell char, unused) |
| `0x08` | 🌧 |
| `0x09` | ☁ |
| `0x09` | ☁ |
| ~~`0x0A`~~ | (line feed, unused) |
| `0x0B` | ♥ |
| `0x0B` | ♥ |
| `0x0C` | 💩 |
| ~~`0x0D`~~ | (carriage return, unused) |
| `0x0E` | 🔔 |