Change System frame menu over to better match actions; added color picker for T114

This commit is contained in:
Jason P 2025-06-28 23:29:32 -05:00
parent 8ce7cbd5c0
commit 3598c40aa5
6 changed files with 96 additions and 9 deletions

View File

@ -69,6 +69,8 @@ using graphics::Emote;
using graphics::emotes;
using graphics::numEmotes;
extern uint16_t TFT_MESH;
#if HAS_WIFI && !defined(ARCH_PORTDUINO)
#include "mesh/wifi/WiFiAPClient.h"
#endif
@ -257,7 +259,7 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O
ST7789_MISO, ST7789_SCK);
#else
dispdev = new ST7789Spi(&SPI1, ST7789_RESET, ST7789_RS, ST7789_NSS, GEOMETRY_RAWMODE, TFT_WIDTH, TFT_HEIGHT);
static_cast<ST7789Spi *>(dispdev)->setRGB(COLOR565(255, 255, 128));
static_cast<ST7789Spi *>(dispdev)->setRGB(TFT_MESH);
#endif
#elif defined(USE_SSD1306)
dispdev = new SSD1306Wire(address.address, -1, -1, geometry,
@ -955,6 +957,9 @@ void Screen::setFrames(FrameFocus focus)
// If no module requested focus, will show the first frame instead
ui->switchToFrame(fsi.positions.clock);
break;
case FOCUS_SYSTEM:
ui->switchToFrame(fsi.positions.memory);
break;
case FOCUS_PRESERVE:
// No more adjustment — force stay on same index
@ -1283,13 +1288,8 @@ int Screen::handleInputEvent(const InputEvent *event)
} else if (event->inputEvent == INPUT_BROKER_SELECT) {
if (this->ui->getUiState()->currentFrame == framesetInfo.positions.home) {
menuHandler::homeBaseMenu();
#if HAS_TFT
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.memory) {
menuHandler::switchToMUIMenu();
#else
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.memory) {
menuHandler::BuzzerModeMenu();
#endif
menuHandler::systemBaseMenu();
#if HAS_GPS
} else if (this->ui->getUiState()->currentFrame == framesetInfo.positions.gps && gps) {
menuHandler::positionBaseMenu();

View File

@ -25,6 +25,7 @@ class Screen
FOCUS_TEXTMESSAGE,
FOCUS_MODULE, // Note: target module should call requestFocus(), otherwise no info about which module to focus
FOCUS_CLOCK,
FOCUS_SYSTEM,
};
explicit Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY);
@ -199,6 +200,7 @@ class Screen : public concurrency::OSThread
CallbackObserver<Screen, AdminModule_ObserverData *>(this, &Screen::handleAdminMessage);
public:
OLEDDisplay *getDisplayDevice() { return dispdev; }
explicit Screen(ScanI2C::DeviceAddress, meshtastic_Config_DisplayConfig_OledType, OLEDDISPLAY_GEOMETRY);
size_t frameCount = 0; // Total number of active frames
~Screen();
@ -211,6 +213,7 @@ class Screen : public concurrency::OSThread
FOCUS_TEXTMESSAGE,
FOCUS_MODULE, // Note: target module should call requestFocus(), otherwise no info about which module to focus
FOCUS_CLOCK,
FOCUS_SYSTEM,
};
// Regenerate the normal set of frames, focusing a specific frame if requested

View File

@ -15,7 +15,8 @@ extern SX1509 gpioExtender;
#endif
#ifndef TFT_MESH
#define TFT_MESH COLOR565(0x67, 0xEA, 0x94)
// Legacy Color: 0x67, 0xEA, 0x94
uint16_t TFT_MESH = COLOR565(255, 255, 128);
#endif
#if defined(ST7735S)

View File

@ -19,6 +19,10 @@ class TFTDisplay : public OLEDDisplay
FIXME - the parameters are not used, just a temporary hack to keep working like the old displays
*/
TFTDisplay(uint8_t, int, int, OLEDDISPLAY_GEOMETRY, HW_I2C);
#ifndef TFT_MESH
// Legacy Color: 0x67, 0xEA, 0x94
uint16_t TFT_MESH = COLOR565(255, 255, 128);
#endif
// Write the buffer to the display memory
virtual void display() override { display(false); };

