Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/graphics/draw/MenuHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ void menuHandler::nodeNameLengthMenu()
screen->runNow();
}
};
bannerOptions.InitialSelected = config.display.use_long_node_name == true ? 1 : 2;
Comment thread
thebentern marked this conversation as resolved.
screen->showOverlayBanner(bannerOptions);
}

Expand Down
34 changes: 28 additions & 6 deletions src/graphics/draw/NodeListRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static int scrollIndex = 0;
// Utility Functions
// =============================

const char *getSafeNodeName(meshtastic_NodeInfoLite *node)
const char *getSafeNodeName(OLEDDisplay *display, meshtastic_NodeInfoLite *node)
{
const char *name = NULL;
static char nodeName[16] = "?";
Expand Down Expand Up @@ -81,6 +81,28 @@ const char *getSafeNodeName(meshtastic_NodeInfoLite *node)
snprintf(nodeName, sizeof(nodeName), "(%04X)", (uint16_t)(node->num & 0xFFFF));
}

if (config.display.use_long_node_name == true) {
int availWidth = (SCREEN_WIDTH / 2) - 65;
Comment thread
thebentern marked this conversation as resolved.
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 "..." (ensure space remains in buffer)
if (strlen(nodeName) < origLen) {
size_t len = strlen(nodeName);
size_t maxLen = sizeof(nodeName) - 4; // 3 for "..." and 1 for '\0'
if (len > maxLen) {
nodeName[maxLen] = '\0';
len = maxLen;
}
strcat(nodeName, "...");
}
}

return nodeName;
}

Expand Down Expand Up @@ -147,7 +169,7 @@ void drawEntryLastHeard(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int
bool isLeftCol = (x < SCREEN_WIDTH / 2);
int timeOffset = (isHighResolution) ? (isLeftCol ? 7 : 10) : (isLeftCol ? 3 : 7);

const char *nodeName = getSafeNodeName(node);
const char *nodeName = getSafeNodeName(display, node);

char timeStr[10];
uint32_t seconds = sinceLastSeen(node);
Expand Down Expand Up @@ -192,7 +214,7 @@ void drawEntryHopSignal(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int

int barsXOffset = columnWidth - barsOffset;

const char *nodeName = getSafeNodeName(node);
const char *nodeName = getSafeNodeName(display, node);

display->setTextAlignment(TEXT_ALIGN_LEFT);
display->setFont(FONT_SMALL);
Expand Down Expand Up @@ -236,7 +258,7 @@ void drawNodeDistance(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
bool isLeftCol = (x < SCREEN_WIDTH / 2);
int nameMaxWidth = columnWidth - (isHighResolution ? (isLeftCol ? 25 : 28) : (isLeftCol ? 20 : 22));

const char *nodeName = getSafeNodeName(node);
const char *nodeName = getSafeNodeName(display, node);
char distStr[10] = "";

meshtastic_NodeInfoLite *ourNode = nodeDB->getMeshNode(nodeDB->getNodeNum());
Expand Down Expand Up @@ -331,7 +353,7 @@ void drawEntryCompass(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
// Adjust max text width depending on column and screen width
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->setFont(FONT_SMALL);
Expand Down Expand Up @@ -362,11 +384,11 @@ void drawCompassArrow(OLEDDisplay *display, meshtastic_NodeInfoLite *node, int16
float bearing = GeoCoord::bearing(userLat, userLon, nodeLat, nodeLon);
float bearingToNode = RAD_TO_DEG * bearing;
float relativeBearing = fmod((bearingToNode - myHeading + 360), 360);
float angle = relativeBearing * DEG_TO_RAD;
// Shrink size by 2px
int size = FONT_HEIGHT_SMALL - 5;
CompassRenderer::drawArrowToNode(display, centerX, centerY, size, relativeBearing);
/*
float angle = relativeBearing * DEG_TO_RAD;
float halfSize = size / 2.0;

// Point of the arrow
Expand Down
Loading