mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-08 14:12:05 +00:00
Rows adjustment
This commit is contained in:
parent
c693cd59a9
commit
2f8a1dba8f
@ -120,11 +120,11 @@ static bool heartbeat = false;
|
||||
#define SCREEN_HEIGHT display->getHeight()
|
||||
|
||||
// Pre-defined lines; this is intended to be used AFTER the common header
|
||||
#define compactFirstLine (FONT_HEIGHT_SMALL - 3) * 1
|
||||
#define compactSecondLine (FONT_HEIGHT_SMALL - 3) * 2
|
||||
#define compactThirdLine (FONT_HEIGHT_SMALL - 3) * 3
|
||||
#define compactFourthLine (FONT_HEIGHT_SMALL - 3) * 4
|
||||
#define compactFifthLine (FONT_HEIGHT_SMALL - 3) * 5
|
||||
#define compactFirstLine ((FONT_HEIGHT_SMALL - 1) * 1)
|
||||
#define compactSecondLine ((FONT_HEIGHT_SMALL - 1) * 2) - 2
|
||||
#define compactThirdLine ((FONT_HEIGHT_SMALL - 1) * 3) - 4
|
||||
#define compactFourthLine ((FONT_HEIGHT_SMALL - 1) * 4) - 6
|
||||
#define compactFifthLine ((FONT_HEIGHT_SMALL - 1) * 5) - 8
|
||||
|
||||
#define standardFirstLine (FONT_HEIGHT_SMALL + 1) * 1
|
||||
#define standardSecondLine (FONT_HEIGHT_SMALL + 1) * 2
|
||||
@ -1181,9 +1181,9 @@ static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus
|
||||
if (!gps->getHasLock()) {
|
||||
// Draw "No sats" to the right of the icon with slightly more gap
|
||||
int textX = x + 9; // 6 (icon) + 3px spacing
|
||||
display->drawString(textX, y - 2, "No sats");
|
||||
display->drawString(textX, y - 3, "No sats");
|
||||
if (config.display.heading_bold)
|
||||
display->drawString(textX + 1, y - 2, "No sats");
|
||||
display->drawString(textX + 1, y - 3, "No sats");
|
||||
return;
|
||||
} else {
|
||||
char satsString[3];
|
||||
@ -2103,14 +2103,16 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
||||
|
||||
// === Battery icon (scale-aware vertical centering) ===
|
||||
int batteryScale = 1;
|
||||
if (screenWidth >= 200) batteryScale = 2;
|
||||
if (screenWidth >= 200)
|
||||
batteryScale = 2;
|
||||
|
||||
int batteryHeight = 8 * batteryScale;
|
||||
int batteryY = y + (highlightHeight / 2) - (batteryHeight / 2);
|
||||
|
||||
// Only shift right 3px if screen is wider than 128
|
||||
int batteryX = x + xOffset - 2;
|
||||
if (screenWidth > 128) batteryX += 2;
|
||||
if (screenWidth > 128)
|
||||
batteryX += 2;
|
||||
|
||||
drawBattery(display, batteryX, batteryY, imgBattery, powerStatus);
|
||||
|
||||
@ -2133,7 +2135,8 @@ void drawCommonHeader(OLEDDisplay *display, int16_t x, int16_t y)
|
||||
|
||||
bool isPM = hour >= 12;
|
||||
hour = hour % 12;
|
||||
if (hour == 0) hour = 12;
|
||||
if (hour == 0)
|
||||
hour = 12;
|
||||
|
||||
char timeStr[10];
|
||||
snprintf(timeStr, sizeof(timeStr), "%d:%02d%s", hour, minute, isPM ? "PM" : "AM");
|
||||
@ -2160,31 +2163,30 @@ static void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
||||
drawCommonHeader(display, x, y);
|
||||
|
||||
// === Content below header ===
|
||||
const int layoutYOffset = 1;
|
||||
|
||||
// === First Row: Node and GPS ===
|
||||
bool origBold = config.display.heading_bold;
|
||||
config.display.heading_bold = false;
|
||||
|
||||
drawNodes(display, x, compactFirstLine + 3 + layoutYOffset, nodeStatus);
|
||||
drawNodes(display, x, compactFirstLine + 3, nodeStatus);
|
||||
|
||||
#if HAS_GPS
|
||||
if (config.position.fixed_position) {
|
||||
if (SCREEN_WIDTH > 128) {
|
||||
drawGPS(display, SCREEN_WIDTH - 53, compactFirstLine + 3 + layoutYOffset, gpsStatus);
|
||||
drawGPS(display, SCREEN_WIDTH - 53, compactFirstLine + 3, gpsStatus);
|
||||
} else {
|
||||
drawGPS(display, SCREEN_WIDTH - 47, compactFirstLine + 3 + layoutYOffset, gpsStatus);
|
||||
drawGPS(display, SCREEN_WIDTH - 47, compactFirstLine + 3, gpsStatus);
|
||||
}
|
||||
} else if (!gpsStatus || !gpsStatus->getIsConnected()) {
|
||||
String displayLine =
|
||||
config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT ? "No GPS" : "GPS off";
|
||||
int posX = SCREEN_WIDTH - display->getStringWidth(displayLine) - 2;
|
||||
display->drawString(posX, compactFirstLine + 3 + layoutYOffset, displayLine);
|
||||
display->drawString(posX, compactFirstLine, displayLine);
|
||||
} else {
|
||||
if (SCREEN_WIDTH > 128) {
|
||||
drawGPS(display, SCREEN_WIDTH - 53, compactFirstLine + 3 + layoutYOffset, gpsStatus);
|
||||
drawGPS(display, SCREEN_WIDTH - 53, compactFirstLine + 3, gpsStatus);
|
||||
} else {
|
||||
drawGPS(display, SCREEN_WIDTH - 47, compactFirstLine + 3 + layoutYOffset, gpsStatus);
|
||||
drawGPS(display, SCREEN_WIDTH - 47, compactFirstLine + 3, gpsStatus);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -2201,18 +2203,19 @@ static void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
||||
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
||||
defined(ST7789_CS) || defined(USE_ST7789) || defined(HX8357_CS) || ARCH_PORTDUINO) && \
|
||||
!defined(DISPLAY_FORCE_SMALL_FONTS)
|
||||
display->drawFastImage(x, compactSecondLine + 3 + layoutYOffset, 12, 8, imgInfoL1);
|
||||
display->drawFastImage(x, compactSecondLine + 11 + layoutYOffset, 12, 8, imgInfoL2);
|
||||
display->drawFastImage(x, compactSecondLine + 3, 12, 8, imgInfoL1);
|
||||
display->drawFastImage(x, compactSecondLine + 11, 12, 8, imgInfoL2);
|
||||
#else
|
||||
display->drawFastImage(x, compactSecondLine + 2 + layoutYOffset, 8, 8, imgInfo);
|
||||
display->drawFastImage(x, compactSecondLine + 2, 8, 8, imgInfo);
|
||||
#endif
|
||||
|
||||
display->drawString(x + 14, compactSecondLine + layoutYOffset, ourId);
|
||||
int i_xoffset = (SCREEN_WIDTH > 128) ? 14 : 10;
|
||||
display->drawString(x + i_xoffset, compactSecondLine, ourId);
|
||||
|
||||
// Display Channel Utilization
|
||||
char chUtil[13];
|
||||
snprintf(chUtil, sizeof(chUtil), "ChUtil %2.0f%%", airTime->channelUtilizationPercent());
|
||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), compactSecondLine + layoutYOffset, chUtil);
|
||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), compactSecondLine, chUtil);
|
||||
|
||||
// === Third Row: LongName Centered ===
|
||||
meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());
|
||||
@ -2220,7 +2223,7 @@ static void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
||||
const char *longName = ourNode->user.long_name;
|
||||
int textWidth = display->getStringWidth(longName);
|
||||
int nameX = (SCREEN_WIDTH - textWidth) / 2;
|
||||
display->drawString(nameX, compactThirdLine + layoutYOffset, longName);
|
||||
display->drawString(nameX, compactThirdLine, longName);
|
||||
}
|
||||
|
||||
// === Fourth Row: Uptime ===
|
||||
@ -2245,7 +2248,7 @@ static void drawDeviceFocused(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
||||
char uptimeFullStr[16];
|
||||
snprintf(uptimeFullStr, sizeof(uptimeFullStr), "Uptime: %s", uptimeStr);
|
||||
int uptimeX = (SCREEN_WIDTH - display->getStringWidth(uptimeFullStr)) / 2;
|
||||
display->drawString(uptimeX, compactFourthLine + layoutYOffset, uptimeFullStr);
|
||||
display->drawString(uptimeX, compactFourthLine, uptimeFullStr);
|
||||
}
|
||||
|
||||
// ****************************
|
||||
@ -2260,12 +2263,9 @@ static void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int
|
||||
// === Header ===
|
||||
drawCommonHeader(display, x, y);
|
||||
|
||||
// === Adjust layout to match shifted header ===
|
||||
const int layoutYOffset = 1;
|
||||
|
||||
// === Draw title (aligned with header baseline) ===
|
||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
||||
const int textY = y + layoutYOffset + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
||||
const int textY = y + 2 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
||||
const int screenWidth = display->getWidth();
|
||||
const char *titleStr = (screenWidth > 128) ? "LoRa Info" : "LoRa";
|
||||
const int centerX = x + SCREEN_WIDTH / 2;
|
||||
@ -2294,34 +2294,35 @@ static void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int
|
||||
#if (defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ILI9342_DRIVER) || defined(ST7701_CS) || defined(ST7735_CS) || \
|
||||
defined(ST7789_CS) || defined(USE_ST7789) || defined(HX8357_CS) || ARCH_PORTDUINO) && \
|
||||
!defined(DISPLAY_FORCE_SMALL_FONTS)
|
||||
display->drawFastImage(x, compactFirstLine + 5 + layoutYOffset, 12, 8, imgInfoL1);
|
||||
display->drawFastImage(x, compactFirstLine + 12 + layoutYOffset, 12, 8, imgInfoL2);
|
||||
display->drawFastImage(x, compactFirstLine + 5, 12, 8, imgInfoL1);
|
||||
display->drawFastImage(x, compactFirstLine + 12, 12, 8, imgInfoL2);
|
||||
#else
|
||||
display->drawFastImage(x, compactFirstLine + 3 + layoutYOffset, 8, 8, imgInfo);
|
||||
display->drawFastImage(x, compactFirstLine + 3, 8, 8, imgInfo);
|
||||
#endif
|
||||
|
||||
display->drawString(x + 14, compactFirstLine + layoutYOffset, ourId);
|
||||
int i_xoffset = (SCREEN_WIDTH > 128) ? 14 : 10;
|
||||
display->drawString(x + i_xoffset, compactFirstLine, ourId);
|
||||
|
||||
const char *region = myRegion ? myRegion->name : NULL;
|
||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(region), compactFirstLine + layoutYOffset, region);
|
||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(region), compactFirstLine, region);
|
||||
|
||||
config.display.heading_bold = origBold;
|
||||
|
||||
// === Second Row: Channel and Channel Utilization ===
|
||||
char chUtil[13];
|
||||
snprintf(chUtil, sizeof(chUtil), "ChUtil %2.0f%%", airTime->channelUtilizationPercent());
|
||||
display->drawString(x, compactSecondLine + layoutYOffset, chUtil);
|
||||
display->drawString(x, compactSecondLine, chUtil);
|
||||
|
||||
char channelStr[20];
|
||||
snprintf(channelStr, sizeof(channelStr), "#%s", channels.getName(channels.getPrimaryIndex()));
|
||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(channelStr), compactSecondLine + layoutYOffset, channelStr);
|
||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(channelStr), compactSecondLine, channelStr);
|
||||
|
||||
// === Third Row: Node longName ===
|
||||
meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());
|
||||
if (ourNode && ourNode->has_user && strlen(ourNode->user.long_name) > 0) {
|
||||
const char *longName = ourNode->user.long_name;
|
||||
int nameX = (SCREEN_WIDTH - display->getStringWidth(longName)) / 2;
|
||||
display->drawString(nameX, compactThirdLine + layoutYOffset, longName);
|
||||
display->drawString(nameX, compactThirdLine, longName);
|
||||
}
|
||||
|
||||
// === Fourth Row: Node shortName ===
|
||||
@ -2329,7 +2330,7 @@ static void drawLoRaFocused(OLEDDisplay *display, OLEDDisplayUiState *state, int
|
||||
snprintf(buf, sizeof(buf), "%s\n%s", xstr(APP_VERSION_SHORT), haveGlyphs(owner.short_name) ? owner.short_name : "");
|
||||
if (ourNode && ourNode->has_user && strlen(ourNode->user.long_name) > 0) {
|
||||
int shortNameX = (SCREEN_WIDTH - display->getStringWidth(owner.short_name)) / 2;
|
||||
display->drawString(shortNameX, compactFourthLine + layoutYOffset, owner.short_name);
|
||||
display->drawString(shortNameX, compactFourthLine, owner.short_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2346,9 +2347,8 @@ static void drawActivity(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
||||
drawCommonHeader(display, x, y);
|
||||
|
||||
// === Draw title ===
|
||||
const int layoutYOffset = 1;
|
||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
||||
const int textY = y + layoutYOffset + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
||||
const int textY = y + 2 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
||||
|
||||
// Use black text if display is inverted
|
||||
if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) {
|
||||
@ -2367,7 +2367,7 @@ static void drawActivity(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
||||
display->setColor(WHITE);
|
||||
|
||||
// === First Line: Draw any log messages ===
|
||||
display->drawLogBuffer(x, compactFirstLine + layoutYOffset);
|
||||
display->drawLogBuffer(x, compactFirstLine);
|
||||
}
|
||||
|
||||
// ****************************
|
||||
@ -2382,12 +2382,9 @@ static void drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayUiStat
|
||||
// === Header ===
|
||||
drawCommonHeader(display, x, y);
|
||||
|
||||
// === Adjust layout to match shifted header ===
|
||||
const int layoutYOffset = 1;
|
||||
|
||||
// === Draw title ===
|
||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
||||
const int textY = y + layoutYOffset + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
||||
const int textY = y + 2 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
||||
const int screenWidth = display->getWidth();
|
||||
const char *titleStr = "GPS";
|
||||
const int centerX = x + SCREEN_WIDTH / 2;
|
||||
@ -2406,34 +2403,34 @@ static void drawCompassAndLocationScreen(OLEDDisplay *display, OLEDDisplayUiStat
|
||||
|
||||
// Row Y offset just like drawNodeListScreen
|
||||
int rowYOffset = FONT_HEIGHT_SMALL - 3;
|
||||
int rowY = y + rowYOffset + layoutYOffset;
|
||||
int rowY = y + rowYOffset;
|
||||
|
||||
// === Second Row: My Location ===
|
||||
#if HAS_GPS
|
||||
bool origBold = config.display.heading_bold;
|
||||
config.display.heading_bold = false;
|
||||
if (config.position.fixed_position) {
|
||||
display->drawString(x + 2, compactFirstLine + layoutYOffset, "Sat:");
|
||||
display->drawString(x + 2, compactFirstLine, "Sat:");
|
||||
if (screenWidth > 128) {
|
||||
drawGPS(display, x + 32, compactFirstLine + 3 + layoutYOffset, gpsStatus);
|
||||
drawGPS(display, x + 32, compactFirstLine + 3, gpsStatus);
|
||||
} else {
|
||||
drawGPS(display, x + 23, compactFirstLine + 3 + layoutYOffset, gpsStatus);
|
||||
drawGPS(display, x + 23, compactFirstLine + 3, gpsStatus);
|
||||
}
|
||||
} else if (!gpsStatus || !gpsStatus->getIsConnected()) {
|
||||
String displayLine =
|
||||
config.position.gps_mode == meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT ? "No GPS" : "GPS off";
|
||||
display->drawString(x + 2, compactFirstLine + layoutYOffset, "Sat:");
|
||||
display->drawString(x + 2, compactFirstLine, "Sat:");
|
||||
if (screenWidth > 128) {
|
||||
display->drawString(x + 32, compactFirstLine + 3 + layoutYOffset, displayLine);
|
||||
display->drawString(x + 32, compactFirstLine, displayLine);
|
||||
} else {
|
||||
display->drawString(x + 23, compactFirstLine + 3 + layoutYOffset, displayLine);
|
||||
display->drawString(x + 23, compactFirstLine, displayLine);
|
||||
}
|
||||
} else {
|
||||
display->drawString(x + 2, compactFirstLine + layoutYOffset, "Sat:");
|
||||
display->drawString(x + 2, compactFirstLine, "Sat:");
|
||||
if (screenWidth > 128) {
|
||||
drawGPS(display, x + 32, compactFirstLine + 3 + layoutYOffset, gpsStatus);
|
||||
drawGPS(display, x + 32, compactFirstLine + 3, gpsStatus);
|
||||
} else {
|
||||
drawGPS(display, x + 23, compactFirstLine + 3 + layoutYOffset, gpsStatus);
|
||||
drawGPS(display, x + 23, compactFirstLine + 3, gpsStatus);
|
||||
}
|
||||
}
|
||||
config.display.heading_bold = origBold;
|
||||
@ -2517,9 +2514,8 @@ static void drawMemoryScreen(OLEDDisplay *display, OLEDDisplayUiState *state, in
|
||||
drawCommonHeader(display, x, y);
|
||||
|
||||
// === Draw title ===
|
||||
const int layoutYOffset = 1;
|
||||
const int highlightHeight = FONT_HEIGHT_SMALL - 1;
|
||||
const int textY = y + layoutYOffset + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
||||
const int textY = y + 2 + (highlightHeight - FONT_HEIGHT_SMALL) / 2;
|
||||
const int screenWidth = display->getWidth();
|
||||
const char *titleStr = (screenWidth > 128) ? "Memory" : "Mem";
|
||||
const int centerX = x + SCREEN_WIDTH / 2;
|
||||
@ -2543,7 +2539,7 @@ static void drawMemoryScreen(OLEDDisplay *display, OLEDDisplayUiState *state, in
|
||||
const int barX = x + 40 + barsOffset;
|
||||
const int textRightX = x + SCREEN_WIDTH - 2;
|
||||
|
||||
int rowY = y + rowYOffset + layoutYOffset;
|
||||
int rowY = y + rowYOffset;
|
||||
|
||||
// === Heap delta tracking ===
|
||||
static uint32_t previousHeapFree = 0;
|
||||
@ -2552,7 +2548,8 @@ static void drawMemoryScreen(OLEDDisplay *display, OLEDDisplayUiState *state, in
|
||||
static int deltaChangeCount = 0;
|
||||
|
||||
auto drawUsageRow = [&](const char *label, uint32_t used, uint32_t total, bool isHeap = false) {
|
||||
if (total == 0) return;
|
||||
if (total == 0)
|
||||
return;
|
||||
|
||||
int percent = (used * 100) / total;
|
||||
|
||||
@ -2667,17 +2664,16 @@ static void drawMemoryScreen(OLEDDisplay *display, OLEDDisplayUiState *state, in
|
||||
// Draw triangle manually
|
||||
int triY = rowY + 4;
|
||||
int triX = centerX - display->getStringWidth(summaryStr) / 2 - 8;
|
||||
|
||||
|
||||
display->drawLine(triX, triY + 6, triX + 3, triY);
|
||||
display->drawLine(triX + 3, triY, triX + 6, triY + 6);
|
||||
display->drawLine(triX, triY + 6, triX + 6, triY + 6);
|
||||
|
||||
|
||||
// Draw the text to the right of the triangle
|
||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||
display->drawString(triX + 10, rowY + 2, summaryStr);
|
||||
}
|
||||
|
||||
|
||||
#if defined(ESP_PLATFORM) && defined(USE_ST7789)
|
||||
SPIClass SPI1(HSPI);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user