View File

@ -13,6 +13,8 @@
#include "modules/AdminModule.h"
#include "modules/CannedMessageModule.h"
extern uint16_t TFT_MESH;
namespace graphics
{
menuHandler::screenMenus menuHandler::menuQueue = menu_none;
@ -298,6 +300,37 @@ void menuHandler::homeBaseMenu()
});
}
void menuHandler::systemBaseMenu()
{
int options;
static const char **optionsArrayPtr;
#if HAS_TFT
static const char *optionsArray[] = {"Back", "Beeps Action", "Switch to MUI"};
options = 3;
#endif
#ifdef HELTEC_MESH_NODE_T114
static const char *optionsArray[] = {"Back", "Beeps Action", "Screen Color"};
options = 3;
#endif
optionsArrayPtr = optionsArray;
screen->showOverlayBanner("System Action", 30000, optionsArrayPtr, options, [](int selected) -> void {
if (selected == 1) {
menuHandler::menuQueue = menuHandler::buzzermodemenupicker;
screen->setInterval(0);
runASAP = true;
} else if (selected == 2) {
#if HAS_TFT
menuHandler::menuQueue = menuHandler::mui_picker;
#endif
#ifdef HELTEC_MESH_NODE_T114
menuHandler::menuQueue = menuHandler::tftcolormenupicker;
#endif
screen->setInterval(0);
runASAP = true;
}
});
}
void menuHandler::favoriteBaseMenu()
{
int options;
@ -448,6 +481,38 @@ void menuHandler::switchToMUIMenu()
});
}
void menuHandler::TFTColorPickerMenu()
{
static const char *optionsArray[] = {"Back", "Default", "Meshtastic Green", "Red", "Orange", "Purple", "Teal"};
screen->showOverlayBanner("Current Screen Color?", 30000, optionsArray, 7, [](int selected) -> void {
// auto *tft = static_cast<ST7789Spi *>(dispdev);
if (selected == 1) {
LOG_INFO("Setting color to soft yellow");
TFT_MESH = COLOR565(255, 255, 128);
} else if (selected == 2) {
LOG_INFO("Setting color to Meshtastic Green");
TFT_MESH = COLOR565(0x67, 0xEA, 0x94);
} else if (selected == 3) {
LOG_INFO("Setting color to Red");
TFT_MESH = COLOR565(255, 64, 64);
} else if (selected == 4) {
LOG_INFO("Setting color to orange");
TFT_MESH = COLOR565(255, 165, 0);
} else if (selected == 5) {
LOG_INFO("Setting color to purple");
TFT_MESH = COLOR565(192, 128, 192);
} else if (selected == 6) {
LOG_INFO("Setting color to teal");
TFT_MESH = COLOR565(64, 224, 208);
}
if (selected != 0) {
static_cast<ST7789Spi *>(screen->getDisplayDevice())->setRGB(TFT_MESH);
screen->setFrames(graphics::Screen::FOCUS_SYSTEM);
}
});
}
void menuHandler::handleMenuSwitch()
{
switch (menuQueue) {
@ -480,6 +545,15 @@ void menuHandler::handleMenuSwitch()
case reset_node_db_menu:
resetNodeDBMenu();
break;
case buzzermodemenupicker:
BuzzerModeMenu();
break;
case mui_picker:
switchToMUIMenu();
break;
case tftcolormenupicker:
TFTColorPickerMenu();
break;
}
menuQueue = menu_none;
}

View File

@ -15,7 +15,10 @@ class menuHandler
position_base_menu,
gps_toggle_menu,
compass_point_north_menu,
reset_node_db_menu
reset_node_db_menu,
buzzermodemenupicker,
mui_picker,
tftcolormenupicker
};
static screenMenus menuQueue;
@ -27,12 +30,14 @@ class menuHandler
static void ClockFacePicker();
static void messageResponseMenu();
static void homeBaseMenu();
static void systemBaseMenu();
static void favoriteBaseMenu();
static void positionBaseMenu();
static void compassNorthMenu();
static void GPSToggleMenu();
static void BuzzerModeMenu();
static void switchToMUIMenu();
static void TFTColorPickerMenu();
static void nodeListMenu();
static void resetNodeDBMenu();
};