From d9dab0cd6cbdd79318ab38a974e3d1dbb0ebb708 Mon Sep 17 00:00:00 2001 From: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> Date: Sun, 14 Dec 2025 15:53:44 -0500 Subject: [PATCH] Added Node Config menu with Lora Region Picker --- .../InkHUD/Applets/System/Menu/MenuApplet.cpp | 40 +++++++++++++++++++ .../InkHUD/Applets/System/Menu/MenuApplet.h | 3 +- .../InkHUD/Applets/System/Menu/MenuPage.h | 4 +- .../InkHUD/Applets/System/Tips/TipsApplet.cpp | 15 +++---- src/graphics/niche/InkHUD/docs/README.md | 6 +-- 5 files changed, 54 insertions(+), 14 deletions(-) diff --git a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp index 23c1f98ae..4560d462f 100644 --- a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp +++ b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp @@ -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 +#include #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)); diff --git a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.h b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.h index 031ebf931..2436f582f 100644 --- a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.h +++ b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.h @@ -59,7 +59,8 @@ class MenuApplet : public SystemApplet, public concurrency::OSThread uint16_t systemInfoPanelHeight = 0; // Need to know before we render - std::vector items; // MenuItems for the current page. Filled by ShowPage + std::vector items; // MenuItems for the current page. Filled by ShowPage + std::vector 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 diff --git a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuPage.h b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuPage.h index a01316db4..14924eb50 100644 --- a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuPage.h +++ b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuPage.h @@ -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 diff --git a/src/graphics/niche/InkHUD/Applets/System/Tips/TipsApplet.cpp b/src/graphics/niche/InkHUD/Applets/System/Tips/TipsApplet.cpp index 868a0e6f9..a159bd517 100644 --- a/src/graphics/niche/InkHUD/Applets/System/Tips/TipsApplet.cpp +++ b/src/graphics/niche/InkHUD/Applets/System/Tips/TipsApplet.cpp @@ -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); diff --git a/src/graphics/niche/InkHUD/docs/README.md b/src/graphics/niche/InkHUD/docs/README.md index e7821299e..eccea8a8d 100644 --- a/src/graphics/niche/InkHUD/docs/README.md +++ b/src/graphics/niche/InkHUD/docs/README.md @@ -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` | 🔔 |