mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-13 22:32:27 +00:00
Dynamic scaling of column counts based upon screen size, clean up box drawing
This commit is contained in:
@@ -1175,7 +1175,7 @@ void menuHandler::nodeNameLengthMenu()
|
|||||||
LOG_INFO("Setting names to short");
|
LOG_INFO("Setting names to short");
|
||||||
config.display.use_long_node_name = false;
|
config.display.use_long_node_name = false;
|
||||||
} else if (selected == Back) {
|
} else if (selected == Back) {
|
||||||
menuQueue = screen_options_menu;
|
menuQueue = node_base_menu;
|
||||||
screen->runNow();
|
screen->runNow();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1203,6 +1203,9 @@ void menuHandler::resetNodeDBMenu()
|
|||||||
LOG_INFO("Initiate node-db reset but keeping favorites");
|
LOG_INFO("Initiate node-db reset but keeping favorites");
|
||||||
nodeDB->resetNodes(1);
|
nodeDB->resetNodes(1);
|
||||||
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
|
rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000);
|
||||||
|
} else if (selected == 0) {
|
||||||
|
menuQueue = node_base_menu;
|
||||||
|
screen->runNow();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
screen->showOverlayBanner(bannerOptions);
|
screen->showOverlayBanner(bannerOptions);
|
||||||
@@ -2097,6 +2100,9 @@ void menuHandler::handleMenuSwitch(OLEDDisplay *display)
|
|||||||
case position_base_menu:
|
case position_base_menu:
|
||||||
positionBaseMenu();
|
positionBaseMenu();
|
||||||
break;
|
break;
|
||||||
|
case node_base_menu:
|
||||||
|
nodeListMenu();
|
||||||
|
break;
|
||||||
#if !MESHTASTIC_EXCLUDE_GPS
|
#if !MESHTASTIC_EXCLUDE_GPS
|
||||||
case gps_toggle_menu:
|
case gps_toggle_menu:
|
||||||
GPSToggleMenu();
|
GPSToggleMenu();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class menuHandler
|
|||||||
clock_face_picker,
|
clock_face_picker,
|
||||||
clock_menu,
|
clock_menu,
|
||||||
position_base_menu,
|
position_base_menu,
|
||||||
|
node_base_menu,
|
||||||
gps_toggle_menu,
|
gps_toggle_menu,
|
||||||
gps_format_menu,
|
gps_format_menu,
|
||||||
compass_point_north_menu,
|
compass_point_north_menu,
|
||||||
|
|||||||
@@ -493,19 +493,23 @@ void drawNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t
|
|||||||
// Space below header
|
// Space below header
|
||||||
y += COMMON_HEADER_HEIGHT;
|
y += COMMON_HEADER_HEIGHT;
|
||||||
|
|
||||||
#if defined(M5STACK_UNITC6L)
|
int totalColumns = 1; // Default to 1 column
|
||||||
int totalColumns = 1;
|
|
||||||
#elif defined(T_LORA_PAGER)
|
|
||||||
int totalColumns = 3;
|
|
||||||
if (config.display.use_long_node_name) {
|
if (config.display.use_long_node_name) {
|
||||||
totalColumns = 2;
|
if (SCREEN_WIDTH <= 240) {
|
||||||
|
totalColumns = 1;
|
||||||
|
} else if (SCREEN_WIDTH > 240) {
|
||||||
|
totalColumns = 2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (SCREEN_WIDTH <= 64) {
|
||||||
|
totalColumns = 1;
|
||||||
|
} else if (SCREEN_WIDTH > 64 && SCREEN_WIDTH <= 240) {
|
||||||
|
totalColumns = 2;
|
||||||
|
} else {
|
||||||
|
totalColumns = 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
int totalColumns = 2;
|
|
||||||
if (config.display.use_long_node_name) {
|
|
||||||
totalColumns = 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int columnWidth = display->getWidth() / totalColumns;
|
int columnWidth = display->getWidth() / totalColumns;
|
||||||
|
|
||||||
@@ -520,7 +524,8 @@ void drawNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t
|
|||||||
for (int i = 0; i < totalEntries; i++) {
|
for (int i = 0; i < totalEntries; i++) {
|
||||||
auto *n = nodeDB->getMeshNodeByIndex(i);
|
auto *n = nodeDB->getMeshNodeByIndex(i);
|
||||||
|
|
||||||
if (!n) continue;
|
if (!n)
|
||||||
|
continue;
|
||||||
if (n->num == nodeDB->getNodeNum())
|
if (n->num == nodeDB->getNodeNum())
|
||||||
continue;
|
continue;
|
||||||
if (locationScreen && !n->has_position)
|
if (locationScreen && !n->has_position)
|
||||||
@@ -597,11 +602,11 @@ void drawNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t
|
|||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
// Box padding
|
// Box padding
|
||||||
int padding = 3;
|
int padding = 2;
|
||||||
int textW = display->getStringWidth(buf);
|
int textW = display->getStringWidth(buf);
|
||||||
int textH = FONT_HEIGHT_SMALL;
|
int textH = FONT_HEIGHT_SMALL;
|
||||||
int w = textW + padding * 2;
|
int boxWidth = textW + padding * 3;
|
||||||
int h = textH + padding * 2;
|
int boxHeight = textH + padding * 2;
|
||||||
|
|
||||||
// Center of usable screen area:
|
// Center of usable screen area:
|
||||||
int headerHeight = FONT_HEIGHT_SMALL - 1;
|
int headerHeight = FONT_HEIGHT_SMALL - 1;
|
||||||
@@ -612,19 +617,27 @@ void drawNodeListScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t
|
|||||||
int usableHeight = usableBottom - usableTop;
|
int usableHeight = usableBottom - usableTop;
|
||||||
|
|
||||||
// Center point inside usable area
|
// Center point inside usable area
|
||||||
int px = (display->getWidth() - w) / 2;
|
int boxLeft = (display->getWidth() - boxWidth) / 2;
|
||||||
int py = usableTop + (usableHeight - h) / 2;
|
int boxTop = usableTop + (usableHeight - boxHeight) / 2;
|
||||||
|
|
||||||
// Background
|
// Draw Box
|
||||||
display->setColor(BLACK);
|
display->setColor(BLACK);
|
||||||
display->fillRect(px, py, w, h);
|
display->fillRect(boxLeft - 1, boxTop - 1, boxWidth + 2, boxHeight + 2);
|
||||||
|
display->fillRect(boxLeft, boxTop - 2, boxWidth, 1);
|
||||||
// Border
|
display->fillRect(boxLeft, boxTop + boxHeight + 1, boxWidth, 1);
|
||||||
|
display->fillRect(boxLeft - 2, boxTop, 1, boxHeight);
|
||||||
|
display->fillRect(boxLeft + boxWidth + 1, boxTop, 1, boxHeight);
|
||||||
|
display->setColor(WHITE);
|
||||||
|
display->drawRect(boxLeft, boxTop, boxWidth, boxHeight);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
display->fillRect(boxLeft, boxTop, 1, 1);
|
||||||
|
display->fillRect(boxLeft + boxWidth - 1, boxTop, 1, 1);
|
||||||
|
display->fillRect(boxLeft, boxTop + boxHeight - 1, 1, 1);
|
||||||
|
display->fillRect(boxLeft + boxWidth - 1, boxTop + boxHeight - 1, 1, 1);
|
||||||
display->setColor(WHITE);
|
display->setColor(WHITE);
|
||||||
display->drawRect(px, py, w, h);
|
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
display->drawString(px + padding, py + padding, buf);
|
display->drawString(boxLeft + padding, boxTop + padding, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user