mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-16 08:31:35 +10:00
BaseUI: Select Environmental Data Source (#11209)
* Select Source * Fixes * remove per sensor name --------- Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
This commit is contained in:
co-authored by
Thomas Göttgens
parent
b59cd58d75
commit
74b9f6ff02
@@ -26,6 +26,9 @@
|
||||
#include "modules/CannedMessageModule.h"
|
||||
#include "modules/ExternalNotificationModule.h"
|
||||
#include "modules/KeyVerificationModule.h"
|
||||
#if HAS_TELEMETRY && HAS_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
||||
#include "modules/Telemetry/EnvironmentTelemetry.h"
|
||||
#endif
|
||||
#include "modules/TraceRouteModule.h"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -1471,6 +1474,76 @@ void menuHandler::positionBaseMenu()
|
||||
screen->showOverlayBanner(bannerOptions);
|
||||
}
|
||||
|
||||
void menuHandler::environmentTelemetryMenu()
|
||||
{
|
||||
#if HAS_TELEMETRY && HAS_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
||||
enum optionsNumbers { Back, Source, enumEnd };
|
||||
|
||||
static const char *optionsArray[] = {"Back", "Source"};
|
||||
static int optionsEnumArray[] = {Back, Source};
|
||||
|
||||
BannerOverlayOptions bannerOptions;
|
||||
bannerOptions.message = "Environment";
|
||||
bannerOptions.optionsArrayPtr = optionsArray;
|
||||
bannerOptions.optionsEnumPtr = optionsEnumArray;
|
||||
bannerOptions.optionsCount = enumEnd;
|
||||
bannerOptions.bannerCallback = [](int selected) -> void {
|
||||
if (selected == Source) {
|
||||
menuQueue = EnvironmentTelemetrySourceMenu;
|
||||
screen->runNow();
|
||||
}
|
||||
};
|
||||
screen->showOverlayBanner(bannerOptions);
|
||||
#endif
|
||||
}
|
||||
|
||||
void menuHandler::environmentTelemetrySourceMenu()
|
||||
{
|
||||
#if HAS_TELEMETRY && HAS_SENSOR && !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR
|
||||
enum optionsNumbers { Back, LocalSensor, Mesh, FavoritesOnly, enumEnd };
|
||||
static const char *optionsArray[enumEnd] = {"Back", "Local Sensor", "Mesh", "Favorite Nodes Only"};
|
||||
static int optionsEnumArray[enumEnd] = {Back, LocalSensor, Mesh, FavoritesOnly};
|
||||
|
||||
BannerOverlayOptions bannerOptions;
|
||||
bannerOptions.message = "Source";
|
||||
bannerOptions.optionsArrayPtr = optionsArray;
|
||||
bannerOptions.optionsEnumPtr = optionsEnumArray;
|
||||
bannerOptions.optionsCount = enumEnd;
|
||||
|
||||
switch (EnvironmentTelemetryModule::getDisplaySource()) {
|
||||
case EnvironmentTelemetryModule::DisplaySource::LocalSensor:
|
||||
bannerOptions.InitialSelected = LocalSensor;
|
||||
break;
|
||||
case EnvironmentTelemetryModule::DisplaySource::FavoriteNodesOnly:
|
||||
bannerOptions.InitialSelected = FavoritesOnly;
|
||||
break;
|
||||
case EnvironmentTelemetryModule::DisplaySource::Mesh:
|
||||
default:
|
||||
bannerOptions.InitialSelected = Mesh;
|
||||
break;
|
||||
}
|
||||
|
||||
bannerOptions.bannerCallback = [](int selected) -> void {
|
||||
if (selected == Back) {
|
||||
menuQueue = EnvironmentTelemetryMenu;
|
||||
screen->runNow();
|
||||
return;
|
||||
}
|
||||
|
||||
if (selected == LocalSensor) {
|
||||
EnvironmentTelemetryModule::setDisplaySource(EnvironmentTelemetryModule::DisplaySource::LocalSensor);
|
||||
} else if (selected == Mesh) {
|
||||
EnvironmentTelemetryModule::setDisplaySource(EnvironmentTelemetryModule::DisplaySource::Mesh);
|
||||
} else if (selected == FavoritesOnly) {
|
||||
EnvironmentTelemetryModule::setDisplaySource(EnvironmentTelemetryModule::DisplaySource::FavoriteNodesOnly);
|
||||
}
|
||||
|
||||
screen->runNow();
|
||||
};
|
||||
screen->showOverlayBanner(bannerOptions);
|
||||
#endif
|
||||
}
|
||||
|
||||
void menuHandler::nodeListMenu()
|
||||
{
|
||||
enum optionsNumbers { Back, NodePicker, TraceRoute, Verify, Reset, NodeNameLength, enumEnd };
|
||||
@@ -2890,6 +2963,12 @@ void menuHandler::handleMenuSwitch(OLEDDisplay *display)
|
||||
case NumberTest:
|
||||
numberTest();
|
||||
break;
|
||||
case EnvironmentTelemetryMenu:
|
||||
environmentTelemetryMenu();
|
||||
break;
|
||||
case EnvironmentTelemetrySourceMenu:
|
||||
environmentTelemetrySourceMenu();
|
||||
break;
|
||||
case WifiToggleMenu:
|
||||
wifiToggleMenu();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user