Fix Companion pairing tests and nRF52 OTA image size

The extracted inbox renderer was missing HomeScreen's pairing PIN visibility
state. Provide it and check that it agrees with the complete PIN on screen.

Reuse the text drawing result instead of measuring pairing values twice, and
keep the bottom pairing layout separate from the large home renderer. This
saves 32 bytes in the RAK4631 Full Companion and lets its OTA image pass the
existing application limit without removing features or weakening checks.

Fixes the two failures in unit-test run 40174991783.
This commit is contained in:
mikecarper committed 2026-10-25 09:00:12 -07:00
1 parent 6bcedc7344
commit 16399a019d
3 files changed
+16 -10

No files matched your search

+2 -2
View File
@@ -1191,10 +1191,10 @@ public:
mesh::ui::drawTextCenteredEllipsized(
display, layout.pairing, layout.pairing_label_y, pairing_label);
display.setTextSize(pairing_value_size);
mesh::ui::drawTextCenteredEllipsized(
const bool value_drawn = mesh::ui::drawTextCenteredEllipsized(
display, layout.pairing, layout.pairing_value_y, pairing_value);
_pairing_pin_visible = pairing_value == pairing_pin
&& display.getTextWidth(pairing_value) <= layout.pairing.width
&& value_drawn
&& layout.pairing_value_y + display.textLineHeight() <= display.height();
} else if (expanded_home) {
display.setColor(UIColor::secondary_txt);
+9 -6
View File
@@ -144,16 +144,19 @@ inline void clearDisplayRegion(DisplayDriver& display,
// Center short text inside the supplied region and ellipsize long text from
// the region's left edge. In both cases the rendered row is horizontally
// bounded by the region and cannot run into an adjacent UI block.
inline void drawTextCenteredEllipsized(DisplayDriver& display,
// Return true when the complete text was drawn, without measuring it again.
inline bool drawTextCenteredEllipsized(DisplayDriver& display,
const DisplayRegion& region, int y,
const char* text) {
if (text == nullptr || text[0] == 0 || region.width <= 0) return;
if (text == nullptr || text[0] == 0 || region.width <= 0) return false;
const int text_width = display.getTextWidth(text);
if (text_width <= region.width) {
display.setCursor(region.x + (region.width - text_width) / 2, y);
display.print(text);
return true;
} else {
display.drawTextEllipsized(region.x, y, region.width, text);
return false;
}
}
@@ -196,8 +199,9 @@ public:
// including native 160x80 T096 and 250x122 MeshPocket panels. The caller must
// not draw ordinary instructions/network rows in this same area.
// Return true only when the complete value fits and was drawn.
inline bool drawBottomPairingBlock(DisplayDriver& display, int content_top,
const char* label, const char* value) {
// Keep this layout separate from the large home renderer to reduce flash use.
__attribute__((noinline)) inline bool drawBottomPairingBlock(
DisplayDriver& display, int content_top, const char* label, const char* value) {
const int bottom = display.height() - (display.height() > 64 ? 2 : 0);
const int available = bottom - content_top;
const int margin = display.width() >= 16 ? 4 : 0;
@@ -227,8 +231,7 @@ inline bool drawBottomPairingBlock(DisplayDriver& display, int content_top,
drawTextCenteredEllipsized(display, region, region.y, label);
}
display.setTextSize(value_size);
drawTextCenteredEllipsized(display, region, bottom - value_height, value);
return display.getTextWidth(value) <= width;
return drawTextCenteredEllipsized(display, region, bottom - value_height, value);
}
} // namespace ui
+5 -2
View File
@@ -250,10 +250,12 @@ int main() {
#define PRESS_LABEL "Press"
int UITask::getPreviewCount() const { return 12; }
const char* UITask::inboxTitle() const { return "HISTORY"; }
void renderHome(DisplayDriver& display, UITask* _task) {
bool renderHome(DisplayDriver& display, UITask* _task) {
bool _pairing_pin_visible = false;
char tmp[80];
const int body_top = 14;
'''+ first_page + r'''
return _pairing_pin_visible;
}
struct MeasuredDisplay : Display {
int size = 1;
@@ -276,7 +278,8 @@ int main() {
MeasuredDisplay display(dims.first, dims.second);
UITask task(display);
task._msgcount = 0; task.connected = true; task.client = client;
renderHome(display, &task);
const bool pairing_pin_visible = renderHome(display, &task);
assert(pairing_pin_visible == display.contains("123456"));
assert(display.contains("HISTORY: 12"));
assert(display.contains("Pending: 0"));
if (task.hasBluetoothConnection()) {