diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index a0fa3edb..7b26b8b0 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -50,7 +50,14 @@ #define UI_RECENT_LIST_SIZE 4 #endif -#if UI_HAS_JOYSTICK +// The sim's D-pad + dedicated OK/Enter key behaves like a joystick board +// (a short Enter press opens Settings/Tools/Messages -- see the +// KEY_ENTER && _page==... handlers below; holding it separately reaches +// KEY_CONTEXT_MENU via handleLongPress(), same as a real joystick board's +// long-press) -- without SIM_PLATFORM here, this would fall to the +// touchscreen-board wording below, which describes a different, and for +// this input method simply wrong, interaction. +#if UI_HAS_JOYSTICK || defined(SIM_PLATFORM) #define PRESS_LABEL "press Enter" #else #define PRESS_LABEL "long press" diff --git a/variants/sim/SimDisplayDriver.h b/variants/sim/SimDisplayDriver.h index e4efc3a8..bc04a48b 100644 --- a/variants/sim/SimDisplayDriver.h +++ b/variants/sim/SimDisplayDriver.h @@ -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 diff --git a/variants/sim/target.cpp b/variants/sim/target.cpp index 4bb87acc..c8922fea 100644 --- a/variants/sim/target.cpp +++ b/variants/sim/target.cpp @@ -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