fix(sim): real text-size scaling + correct joystick-board menu hint

Two more real-vs-sim mismatches, found after seeing the rendered UI:

1. The Clock screen's big time display (setTextSize(2)) rendered at size 1
   -- SimDisplayDriverCanvas ignored setTextSize() entirely (a leftover
   no-op from the old system-font renderer) and never overrode
   getCharWidth()/getLineHeight(), so the big-digit layout math in
   UITask.cpp's drawBig() came out wrong even once print() itself gained
   real font support. Track _text_sz, scale both metrics by it (matching
   SSD1306Display's own getCharWidth()==6*_text_sz pattern), and pass it
   through to miscFixedPrint() in target.cpp instead of a hardcoded 1.

2. The Home carousel's "<PRESS_LABEL> to open" hint said "long press to
   open" -- true only for touchscreen-only boards with no dedicated Enter
   button (PRESS_LABEL's #if UI_HAS_JOYSTICK / #else split in
   examples/companion_radio/ui-new/UITask.cpp). The sim's D-pad + OK key
   behaves like a joystick board (a SHORT Enter press opens each page;
   holding it separately reaches the real context menu via
   handleLongPress()), so showing the touchscreen wording was both
   inaccurate and different from what a real joystick board like Heltec V3
   displays. Added SIM_PLATFORM to that #if alongside UI_HAS_JOYSTICK --
   UI_HAS_JOYSTICK itself stays unset, since its other two gates
   (begin()-ing/polling real joystick MomentaryButton objects) need
   hardware the sim's target.cpp doesn't declare.

Verified in real Chromium: Clock screen shows "08:11:10" at real double
size above the normal-size date line; Home carousel now says "press Enter
to open". Full regression clean: 3 native envs, wasm companion_radio, the
2-instance+repeater mesh demo, and the long-press context-menu test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-09-03 10:12:31 +02:00
co-authored by Claude Sonnet 5
parent 725e3b715e
commit d7242ddc21
3 changed files with 26 additions and 4 deletions
+13 -1
View File
@@ -196,6 +196,7 @@ class SimDisplayDriverCanvas : public DisplayDriver {
bool _on = false;
int _cursor_x = 0, _cursor_y = 0;
Color _color = LIGHT;
int _text_sz = 1;
public:
SimDisplayDriverCanvas() : DisplayDriver(128, 64) { }
@@ -234,10 +235,21 @@ public:
});
}
void setTextSize(int sz) override { /* one fixed size, like the native ASCII backend */ }
void setTextSize(int sz) override { _text_sz = sz; }
void setColor(Color c) override { _color = c; }
void setCursor(int x, int y) override { _cursor_x = x; _cursor_y = y; }
// MiscFixed's real metrics (6px advance, 9px row height -- see
// src/helpers/ui/MiscFixedFont.h), scaled by the current text size, same
// as a real board's SSD1306Display::getCharWidth()/getLineHeight() do.
// DisplayDriver.h's own defaults (6/8, unscaled) would make the Clock
// screen's setTextSize(2)/(4) big-digit layout math (drawBig()'s width
// centring, line spacing) come out wrong -- half-size digits crowded on
// top of each other -- even though print() itself renders them at the
// right size once _text_sz reaches it (see target.cpp).
int getCharWidth() const override { return 6 * _text_sz; }
int getLineHeight() const override { return 9 * _text_sz; }
// Amber-on-black palette (a common OLED look) for LIGHT/DARK; the other
// Color enumerators (RED/GREEN/BLUE/YELLOW/ORANGE) aren't used on the real
// monochrome OLED boards this sim mirrors either (DisplayDriver.h's own
+5 -2
View File
@@ -69,8 +69,11 @@ void SimDisplayDriverCanvas::print(const char* str) {
gfx.setCursor(_cursor_x, _cursor_y);
// color arg is just our own internal "lit" marker (1) -- the real on-screen
// amber/black choice is applied once at blit time below, from _color, same
// as every other primitive in this class.
miscFixedPrint(gfx, str, 1, 1);
// as every other primitive in this class. sz is the real current text
// size (set via setTextSize(), e.g. the Clock screen's big digits) --
// miscFixedPrint()/miscFixedDrawGlyph() scale both the glyph pixels and
// the advance width by it already.
miscFixedPrint(gfx, str, _text_sz, 1);
// startFrame() already blanks the whole canvas to black every frame, so
// only the lit pixels need drawing here -- unlit buffer cells are already