mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-09-14 15:16:40 +00:00
feat(sim): long-press context menu + pixel-perfect real font rendering
Two prototype polish fixes ahead of the website embed work: 1. Holding Enter (the sim's main way into "the rest of the options") did nothing -- the JS bridge's sim_enqueue_key() went straight to enqueueKey(), bypassing UITask::handleLongPress() entirely, so KEY_CONTEXT_MENU could never be reached. Add injectSimKeyLongPress()/ sim_enqueue_key_longpress(), which does route through the real handleLongPress() (same code a real MomentaryButton(pin, 1000, ...) reaches), and wire up press-and-hold (buttons + Enter/Space key) in both web harnesses with the same 1000ms threshold real hardware uses. 2. SimDisplayDriverCanvas::print() drew text with the browser's own system font (ctx.fillText, '8px monospace') instead of the real bitmap font a MeshCore-Solo board renders with OLED_MISC_FIXED_FONT=1 (see solo/heltec_v3/platformio.ini). Vendor the real Adafruit_GFX (unmodified, from the same PlatformIO registry package a real board build pulls) into variants/sim/thirdparty/gfx/, and render print() through the real, shared src/helpers/ui/MiscFixedRenderer.h + MiscFixedFont.h -- byte- identical glyphs to real hardware, not a look-alike. Verified in a real Chromium (Playwright): short Enter -> "CLOCK TOOLS", held Enter -> "CLOCK FIELDS" (gotoDashboardConfig(), proving KEY_CONTEXT_MENU is really reached); font renders as hard square pixels, inverse/selected-row text still punches correctly through a filled bar. Full regression re-run clean: all 3 native envs, wasm companion_radio, and the two-instance + repeater mesh demo (relay routing, DM delivery). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -244,32 +244,13 @@ public:
|
||||
// comment: "on b/w screen, colors will be !=0 synonym of light").
|
||||
static const char* jsColor(Color c) { return c == DARK ? "#000" : "#ffb000"; }
|
||||
|
||||
void print(const char* str) override {
|
||||
if (!str) return;
|
||||
EM_ASM({
|
||||
if (!Module.__simCtx) return;
|
||||
var ctx = Module.__simCtx;
|
||||
ctx.fillStyle = UTF8ToString($3) === 'L' ? '#ffb000' : '#000';
|
||||
ctx.font = '8px monospace';
|
||||
ctx.textBaseline = 'top';
|
||||
// Advance width is fixed (getCharWidth()==6, DisplayDriver.h default) --
|
||||
// draw one character per cell so glyph spacing matches the layout math
|
||||
// every screen already does off getTextWidth()'s strlen()*6 estimate,
|
||||
// instead of leaving it to the font's own (proportional) metrics.
|
||||
// NB: EM_ASM's argument-splitting only understands parens, not
|
||||
// braces -- an unparenthesized top-level comma (e.g. a multi-name
|
||||
// `var a, b;`) gets misread as separating this macro's own C++
|
||||
// arguments and breaks the whole block. Every declaration below is
|
||||
// therefore its own separate `var` statement.
|
||||
var s = UTF8ToString($0);
|
||||
var x = $1;
|
||||
var y = $2;
|
||||
for (var i = 0; i < s.length; i++) {
|
||||
ctx.fillText(s[i], x + i * 6, y);
|
||||
}
|
||||
}, str, _cursor_x, _cursor_y, (_color != DARK) ? "L" : "D");
|
||||
_cursor_x += getTextWidth(str);
|
||||
}
|
||||
// Real bitmap-font rendering (byte-identical glyphs to a real MeshCore-Solo
|
||||
// board with OLED_MISC_FIXED_FONT=1 -- see solo/heltec_v3/platformio.ini),
|
||||
// not the browser's own system font -- defined out-of-line in target.cpp,
|
||||
// the one Emscripten-only translation unit allowed to pull in
|
||||
// MiscFixedRenderer.h (its own header comment: including it from more than
|
||||
// one .cpp would duplicate the font's static const tables in each).
|
||||
void print(const char* str) override;
|
||||
|
||||
void fillRect(int x, int y, int w, int h) override {
|
||||
EM_ASM({
|
||||
|
||||
Reference in New Issue
Block a user