Establish Action Menu on all node list screens, add NodeDB reset (with confirmation) option

This commit is contained in:
Jason P 2025-06-24 13:13:37 -05:00
parent 9f53df4f2e
commit 7af31a88c0
4 changed files with 49 additions and 2 deletions

View File

@ -827,22 +827,27 @@ void Screen::setFrames(FrameFocus focus)
indicatorIcons.push_back(icon_mail); indicatorIcons.push_back(icon_mail);
#ifndef USE_EINK #ifndef USE_EINK
fsi.positions.nodelist = numframes;
normalFrames[numframes++] = graphics::NodeListRenderer::drawDynamicNodeListScreen; normalFrames[numframes++] = graphics::NodeListRenderer::drawDynamicNodeListScreen;
indicatorIcons.push_back(icon_nodes); indicatorIcons.push_back(icon_nodes);
#endif #endif
// Show detailed node views only on E-Ink builds // Show detailed node views only on E-Ink builds
#ifdef USE_EINK #ifdef USE_EINK
fsi.positions.nodelist_lastheard = numframes;
normalFrames[numframes++] = graphics::NodeListRenderer::drawLastHeardScreen; normalFrames[numframes++] = graphics::NodeListRenderer::drawLastHeardScreen;
indicatorIcons.push_back(icon_nodes); indicatorIcons.push_back(icon_nodes);
fsi.positions.nodelist_hopsignal = numframes;
normalFrames[numframes++] = graphics::NodeListRenderer::drawHopSignalScreen; normalFrames[numframes++] = graphics::NodeListRenderer::drawHopSignalScreen;
indicatorIcons.push_back(icon_signal); indicatorIcons.push_back(icon_signal);
fsi.positions.nodelist_distance = numframes;
normalFrames[numframes++] = graphics::NodeListRenderer::drawDistanceScreen; normalFrames[numframes++] = graphics::NodeListRenderer::drawDistanceScreen;
indicatorIcons.push_back(icon_distance); indicatorIcons.push_back(icon_distance);
#endif #endif
#if HAS_GPS #if HAS_GPS
fsi.positions.nodelist_bearings = numframes;
normalFrames[numframes++] = graphics::NodeListRenderer::drawNodeListWithCompasses; normalFrames[numframes++] = graphics::NodeListRenderer::drawNodeListWithCompasses;
indicatorIcons.push_back(icon_list); indicatorIcons.push_back(icon_list);
@ -1272,6 +1277,13 @@ int Screen::handleInputEvent(const InputEvent *event)
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) {
menuHandler::favoriteBaseMenu(); menuHandler::favoriteBaseMenu();
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist ||
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_lastheard ||
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_hopsignal ||
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_distance ||
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_hopsignal ||
this->ui->getUiState()->currentFrame == framesetInfo.positions.nodelist_bearings) {
menuHandler::nodeListMenu();
} }
} else if (event->inputEvent == INPUT_BROKER_BACK) { } else if (event->inputEvent == INPUT_BROKER_BACK) {
showPrevFrame(); showPrevFrame();

View File

@ -609,7 +609,6 @@ class Screen : public concurrency::OSThread
struct FramesetInfo { struct FramesetInfo {
struct FramePositions { struct FramePositions {
uint8_t fault = 255; uint8_t fault = 255;
uint8_t textMessage = 255;
uint8_t waypoint = 255; uint8_t waypoint = 255;
uint8_t focusedModule = 255; uint8_t focusedModule = 255;
uint8_t log = 255; uint8_t log = 255;
@ -619,6 +618,12 @@ class Screen : public concurrency::OSThread
uint8_t memory = 255; uint8_t memory = 255;
uint8_t gps = 255; uint8_t gps = 255;
uint8_t home = 255; uint8_t home = 255;
uint8_t textMessage = 255;
uint8_t nodelist = 255;
uint8_t nodelist_lastheard = 255;
uint8_t nodelist_hopsignal = 255;
uint8_t nodelist_distance = 255;
uint8_t nodelist_bearings = 255;
uint8_t clock = 255; uint8_t clock = 255;
uint8_t firstFavorite = 255; uint8_t firstFavorite = 255;
uint8_t lastFavorite = 255; uint8_t lastFavorite = 255;

View File

@ -10,6 +10,7 @@
#include "graphics/Screen.h" #include "graphics/Screen.h"
#include "graphics/draw/UIRenderer.h" #include "graphics/draw/UIRenderer.h"
#include "main.h" #include "main.h"
#include "modules/AdminModule.h"
#include "modules/CannedMessageModule.h" #include "modules/CannedMessageModule.h"
namespace graphics namespace graphics
@ -310,6 +311,29 @@ void menuHandler::positionBaseMenu()
}); });
} }
void menuHandler::nodeListMenu()
{
static const char *optionsArray[] = {"Back", "Reset NodeDB"};
screen->showOverlayBanner("Node Options", 30000, optionsArray, 2, [](int selected) -> void {
if (selected == 1) {
menuQueue = reset_node_db_menu;
}
});
}
void menuHandler::resetNodeDBMenu()
{
static const char *optionsArray[] = {"Back", "Confirm"};
screen->showOverlayBanner("Confirm Reset NodeDB", 30000, optionsArray, 2, [](int selected) -> void {
if (selected == 1) {
disableBluetooth();
LOG_INFO("Initiate node-db reset");
nodeDB->resetNodes();
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
}
});
}
void menuHandler::compassNorthMenu() void menuHandler::compassNorthMenu()
{ {
static const char *optionsArray[] = {"Back", "Points Up", "Dynamic"}; static const char *optionsArray[] = {"Back", "Points Up", "Dynamic"};
@ -405,6 +429,9 @@ void menuHandler::handleMenuSwitch()
case compass_point_north_menu: case compass_point_north_menu:
compassNorthMenu(); compassNorthMenu();
break; break;
case reset_node_db_menu:
resetNodeDBMenu();
break;
} }
menuQueue = menu_none; menuQueue = menu_none;
} }

View File

@ -14,7 +14,8 @@ class menuHandler
clock_menu, clock_menu,
position_base_menu, position_base_menu,
gps_toggle_menu, gps_toggle_menu,
compass_point_north_menu compass_point_north_menu,
reset_node_db_menu
}; };
static screenMenus menuQueue; static screenMenus menuQueue;
@ -32,6 +33,8 @@ class menuHandler
static void GPSToggleMenu(); static void GPSToggleMenu();
static void BuzzerModeMenu(); static void BuzzerModeMenu();
static void switchToMUIMenu(); static void switchToMUIMenu();
static void nodeListMenu();
static void resetNodeDBMenu();
}; };
} // namespace graphics } // namespace graphics