mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-27 15:02:41 +00:00
Address longName wrapping
This commit is contained in:
parent
35fa418739
commit
7640caa053
@ -784,6 +784,7 @@ void menuHandler::nodeNameLengthMenu()
|
|||||||
screen->runNow();
|
screen->runNow();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
bannerOptions.InitialSelected = config.display.use_long_node_name == true ? 1 : 2;
|
||||||
screen->showOverlayBanner(bannerOptions);
|
screen->showOverlayBanner(bannerOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@ static int scrollIndex = 0;
|
|||||||
// Utility Functions
|
// Utility Functions
|
||||||
// =============================
|
// =============================
|
||||||
|
|
||||||
const char *getSafeNodeName(meshtastic_NodeInfoLite *node)
|
const char *getSafeNodeName(OLEDDisplay *display, meshtastic_NodeInfoLite *node)
|
||||||
{
|
{
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
static char nodeName[16] = "?";
|
static char nodeName[16] = "?";
|
||||||
@ -81,6 +81,22 @@ const char *getSafeNodeName(meshtastic_NodeInfoLite *node)
|
|||||||
snprintf(nodeName, sizeof(nodeName), "(%04X)", (uint16_t)(node->num & 0xFFFF));
|
snprintf(nodeName, sizeof(nodeName), "(%04X)", (uint16_t)(node->num & 0xFFFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.display.use_long_node_name == true) {
|
||||||
|
int availWidth = (SCREEN_WIDTH / 2) - 65;
|
||||||
|
if (availWidth < 0)
|
||||||
|
availWidth = 0;
|
||||||
|
|
||||||
|
size_t origLen = strlen(nodeName);
|
||||||
|
while (nodeName[0] && display->getStringWidth(nodeName) > availWidth) {
|
||||||
|
nodeName[strlen(nodeName) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we actually truncated, append "..."
|
||||||
|
if (strlen(nodeName) < origLen) {
|
||||||
|
strcat(nodeName, "...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nodeName;
|
return nodeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +163,7 @@ void drawEntryLastHeard(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int
|
|||||||
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
||||||
int timeOffset = (isHighResolution) ? (isLeftCol ? 7 : 10) : (isLeftCol ? 3 : 7);
|
int timeOffset = (isHighResolution) ? (isLeftCol ? 7 : 10) : (isLeftCol ? 3 : 7);
|
||||||
|
|
||||||
const char *nodeName = getSafeNodeName(node);
|
const char *nodeName = getSafeNodeName(display, node);
|
||||||
|
|
||||||
char timeStr[10];
|
char timeStr[10];
|
||||||
uint32_t seconds = sinceLastSeen(node);
|
uint32_t seconds = sinceLastSeen(node);
|
||||||
@ -192,7 +208,7 @@ void drawEntryHopSignal(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int
|
|||||||
|
|
||||||
int barsXOffset = columnWidth - barsOffset;
|
int barsXOffset = columnWidth - barsOffset;
|
||||||
|
|
||||||
const char *nodeName = getSafeNodeName(node);
|
const char *nodeName = getSafeNodeName(display, node);
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
@ -236,7 +252,7 @@ void drawNodeDistance(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
|
|||||||
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
bool isLeftCol = (x < SCREEN_WIDTH / 2);
|
||||||
int nameMaxWidth = columnWidth - (isHighResolution ? (isLeftCol ? 25 : 28) : (isLeftCol ? 20 : 22));
|
int nameMaxWidth = columnWidth - (isHighResolution ? (isLeftCol ? 25 : 28) : (isLeftCol ? 20 : 22));
|
||||||
|
|
||||||
const char *nodeName = getSafeNodeName(node);
|
const char *nodeName = getSafeNodeName(display, node);
|
||||||
char distStr[10] = "";
|
char distStr[10] = "";
|
||||||
|
|
||||||
meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());
|
meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());
|
||||||
@ -331,7 +347,7 @@ void drawEntryCompass(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
|
|||||||
// Adjust max text width depending on column and screen width
|
// Adjust max text width depending on column and screen width
|
||||||
int nameMaxWidth = columnWidth - (isHighResolution ? (isLeftCol ? 25 : 28) : (isLeftCol ? 20 : 22));
|
int nameMaxWidth = columnWidth - (isHighResolution ? (isLeftCol ? 25 : 28) : (isLeftCol ? 20 : 22));
|
||||||
|
|
||||||
const char *nodeName = getSafeNodeName(node);
|
const char *nodeName = getSafeNodeName(display, node);
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
@ -362,11 +378,11 @@ void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
|
|||||||
float bearing = GeoCoord::bearing(userLat, userLon, nodeLat, nodeLon);
|
float bearing = GeoCoord::bearing(userLat, userLon, nodeLat, nodeLon);
|
||||||
float bearingToNode = RAD_TO_DEG * bearing;
|
float bearingToNode = RAD_TO_DEG * bearing;
|
||||||
float relativeBearing = fmod((bearingToNode - myHeading + 360), 360);
|
float relativeBearing = fmod((bearingToNode - myHeading + 360), 360);
|
||||||
float angle = relativeBearing * DEG_TO_RAD;
|
|
||||||
// Shrink size by 2px
|
// Shrink size by 2px
|
||||||
int size = FONT_HEIGHT_SMALL - 5;
|
int size = FONT_HEIGHT_SMALL - 5;
|
||||||
CompassRenderer::drawArrowToNode(display, centerX, centerY, size, relativeBearing);
|
CompassRenderer::drawArrowToNode(display, centerX, centerY, size, relativeBearing);
|
||||||
/*
|
/*
|
||||||
|
float angle = relativeBearing * DEG_TO_RAD;
|
||||||
float halfSize = size / 2.0;
|
float halfSize = size / 2.0;
|
||||||
|
|
||||||
// Point of the arrow
|
// Point of the arrow
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user