Use compact message text and sender lines on all small displays

This commit is contained in:
mikecarper committed 2026-09-08 13:36:40 -07:00
1 parent a7f088290b
commit eeea15ef01
19 files changed
+507 -141

No files matched your search

+20 -2
View File
@@ -3,6 +3,9 @@
#include <helpers/ui/BluetoothPairingUiPolicy.h>
#include <helpers/ui/CompanionHomeLayout.h>
#include <helpers/ui/CompanionMessageHistory.h>
#if UI_SMALL_MESSAGE_FONT == 1
#include <helpers/ui/Pixel5Text.h>
#endif
#include <helpers/ui/CompanionTransportSelectorLayout.h>
#include "../MyMesh.h"
#include "../CompanionWiFi.h"
@@ -1171,7 +1174,11 @@ public:
};
#ifndef UI_MSG_PREVIEW_SIZE
#define UI_MSG_PREVIEW_SIZE 78
#if UI_SMALL_MESSAGE_FONT == 1
#define UI_MSG_PREVIEW_SIZE 161
#else
#define UI_MSG_PREVIEW_SIZE 78
#endif
#endif
#ifndef UI_COMPACT_MESSAGE_STATUS
#define UI_COMPACT_MESSAGE_STATUS 0
@@ -1407,7 +1414,7 @@ public:
display.setCursor(0, 0);
display.setTextSize(1);
display.setColor(UIColor::corp_blue);
snprintf(tmp, sizeof(tmp), "Message %d/%d",
snprintf(tmp, sizeof(tmp), display.width() < 100 ? "%d/%d" : "Message %d/%d",
filtered_count == 0 ? 0 : view_offset + 1, filtered_count);
display.print(tmp);
@@ -1425,12 +1432,22 @@ public:
mesh::ui::formatCompanionMessageAge(
tmp, sizeof(tmp), companionMessageElapsedMillis(p->heard_millis));
if (display.width() < 100) {
char* suffix = strchr(tmp, ' ');
if (suffix != nullptr) *suffix = 0;
}
display.setCursor(display.width() - display.getTextWidth(tmp) - 2, 0);
display.print(tmp);
display.drawRect(0, layout.header_divider_y, display.width(), 1);
display.setCompactText(false);
#if UI_SMALL_MESSAGE_FONT == 1
mesh::ui::drawSmallMessageBody(display, p->origin, p->message,
layout.origin_y, layout.origin_y + 7,
UI_MESSAGE_CHANNEL_FOOTER == 1
? display.height() - layout.filter_height : display.height());
#else
display.setCursor(0, layout.origin_y);
display.setColor(UIColor::secondary_txt);
char filtered_origin[sizeof(p->origin)];
@@ -1442,6 +1459,7 @@ public:
char filtered_msg[sizeof(p->message)];
display.translateUTF8ToBlocks(filtered_msg, p->message, sizeof(filtered_msg));
display.printWordWrap(filtered_msg, display.width());
#endif
renderChannelFilter(display);
@@ -1,4 +1,7 @@
#include "UITask.h"
#if UI_SMALL_MESSAGE_FONT == 1
#include <helpers/ui/Pixel5Text.h>
#endif
#include <Arduino.h>
#include <helpers/TxtDataHelpers.h>
#include <helpers/ui/BluetoothPairingUiPolicy.h>
@@ -242,6 +245,9 @@ void UITask::renderCurrScreen() {
_display->setColor(UIColor::primary_txt);
_display->print(_node_prefs->node_name);
#if UI_SMALL_MESSAGE_FONT == 1
mesh::ui::drawSmallMessageBody(*_display, _origin, _msg, 12, 19);
#else
_display->setCursor(0, 12);
_display->setColor(UIColor::secondary_txt);
_display->print(_origin);
@@ -253,6 +259,7 @@ void UITask::renderCurrScreen() {
_display->setColor(UIColor::primary_txt);
sprintf(tmp, "%d", _msgcount);
_display->print(tmp);
#endif
_display->setColor(UIColor::secondary_txt); // last color will be kept on T114
} else if (!pairing_screen_active && (millis() - ui_started_at) < BOOT_SCREEN_MILLIS) { // boot screen
// meshcore logo
@@ -31,7 +31,11 @@ class UITask : public AbstractUITask {
CompanionNodePrefs* _node_prefs;
char _version_info[32];
char _origin[62];
#if UI_SMALL_MESSAGE_FONT == 1
char _msg[161];
#else
char _msg[80];
#endif
char _alert[80];
int _msgcount;
bool _need_refresh = true;
@@ -1,4 +1,7 @@
#include "UITask.h"
#if UI_SMALL_MESSAGE_FONT == 1
#include <helpers/ui/Pixel5Text.h>
#endif
#include <helpers/TxtDataHelpers.h>
#include <helpers/ui/BluetoothPairingUiPolicy.h>
#include "../MyMesh.h"
@@ -439,6 +442,38 @@ public:
};
#if UI_SMALL_MESSAGE_FONT == 1
class TinyMessageScreen : public UIScreen {
UITask* _task;
char _origin[62] = {};
char _message[161] = {};
public:
explicit TinyMessageScreen(UITask* task) : _task(task) {}
void setMessage(uint8_t path_len, const char* from, const char* message) {
if (path_len == 0xFF) {
snprintf(_origin, sizeof(_origin), "%s [direct]:", from);
} else {
snprintf(_origin, sizeof(_origin), "%s [%uh]:", from,
(unsigned int)path_len);
}
StrHelper::strncpy(_message, message, sizeof(_message));
}
int render(DisplayDriver& display) override {
// The 72x40 interface reserves its top 8px for the scrolling status bar.
mesh::ui::drawSmallMessageBody(display, _origin, _message, 10, 17);
return 1000;
}
bool handleInput(char c) override {
if (c == KEY_NEXT || c == KEY_PREV || c == KEY_LEFT || c == KEY_RIGHT
|| c == KEY_ENTER) {
_task->gotoHomeScreen();
return true;
}
return false;
}
};
#endif
void UITask::begin(DisplayDriver* display, SensorManager* sensors, CompanionNodePrefs* node_prefs) {
_display = display;
_sensors = sensors;
@@ -478,6 +513,9 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, CompanionNode
splash = new SplashScreen(this);
home = new HomeScreen(this, &rtc_clock, sensors, node_prefs);
#if UI_SMALL_MESSAGE_FONT == 1
msg_preview = new TinyMessageScreen(this);
#endif
setCurrScreen(splash);
}
@@ -519,6 +557,11 @@ switch(t){
void UITask::msgRead(int msgcount) {
_msgcount = msgcount;
if (msgcount == 0) {
#if UI_SMALL_MESSAGE_FONT == 1
if (curr == msg_preview
&& static_cast<int32_t>(millis() - _msg_preview_until) < 0) return;
_deferred_msg_preview = false;
#endif
gotoHomeScreen();
}
}
@@ -529,6 +572,12 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text,
(void)channel_idx;
(void)channel_name;
_msgcount = msgcount;
#if UI_SMALL_MESSAGE_FONT == 1
static_cast<TinyMessageScreen*>(msg_preview)->setMessage(path_len, from_name, text);
if (isPairingScreenActive()) _deferred_msg_preview = true;
else setCurrScreen(msg_preview);
_msg_preview_until = millis() + 15000UL;
#endif
if (_display != NULL) {
if (!_display->isOn() && shouldWakeDisplayForMessage()) {
@@ -591,6 +640,12 @@ void UITask::showPairingPin() {
void UITask::finishPairingScreen(bool timed_out) {
_pairing_screen_until = 0;
_next_refresh = 0;
#if UI_SMALL_MESSAGE_FONT == 1
if (_deferred_msg_preview) {
_deferred_msg_preview = false;
setCurrScreen(msg_preview);
}
#endif
if (_display == NULL) return;
if (timed_out) {
+5 -1
View File
@@ -56,7 +56,11 @@ class UITask : public AbstractUITask {
UIScreen* splash;
UIScreen* home;
// UIScreen* msg_preview;
#if UI_SMALL_MESSAGE_FONT == 1
UIScreen* msg_preview = nullptr;
bool _deferred_msg_preview = false;
unsigned long _msg_preview_until = 0;
#endif
UIScreen* curr;