Fixup Waypoint screen with BaseUI code

This commit is contained in:
Jason P
2025-10-13 17:07:48 -05:00
parent 214aa8b59d
commit 849a749b81

View File

@@ -2,6 +2,7 @@
#include "NodeDB.h" #include "NodeDB.h"
#include "PowerFSM.h" #include "PowerFSM.h"
#include "configuration.h" #include "configuration.h"
#include "graphics/SharedUIDisplay.h"
#include "graphics/draw/CompassRenderer.h" #include "graphics/draw/CompassRenderer.h"
#if HAS_SCREEN #if HAS_SCREEN
@@ -80,16 +81,20 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
{ {
if (!screen) if (!screen)
return; return;
// Prepare to draw display->clear();
display->setFont(FONT_SMALL);
display->setTextAlignment(TEXT_ALIGN_LEFT); display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(FONT_SMALL);
int line = 1;
// === Set Title
const char *titleStr = "Waypoint";
// === Header ===
graphics::drawCommonHeader(display, x, y, titleStr);
const int w = display->getWidth(); const int w = display->getWidth();
const int h = display->getHeight(); const int h = display->getHeight();
// Handle inverted display
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED)
display->fillRect(x, y, w, FONT_HEIGHT_SMALL);
// Decode the waypoint // Decode the waypoint
const meshtastic_MeshPacket &mp = devicestate.rx_waypoint; const meshtastic_MeshPacket &mp = devicestate.rx_waypoint;
meshtastic_Waypoint wp{}; meshtastic_Waypoint wp{};
@@ -108,10 +113,6 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
// Get our node, to use our own position // Get our node, to use our own position
meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum()); meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());
// Text fields to draw (left of compass)
// Last element must be NULL. This signals the end of the char*[] to drawColumns
const char *fields[] = {"Waypoint", lastStr, wp.name, wp.description, distStr, nullptr};
// Dimensions / co-ordinates for the compass/circle // Dimensions / co-ordinates for the compass/circle
const uint16_t compassDiam = graphics::CompassRenderer::getCompassDiam(w, h); const uint16_t compassDiam = graphics::CompassRenderer::getCompassDiam(w, h);
const int16_t compassX = x + w - (compassDiam / 2) - 5; const int16_t compassX = x + w - (compassDiam / 2) - 5;
@@ -168,11 +169,10 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
// Draw compass circle // Draw compass circle
display->drawCircle(compassX, compassY, compassDiam / 2); display->drawCircle(compassX, compassY, compassDiam / 2);
// Undo color-inversion, if set prior to drawing header display->setTextAlignment(TEXT_ALIGN_LEFT); // Something above me changes to a different alignment, forcing a fix here!
// Unsure of expected behavior? For now: copy drawNodeInfo display->drawString(0, graphics::getTextPositions(display)[line++], lastStr);
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) { display->drawString(0, graphics::getTextPositions(display)[line++], wp.name);
display->setColor(BLACK); display->drawString(0, graphics::getTextPositions(display)[line++], wp.description);
} display->drawString(0, graphics::getTextPositions(display)[line++], distStr);
graphics::NodeListRenderer::drawColumns(display, x, y, fields);
} }
#endif #endif