diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 1dfff137a..0986e6eb0 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -9,11 +9,11 @@ plugins: lint: enabled: - checkov@3.2.447 - - renovate@41.19.0 + - renovate@41.23.4 - prettier@3.6.2 - trufflehog@3.89.2 - yamllint@1.37.1 - - bandit@1.8.5 + - bandit@1.8.6 - trivy@0.64.1 - taplo@0.9.3 - ruff@0.12.2 diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 4d9c9e36f..6f19427d8 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -294,13 +294,13 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O LOG_INFO("Protobuf Value uiconfig.screen_rgb_color: %d", uiconfig.screen_rgb_color); int32_t rawRGB = uiconfig.screen_rgb_color; if (rawRGB > 0 && rawRGB <= 255255255) { - uint8_t r = (rawRGB >> 16) & 0xFF; - uint8_t g = (rawRGB >> 8) & 0xFF; - uint8_t b = rawRGB & 0xFF; - LOG_INFO("Values of r,g,b: %d, %d, %d", r, g, b); + uint8_t TFT_MESH_r = (rawRGB >> 16) & 0xFF; + uint8_t TFT_MESH_g = (rawRGB >> 8) & 0xFF; + uint8_t TFT_MESH_b = rawRGB & 0xFF; + LOG_INFO("Values of r,g,b: %d, %d, %d", TFT_MESH_r, TFT_MESH_g, TFT_MESH_b); - if (r <= 255 && g <= 255 && b <= 255) { - TFT_MESH = COLOR565(r, g, b); + if (TFT_MESH_r <= 255 && TFT_MESH_g <= 255 && TFT_MESH_b <= 255) { + TFT_MESH = COLOR565(TFT_MESH_r, TFT_MESH_g, TFT_MESH_b); } } @@ -313,6 +313,8 @@ 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); +#endif +#elif defined(USE_ST7789) static_cast(dispdev)->setRGB(TFT_MESH); #endif #elif defined(USE_ST7796) @@ -322,6 +324,7 @@ Screen::Screen(ScanI2C::DeviceAddress address, meshtastic_Config_DisplayConfig_O #else dispdev = new ST7796Spi(&SPI1, ST7796_RESET, ST7796_RS, ST7796_NSS, GEOMETRY_RAWMODE, TFT_WIDTH, TFT_HEIGHT); #endif + #elif defined(USE_SSD1306) dispdev = new SSD1306Wire(address.address, -1, -1, geometry, (address.port == ScanI2C::I2CPort::WIRE1) ? HW_I2C::I2C_TWO : HW_I2C::I2C_ONE); @@ -981,22 +984,6 @@ void Screen::setFrames(FrameFocus focus) indicatorIcons.push_back(digital_icon_clock); #endif - // We don't show the node info of our node (if we have it yet - we should) - size_t numMeshNodes = nodeDB->getNumMeshNodes(); - if (numMeshNodes > 0) - numMeshNodes--; - - for (size_t i = 0; i < nodeDB->getNumMeshNodes(); i++) { - const meshtastic_NodeInfoLite *n = nodeDB->getMeshNodeByIndex(i); - if (n && n->num != nodeDB->getNodeNum() && n->is_favorite) { - if (fsi.positions.firstFavorite == 255) - fsi.positions.firstFavorite = numframes; - fsi.positions.lastFavorite = numframes; - normalFrames[numframes++] = graphics::UIRenderer::drawNodeInfo; - indicatorIcons.push_back(icon_node); - } - } - #if HAS_WIFI && !defined(ARCH_PORTDUINO) if (!dismissedFrames.wifi && isWifiAvailable()) { fsi.positions.wifi = numframes; @@ -1006,7 +993,7 @@ void Screen::setFrames(FrameFocus focus) #endif // Beware of what changes you make in this code! - // We pass numfames into GetMeshModulesWithUIFrames() which is highly important! + // We pass numframes into GetMeshModulesWithUIFrames() which is highly important! // Inside of that callback, goes over to MeshModule.cpp and we run // modulesWithUIFrames.resize(startIndex, nullptr), to insert nullptr // entries until we're ready to start building the matching entries. @@ -1035,6 +1022,34 @@ void Screen::setFrames(FrameFocus focus) LOG_DEBUG("Added modules. numframes: %d", numframes); + // We don't show the node info of our node (if we have it yet - we should) + size_t numMeshNodes = nodeDB->getNumMeshNodes(); + if (numMeshNodes > 0) + numMeshNodes--; + + // Temporary array to hold favorite node frames + std::vector favoriteFrames; + + for (size_t i = 0; i < nodeDB->getNumMeshNodes(); i++) { + const meshtastic_NodeInfoLite *n = nodeDB->getMeshNodeByIndex(i); + if (n && n->num != nodeDB->getNodeNum() && n->is_favorite) { + favoriteFrames.push_back(graphics::UIRenderer::drawNodeInfo); + } + } + + // Insert favorite frames *after* collecting them all + if (!favoriteFrames.empty()) { + fsi.positions.firstFavorite = numframes; + for (auto &f : favoriteFrames) { + normalFrames[numframes++] = f; + indicatorIcons.push_back(icon_node); + } + fsi.positions.lastFavorite = numframes - 1; + } else { + fsi.positions.firstFavorite = 255; + fsi.positions.lastFavorite = 255; + } + fsi.frameCount = numframes; // Total framecount is used to apply FOCUS_PRESERVE this->frameCount = numframes; // ✅ Save frame count for use in custom overlay LOG_DEBUG("Finished build frames. numframes: %d", numframes); @@ -1046,8 +1061,7 @@ void Screen::setFrames(FrameFocus focus) static OverlayCallback overlays[] = {graphics::UIRenderer::drawNavigationBar, NotificationRenderer::drawBannercallback}; ui->setOverlays(overlays, sizeof(overlays) / sizeof(overlays[0])); - prevFrame = -1; // Force drawNodeInfo to pick a new node (because our list - // just changed) + prevFrame = -1; // Force drawNodeInfo to pick a new node (because our list just changed) // Focus on a specific frame, in the frame set we just created switch (focus) { diff --git a/src/graphics/draw/MenuHandler.cpp b/src/graphics/draw/MenuHandler.cpp index 43c226896..a66ccd983 100644 --- a/src/graphics/draw/MenuHandler.cpp +++ b/src/graphics/draw/MenuHandler.cpp @@ -358,6 +358,9 @@ void menuHandler::systemBaseMenu() static int optionsEnumArray[7] = {Back}; int options = 1; + optionsArray[options] = "Reboot"; + optionsEnumArray[options++] = Reboot; + optionsArray[options] = "Beeps Action"; optionsEnumArray[options++] = Beeps; @@ -366,9 +369,6 @@ void menuHandler::systemBaseMenu() optionsEnumArray[options++] = Brightness; } - optionsArray[options] = "Reboot"; - optionsEnumArray[options++] = Reboot; - #if defined(HELTEC_MESH_NODE_T114) || defined(HELTEC_VISION_MASTER_T190) || HAS_TFT optionsArray[options] = "Screen Color"; optionsEnumArray[options++] = Color; @@ -677,52 +677,52 @@ void menuHandler::TFTColorPickerMenu(OLEDDisplay *display) bannerOptions.optionsArrayPtr = optionsArray; bannerOptions.optionsCount = 10; bannerOptions.bannerCallback = [display](int selected) -> void { - uint8_t r = 0; - uint8_t g = 0; - uint8_t b = 0; + uint8_t TFT_MESH_r = 0; + uint8_t TFT_MESH_g = 0; + uint8_t TFT_MESH_b = 0; if (selected == 1) { LOG_INFO("Setting color to system default or defined variant"); // Given just before we set all these to zero, we will allow this to go through } else if (selected == 2) { LOG_INFO("Setting color to Meshtastic Green"); - r = 103; - g = 234; - b = 148; + TFT_MESH_r = 103; + TFT_MESH_g = 234; + TFT_MESH_b = 148; } else if (selected == 3) { LOG_INFO("Setting color to Yellow"); - r = 255; - g = 255; - b = 128; + TFT_MESH_r = 255; + TFT_MESH_g = 255; + TFT_MESH_b = 128; } else if (selected == 4) { LOG_INFO("Setting color to Red"); - r = 255; - g = 64; - b = 64; + TFT_MESH_r = 255; + TFT_MESH_g = 64; + TFT_MESH_b = 64; } else if (selected == 5) { LOG_INFO("Setting color to Orange"); - r = 255; - g = 160; - b = 20; + TFT_MESH_r = 255; + TFT_MESH_g = 160; + TFT_MESH_b = 20; } else if (selected == 6) { LOG_INFO("Setting color to Purple"); - r = 204; - g = 153; - b = 255; + TFT_MESH_r = 204; + TFT_MESH_g = 153; + TFT_MESH_b = 255; } else if (selected == 7) { LOG_INFO("Setting color to Teal"); - r = 64; - g = 224; - b = 208; + TFT_MESH_r = 64; + TFT_MESH_g = 224; + TFT_MESH_b = 208; } else if (selected == 8) { LOG_INFO("Setting color to Pink"); - r = 255; - g = 105; - b = 180; + TFT_MESH_r = 255; + TFT_MESH_g = 105; + TFT_MESH_b = 180; } else if (selected == 9) { LOG_INFO("Setting color to White"); - r = 255; - g = 255; - b = 255; + TFT_MESH_r = 255; + TFT_MESH_g = 255; + TFT_MESH_b = 255; } #if defined(HELTEC_MESH_NODE_T114) || defined(HELTEC_VISION_MASTER_T190) || HAS_TFT @@ -731,14 +731,14 @@ void menuHandler::TFTColorPickerMenu(OLEDDisplay *display) display->fillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); display->setColor(WHITE); - if (r == 0 && g == 0 && b == 0) { + if (TFT_MESH_r == 0 && TFT_MESH_g == 0 && TFT_MESH_b == 0) { #ifdef TFT_MESH_OVERRIDE TFT_MESH = TFT_MESH_OVERRIDE; #else TFT_MESH = COLOR565(0x67, 0xEA, 0x94); #endif } else { - TFT_MESH = COLOR565(r, g, b); + TFT_MESH = COLOR565(TFT_MESH_r, TFT_MESH_g, TFT_MESH_b); } #if defined(HELTEC_MESH_NODE_T114) || defined(HELTEC_VISION_MASTER_T190) @@ -746,10 +746,10 @@ void menuHandler::TFTColorPickerMenu(OLEDDisplay *display) #endif screen->setFrames(graphics::Screen::FOCUS_SYSTEM); - if (r == 0 && g == 0 && b == 0) { + if (TFT_MESH_r == 0 && TFT_MESH_g == 0 && TFT_MESH_b == 0) { uiconfig.screen_rgb_color = 0; } else { - uiconfig.screen_rgb_color = (r << 16) | (g << 8) | b; + uiconfig.screen_rgb_color = (TFT_MESH_r << 16) | (TFT_MESH_g << 8) | TFT_MESH_b; } LOG_INFO("Storing Value of %d to uiconfig.screen_rgb_color", uiconfig.screen_rgb_color); nodeDB->saveProto("/prefs/uiconfig.proto", meshtastic_DeviceUIConfig_size, &meshtastic_DeviceUIConfig_msg, &uiconfig);