mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 22:22:05 +00:00
Finalize drawCommonHeader migration
This commit is contained in:
parent
4b60f8de05
commit
51fc8b3568
@ -399,26 +399,11 @@ void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
|
|
||||||
// === Header ===
|
// === Set Title
|
||||||
graphics::drawCommonHeader(display, x, y);
|
|
||||||
|
|
||||||
// === Draw title (aligned with header baseline) ===
|
|
||||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const char *titleStr = (SCREEN_WIDTH > 128) ? "LoRa Info" : "LoRa";
|
const char *titleStr = (SCREEN_WIDTH > 128) ? "LoRa Info" : "LoRa";
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
// === Header ===
|
||||||
display->setColor(BLACK);
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
}
|
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->drawString(centerX, textY, titleStr);
|
|
||||||
if (config.display.heading_bold) {
|
|
||||||
display->drawString(centerX + 1, textY, titleStr);
|
|
||||||
}
|
|
||||||
display->setColor(WHITE);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
|
|
||||||
// === First Row: Region / BLE Name ===
|
// === First Row: Region / BLE Name ===
|
||||||
graphics::UIRenderer::drawNodes(display, x, compactFirstLine + 3, nodeStatus, 0, true, "");
|
graphics::UIRenderer::drawNodes(display, x, compactFirstLine + 3, nodeStatus, 0, true, "");
|
||||||
@ -527,25 +512,11 @@ void drawMemoryUsage(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x,
|
|||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
// === Header ===
|
// === Set Title
|
||||||
graphics::drawCommonHeader(display, x, y);
|
|
||||||
|
|
||||||
// === Draw title ===
|
|
||||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const char *titleStr = (SCREEN_WIDTH > 128) ? "System" : "Sys";
|
const char *titleStr = (SCREEN_WIDTH > 128) ? "System" : "Sys";
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
// === Header ===
|
||||||
display->setColor(BLACK);
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
}
|
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->drawString(centerX, textY, titleStr);
|
|
||||||
if (config.display.heading_bold) {
|
|
||||||
display->drawString(centerX + 1, textY, titleStr);
|
|
||||||
}
|
|
||||||
display->setColor(WHITE);
|
|
||||||
|
|
||||||
// === Layout ===
|
// === Layout ===
|
||||||
const int yPositions[6] = {moreCompactFirstLine, moreCompactSecondLine, moreCompactThirdLine,
|
const int yPositions[6] = {moreCompactFirstLine, moreCompactSecondLine, moreCompactThirdLine,
|
||||||
|
@ -604,27 +604,12 @@ void drawNodeInfo(OLEDDisplay *display, const OLEDDisplayUiState *state, int16_t
|
|||||||
|
|
||||||
display->clear();
|
display->clear();
|
||||||
|
|
||||||
// Draw battery/time/mail header (common across screens)
|
// === Set Title
|
||||||
graphics::drawCommonHeader(display, x, y);
|
|
||||||
|
|
||||||
// Draw the short node name centered at the top, with bold shadow if set
|
|
||||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
const char *shortName =
|
const char *shortName =
|
||||||
(node->has_user && graphics::UIRenderer::haveGlyphs(node->user.short_name)) ? node->user.short_name : "Node";
|
(node->has_user && graphics::UIRenderer::haveGlyphs(node->user.short_name)) ? node->user.short_name : "Node";
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED)
|
// === Header ===
|
||||||
display->setColor(BLACK);
|
graphics::drawCommonHeader(display, x, y, shortName);
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->setFont(FONT_SMALL);
|
|
||||||
display->drawString(centerX, textY, shortName);
|
|
||||||
if (config.display.heading_bold)
|
|
||||||
display->drawString(centerX + 1, textY, shortName);
|
|
||||||
|
|
||||||
display->setColor(WHITE);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
display->setFont(FONT_SMALL);
|
|
||||||
|
|
||||||
// Dynamic row stacking with predefined Y positions
|
// Dynamic row stacking with predefined Y positions
|
||||||
const int yPositions[5] = {moreCompactFirstLine, moreCompactSecondLine, moreCompactThirdLine, moreCompactFourthLine,
|
const int yPositions[5] = {moreCompactFirstLine, moreCompactSecondLine, moreCompactThirdLine, moreCompactFourthLine,
|
||||||
|
@ -306,25 +306,11 @@ void drawNodeInfo(OLEDDisplay *display, const OLEDDisplayUiState *state, int16_t
|
|||||||
|
|
||||||
display->clear();
|
display->clear();
|
||||||
|
|
||||||
// === Draw battery/time/mail header (common across screens) ===
|
|
||||||
graphics::drawCommonHeader(display, x, y);
|
|
||||||
|
|
||||||
// === Draw the short node name centered at the top, with bold shadow if set ===
|
// === Draw the short node name centered at the top, with bold shadow if set ===
|
||||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
const char *shortName = (node->has_user && haveGlyphs(node->user.short_name)) ? node->user.short_name : "Node";
|
const char *shortName = (node->has_user && haveGlyphs(node->user.short_name)) ? node->user.short_name : "Node";
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED)
|
|
||||||
display->setColor(BLACK);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->setFont(FONT_SMALL);
|
|
||||||
display->drawString(centerX, textY, shortName);
|
|
||||||
if (config.display.heading_bold)
|
|
||||||
display->drawString(centerX + 1, textY, shortName);
|
|
||||||
|
|
||||||
display->setColor(WHITE);
|
// === Draw battery/time/mail header (common across screens) ===
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
graphics::drawCommonHeader(display, x, y, shortName);
|
||||||
display->setFont(FONT_SMALL);
|
|
||||||
|
|
||||||
// ===== DYNAMIC ROW STACKING WITH YOUR MACROS =====
|
// ===== DYNAMIC ROW STACKING WITH YOUR MACROS =====
|
||||||
// 1. Each potential info row has a macro-defined Y position (not regular increments!).
|
// 1. Each potential info row has a macro-defined Y position (not regular increments!).
|
||||||
@ -569,7 +555,7 @@ void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t
|
|||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
|
|
||||||
// === Header ===
|
// === Header ===
|
||||||
graphics::drawCommonHeader(display, x, y);
|
graphics::drawCommonHeader(display, x, y, "");
|
||||||
|
|
||||||
// === Content below header ===
|
// === Content below header ===
|
||||||
|
|
||||||
@ -949,26 +935,11 @@ void drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
|
|
||||||
// === Header ===
|
// === Set Title
|
||||||
graphics::drawCommonHeader(display, x, y);
|
|
||||||
|
|
||||||
// === Draw title ===
|
|
||||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const char *titleStr = "GPS";
|
const char *titleStr = "GPS";
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
// === Header ===
|
||||||
display->setColor(BLACK);
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
}
|
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->drawString(centerX, textY, titleStr);
|
|
||||||
if (config.display.heading_bold) {
|
|
||||||
display->drawString(centerX + 1, textY, titleStr);
|
|
||||||
}
|
|
||||||
display->setColor(WHITE);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
|
|
||||||
// === First Row: My Location ===
|
// === First Row: My Location ===
|
||||||
#if HAS_GPS
|
#if HAS_GPS
|
||||||
|
@ -344,28 +344,11 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt
|
|||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
// Draw shared header bar (battery, time, etc.)
|
// === Set Title
|
||||||
graphics::drawCommonHeader(display, x, y);
|
|
||||||
|
|
||||||
// === Draw Title (Centered under header) ===
|
|
||||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
|
||||||
const int titleY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const char *titleStr = (SCREEN_WIDTH > 128) ? "Environment" : "Env.";
|
const char *titleStr = (SCREEN_WIDTH > 128) ? "Environment" : "Env.";
|
||||||
|
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
// === Header ===
|
||||||
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
// Use black text on white background if in inverted mode
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED)
|
|
||||||
display->setColor(BLACK);
|
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->drawString(centerX, titleY, titleStr); // Centered title
|
|
||||||
if (config.display.heading_bold)
|
|
||||||
display->drawString(centerX + 1, titleY, titleStr); // Bold effect via 1px offset
|
|
||||||
|
|
||||||
// Restore text color & alignment
|
|
||||||
display->setColor(WHITE);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
|
|
||||||
// === Row spacing setup ===
|
// === Row spacing setup ===
|
||||||
const int rowHeight = FONT_HEIGHT_SMALL - 4;
|
const int rowHeight = FONT_HEIGHT_SMALL - 4;
|
||||||
|
@ -113,25 +113,11 @@ void PowerTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *s
|
|||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
|
|
||||||
graphics::drawCommonHeader(display, x, y); // Shared UI header
|
// === Set Title
|
||||||
|
|
||||||
// === Draw title (aligned with header baseline) ===
|
|
||||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
|
||||||
const int textY = y + 1 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
|
||||||
const char *titleStr = (SCREEN_WIDTH > 128) ? "Power Telem." : "Power";
|
const char *titleStr = (SCREEN_WIDTH > 128) ? "Power Telem." : "Power";
|
||||||
const int centerX = x + SCREEN_WIDTH / 2;
|
|
||||||
|
|
||||||
if (config.display.displaymode != meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
// === Header ===
|
||||||
display->setColor(BLACK);
|
graphics::drawCommonHeader(display, x, y, titleStr);
|
||||||
}
|
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->drawString(centerX, textY, titleStr);
|
|
||||||
if (config.display.heading_bold) {
|
|
||||||
display->drawString(centerX + 1, textY, titleStr);
|
|
||||||
}
|
|
||||||
display->setColor(WHITE);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
|
|
||||||
if (lastMeasurementPacket == nullptr) {
|
if (lastMeasurementPacket == nullptr) {
|
||||||
// In case of no valid packet, display "Power Telemetry", "No measurement"
|
// In case of no valid packet, display "Power Telemetry", "No measurement"
|
||||||
|
Loading…
Reference in New Issue
Block a user