From 0f69f6ca711d0b2de3fbb424b21c7fa94b39affc Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 31 May 2025 17:32:08 -0500 Subject: [PATCH] Draw columns --- src/graphics/Screen.cpp | 23 ----------------------- src/graphics/Screen.h | 2 -- src/graphics/draw/NodeListRenderer.cpp | 23 +++++++++++++++++++++++ src/graphics/draw/NodeListRenderer.h | 1 + src/graphics/draw/UIRenderer.h | 2 -- src/modules/WaypointModule.cpp | 3 ++- 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 5bdc4da7a..22842adaf 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -689,29 +689,6 @@ bool deltaToTimestamp(uint32_t secondsAgo, uint8_t *hours, uint8_t *minutes, int return validCached; } -/// Draw a series of fields in a column, wrapping to multiple columns if needed -void Screen::drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields) -{ - // The coordinates define the left starting point of the text - display->setTextAlignment(TEXT_ALIGN_LEFT); - - const char **f = fields; - int xo = x, yo = y; - while (*f) { - display->drawString(xo, yo, *f); - if ((display->getColor() == BLACK) && config.display.heading_bold) - display->drawString(xo + 1, yo, *f); - - display->setColor(WHITE); - yo += FONT_HEIGHT_SMALL; - if (yo > SCREEN_HEIGHT - FONT_HEIGHT_SMALL) { - xo += SCREEN_WIDTH / 2; - yo = 0; - } - f++; - } -} - /** * Given a recent lat/lon return a guess of the heading the user is walking on. * diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index 0ab1bae6b..29e5df226 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -238,8 +238,6 @@ class Screen : public concurrency::OSThread // Draw north float estimatedHeading(double lat, double lon); - void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields); - /// Handle button press, trackball or swipe action) void onPress() { enqueueCmd(ScreenCmd{.cmd = Cmd::ON_PRESS}); } void showPrevFrame() { enqueueCmd(ScreenCmd{.cmd = Cmd::SHOW_PREV_FRAME}); } diff --git a/src/graphics/draw/NodeListRenderer.cpp b/src/graphics/draw/NodeListRenderer.cpp index 222369075..7bf742f4f 100644 --- a/src/graphics/draw/NodeListRenderer.cpp +++ b/src/graphics/draw/NodeListRenderer.cpp @@ -850,5 +850,28 @@ void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, in } } +/// Draw a series of fields in a column, wrapping to multiple columns if needed +void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields) +{ + // The coordinates define the left starting point of the text + display->setTextAlignment(TEXT_ALIGN_LEFT); + + const char **f = fields; + int xo = x, yo = y; + while (*f) { + display->drawString(xo, yo, *f); + if ((display->getColor() == BLACK) && config.display.heading_bold) + display->drawString(xo + 1, yo, *f); + + display->setColor(WHITE); + yo += FONT_HEIGHT_SMALL; + if (yo > SCREEN_HEIGHT - FONT_HEIGHT_SMALL) { + xo += SCREEN_WIDTH / 2; + yo = 0; + } + f++; + } +} + } // namespace NodeListRenderer } // namespace graphics diff --git a/src/graphics/draw/NodeListRenderer.h b/src/graphics/draw/NodeListRenderer.h index c583c8ef0..d35350cb8 100644 --- a/src/graphics/draw/NodeListRenderer.h +++ b/src/graphics/draw/NodeListRenderer.h @@ -61,6 +61,7 @@ const char *getCurrentModeTitle(int screenWidth); void retrieveAndSortNodes(std::vector &nodeList); String getSafeNodeName(meshtastic_NodeInfoLite *node); uint32_t sinceLastSeen(meshtastic_NodeInfoLite *node); +void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields); // Bitmap drawing function void drawScaledXBitmap16x16(int x, int y, int width, int height, const uint8_t *bitmapXBM, OLEDDisplay *display); diff --git a/src/graphics/draw/UIRenderer.h b/src/graphics/draw/UIRenderer.h index a83801e56..72262959f 100644 --- a/src/graphics/draw/UIRenderer.h +++ b/src/graphics/draw/UIRenderer.h @@ -43,8 +43,6 @@ void drawGPSAltitude(OLEDDisplay *display, int16_t x, int16_t y, const meshtasti void drawGPSpowerstat(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gpsStatus); // Layout and utility functions -void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields); -void drawColumnSeparator(OLEDDisplay *display, int16_t x, int16_t startY, int16_t endY); void drawScrollbar(OLEDDisplay *display, int visibleItems, int totalItems, int scrollIndex, int x, int startY); // Overlay and special screens diff --git a/src/modules/WaypointModule.cpp b/src/modules/WaypointModule.cpp index 0e0cec9ca..8641990f7 100644 --- a/src/modules/WaypointModule.cpp +++ b/src/modules/WaypointModule.cpp @@ -7,6 +7,7 @@ #if HAS_SCREEN #include "gps/RTC.h" #include "graphics/Screen.h" +#include "graphics/draw/NodeListRenderer.h" #include "main.h" #endif @@ -191,6 +192,6 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, } // Must be after distStr is populated - screen->drawColumns(display, x, y, fields); + graphics::NodeListRenderer::drawColumns(display, x, y, fields); } #endif