Shorten longNames to not exceed message popups

This commit is contained in:
Jason P
2025-10-16 22:53:01 -05:00
parent 14dfce5e03
commit 13458d3a6a
4 changed files with 40 additions and 5 deletions

View File

@@ -2199,11 +2199,27 @@ ProcessMessage CannedMessageModule::handleReceived(const meshtastic_MeshPacket &
// Show overlay banner
if (screen) {
auto *display = screen->getDisplayDevice();
graphics::BannerOverlayOptions opts;
static char buf[128];
const char *channelName = channels.getName(this->channel);
const char *nodeName = getNodeName(this->incoming);
const char *src = getNodeName(this->incoming);
char nodeName[48];
strncpy(nodeName, src, sizeof(nodeName) - 1);
nodeName[sizeof(nodeName) - 1] = '\0';
int availWidth = display->getWidth() - (graphics::isHighResolution ? 60 : 30);
if (availWidth < 0)
availWidth = 0;
size_t origLen = strlen(nodeName);
while (nodeName[0] && display->getStringWidth(nodeName) > availWidth) {
nodeName[strlen(nodeName) - 1] = '\0';
}
if (strlen(nodeName) < origLen) {
strcat(nodeName, "...");
}
// Calculate signal quality and bars based on preset, SNR, and RSSI
float snrLimit = getSnrLimit(config.lora.modem_preset);

View File

@@ -6,7 +6,9 @@
#include "buzz.h"
#include "configuration.h"
#include "graphics/Screen.h"
#include "graphics/SharedUIDisplay.h"
#include "graphics/draw/MessageRenderer.h"
#include "main.h"
TextMessageModule *textMessageModule;
ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp)
@@ -24,7 +26,9 @@ ProcessMessage TextMessageModule::handleReceived(const meshtastic_MeshPacket &mp
const StoredMessage &sm = messageStore.addFromPacket(mp);
// Pass message to renderer (banner + thread switching + scroll reset)
graphics::MessageRenderer::handleNewMessage(sm, mp);
// Use the global Screen singleton to retrieve the current OLED display
auto *display = screen ? screen->getDisplayDevice() : nullptr;
graphics::MessageRenderer::handleNewMessage(display, sm, mp);
#endif
// Only trigger screen wake if configuration allows it
if (shouldWakeOnReceivedMessage()) {