mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-09 22:52:07 +00:00
Draw columns
This commit is contained in:
parent
633924ced8
commit
0f69f6ca71
@ -689,29 +689,6 @@ bool deltaToTimestamp(uint32_t secondsAgo, uint8_t *hours, uint8_t *minutes, int
|
|||||||
return validCached;
|
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.
|
* Given a recent lat/lon return a guess of the heading the user is walking on.
|
||||||
*
|
*
|
||||||
|
@ -238,8 +238,6 @@ class Screen : public concurrency::OSThread
|
|||||||
// Draw north
|
// Draw north
|
||||||
float estimatedHeading(double lat, double lon);
|
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)
|
/// Handle button press, trackball or swipe action)
|
||||||
void onPress() { enqueueCmd(ScreenCmd{.cmd = Cmd::ON_PRESS}); }
|
void onPress() { enqueueCmd(ScreenCmd{.cmd = Cmd::ON_PRESS}); }
|
||||||
void showPrevFrame() { enqueueCmd(ScreenCmd{.cmd = Cmd::SHOW_PREV_FRAME}); }
|
void showPrevFrame() { enqueueCmd(ScreenCmd{.cmd = Cmd::SHOW_PREV_FRAME}); }
|
||||||
|
@ -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 NodeListRenderer
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
@ -61,6 +61,7 @@ const char *getCurrentModeTitle(int screenWidth);
|
|||||||
void retrieveAndSortNodes(std::vector<NodeEntry> &nodeList);
|
void retrieveAndSortNodes(std::vector<NodeEntry> &nodeList);
|
||||||
String getSafeNodeName(meshtastic_NodeInfoLite *node);
|
String getSafeNodeName(meshtastic_NodeInfoLite *node);
|
||||||
uint32_t sinceLastSeen(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
|
// Bitmap drawing function
|
||||||
void drawScaledXBitmap16x16(int x, int y, int width, int height, const uint8_t *bitmapXBM, OLEDDisplay *display);
|
void drawScaledXBitmap16x16(int x, int y, int width, int height, const uint8_t *bitmapXBM, OLEDDisplay *display);
|
||||||
|
@ -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);
|
void drawGPSpowerstat(OLEDDisplay *display, int16_t x, int16_t y, const meshtastic::GPSStatus *gpsStatus);
|
||||||
|
|
||||||
// Layout and utility functions
|
// 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);
|
void drawScrollbar(OLEDDisplay *display, int visibleItems, int totalItems, int scrollIndex, int x, int startY);
|
||||||
|
|
||||||
// Overlay and special screens
|
// Overlay and special screens
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#if HAS_SCREEN
|
#if HAS_SCREEN
|
||||||
#include "gps/RTC.h"
|
#include "gps/RTC.h"
|
||||||
#include "graphics/Screen.h"
|
#include "graphics/Screen.h"
|
||||||
|
#include "graphics/draw/NodeListRenderer.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -191,6 +192,6 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Must be after distStr is populated
|
// Must be after distStr is populated
|
||||||
screen->drawColumns(display, x, y, fields);
|
graphics::NodeListRenderer::drawColumns(display, x, y, fields);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user