mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-23 19:20:41 +00:00
Added Node Config menu with Lora Region Picker
This commit is contained in:
@@ -4,11 +4,15 @@
|
|||||||
|
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
|
|
||||||
|
#include "DisplayFormatters.h"
|
||||||
#include "MeshService.h"
|
#include "MeshService.h"
|
||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
#include "airtime.h"
|
#include "airtime.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "mesh/generated/meshtastic/deviceonly.pb.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
#include <RadioLibInterface.h>
|
||||||
|
#include <target_specific.h>
|
||||||
|
|
||||||
#if !MESHTASTIC_EXCLUDE_GPS
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
@@ -434,6 +438,7 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
|||||||
{
|
{
|
||||||
items.clear();
|
items.clear();
|
||||||
items.shrink_to_fit();
|
items.shrink_to_fit();
|
||||||
|
nodeConfigLabels.clear();
|
||||||
|
|
||||||
switch (page) {
|
switch (page) {
|
||||||
case ROOT:
|
case ROOT:
|
||||||
@@ -444,6 +449,7 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
|||||||
items.push_back(MenuItem("Send", MenuPage::SEND));
|
items.push_back(MenuItem("Send", MenuPage::SEND));
|
||||||
items.push_back(MenuItem("Options", MenuPage::OPTIONS));
|
items.push_back(MenuItem("Options", MenuPage::OPTIONS));
|
||||||
// items.push_back(MenuItem("Display Off", MenuPage::EXIT)); // TODO
|
// 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("Save & Shut Down", MenuAction::SHUTDOWN));
|
||||||
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||||
break;
|
break;
|
||||||
@@ -507,6 +513,40 @@ void InkHUD::MenuApplet::showPage(MenuPage page)
|
|||||||
populateRecentsPage();
|
populateRecentsPage();
|
||||||
break;
|
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:
|
case REGION:
|
||||||
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
items.push_back(MenuItem("Exit", MenuPage::EXIT));
|
||||||
items.push_back(MenuItem("US", MenuAction::SET_REGION_US, MenuPage::EXIT));
|
items.push_back(MenuItem("US", MenuAction::SET_REGION_US, MenuPage::EXIT));
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ class MenuApplet : public SystemApplet, public concurrency::OSThread
|
|||||||
|
|
||||||
uint16_t systemInfoPanelHeight = 0; // Need to know before we render
|
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
|
// Data for selecting and sending canned messages via the menu
|
||||||
// Placed into a sub-class for organization only
|
// Placed into a sub-class for organization only
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ enum MenuPage : uint8_t {
|
|||||||
SEND,
|
SEND,
|
||||||
CANNEDMESSAGE_RECIPIENT, // Select destination for a canned message
|
CANNEDMESSAGE_RECIPIENT, // Select destination for a canned message
|
||||||
OPTIONS,
|
OPTIONS,
|
||||||
|
NODE_CONFIG,
|
||||||
|
NODE_CONFIG_LORA,
|
||||||
APPLETS,
|
APPLETS,
|
||||||
AUTOSHOW,
|
AUTOSHOW,
|
||||||
RECENTS, // Select length of "recentlyActiveSeconds"
|
RECENTS, // Select length of "recentlyActiveSeconds"
|
||||||
REGION,
|
REGION,
|
||||||
EXIT, // Dismiss the menu applet
|
EXIT, // Dismiss the menu applet
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace NicheGraphics::InkHUD
|
} // namespace NicheGraphics::InkHUD
|
||||||
|
|||||||
@@ -100,9 +100,8 @@ void InkHUD::TipsApplet::onRender()
|
|||||||
setFont(fontSmall);
|
setFont(fontSmall);
|
||||||
int16_t cursorY = h + fontSmall.lineHeight();
|
int16_t cursorY = h + fontSmall.lineHeight();
|
||||||
|
|
||||||
const char *body =
|
const char *body = "Before removing power, please shut down from InkHUD menu, or a client app.\n\n"
|
||||||
"Before removing power, please shut down from InkHUD menu, or a client app.\n\n"
|
"This ensures data is saved.";
|
||||||
"This ensures data is saved.";
|
|
||||||
|
|
||||||
uint16_t bodyH = getWrappedTextHeight(0, width(), body);
|
uint16_t bodyH = getWrappedTextHeight(0, width(), body);
|
||||||
printWrapped(0, cursorY, width(), body);
|
printWrapped(0, cursorY, width(), body);
|
||||||
@@ -121,9 +120,8 @@ void InkHUD::TipsApplet::onRender()
|
|||||||
setFont(fontSmall);
|
setFont(fontSmall);
|
||||||
int16_t cursorY = h + fontSmall.lineHeight();
|
int16_t cursorY = h + fontSmall.lineHeight();
|
||||||
|
|
||||||
const char *body =
|
const char *body = "Configure & control display with the InkHUD menu. "
|
||||||
"Configure & control display with the InkHUD menu. "
|
"Optional features, layout, rotation, and more.";
|
||||||
"Optional features, layout, rotation, and more.";
|
|
||||||
|
|
||||||
uint16_t bodyH = getWrappedTextHeight(0, width(), body);
|
uint16_t bodyH = getWrappedTextHeight(0, width(), body);
|
||||||
printWrapped(0, cursorY, width(), body);
|
printWrapped(0, cursorY, width(), body);
|
||||||
@@ -165,9 +163,8 @@ void InkHUD::TipsApplet::onRender()
|
|||||||
setFont(fontSmall);
|
setFont(fontSmall);
|
||||||
int16_t cursorY = h + fontSmall.lineHeight();
|
int16_t cursorY = h + fontSmall.lineHeight();
|
||||||
|
|
||||||
const char *body =
|
const char *body = "To rotate the display, use the InkHUD menu. "
|
||||||
"To rotate the display, use the InkHUD menu. "
|
"Long-press the user button > Options > Rotate.";
|
||||||
"Long-press the user button > Options > Rotate.";
|
|
||||||
|
|
||||||
uint16_t bh = getWrappedTextHeight(0, width(), body);
|
uint16_t bh = getWrappedTextHeight(0, width(), body);
|
||||||
printWrapped(0, cursorY, width(), body);
|
printWrapped(0, cursorY, width(), body);
|
||||||
|
|||||||
@@ -756,12 +756,12 @@ This mapping of emoji to control characters is fairly arbitrary. Selection was i
|
|||||||
| `0x03` | 🙂 |
|
| `0x03` | 🙂 |
|
||||||
| `0x04` | 😆 |
|
| `0x04` | 😆 |
|
||||||
| `0x05` | 👋 |
|
| `0x05` | 👋 |
|
||||||
| `0x06` | ☀ |
|
| `0x06` | ☀ |
|
||||||
| ~~`0x07`~~ | (bell char, unused) |
|
| ~~`0x07`~~ | (bell char, unused) |
|
||||||
| `0x08` | 🌧 |
|
| `0x08` | 🌧 |
|
||||||
| `0x09` | ☁ |
|
| `0x09` | ☁ |
|
||||||
| ~~`0x0A`~~ | (line feed, unused) |
|
| ~~`0x0A`~~ | (line feed, unused) |
|
||||||
| `0x0B` | ♥ |
|
| `0x0B` | ♥ |
|
||||||
| `0x0C` | 💩 |
|
| `0x0C` | 💩 |
|
||||||
| ~~`0x0D`~~ | (carriage return, unused) |
|
| ~~`0x0D`~~ | (carriage return, unused) |
|
||||||
| `0x0E` | 🔔 |
|
| `0x0E` | 🔔 |
|
||||||
|
|||||||
Reference in New Issue
Block a user