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:
@@ -75,6 +75,20 @@ inline long random(long howsmall, long howbig) {
|
||||
#ifndef PROGMEM
|
||||
#define PROGMEM
|
||||
#endif
|
||||
// Real pgm_read_*() on a native host is just a plain dereference -- there's
|
||||
// no separate flash address space to special-case. Needed once Adafruit_GFX
|
||||
// + MiscFixedFont.h (variants/sim/thirdparty/gfx/, src/helpers/ui/) entered
|
||||
// the sim build; nothing before that read PROGMEM data at all (see this
|
||||
// file's own header comment).
|
||||
#ifndef pgm_read_byte
|
||||
#define pgm_read_byte(addr) (*(const uint8_t*)(addr))
|
||||
#endif
|
||||
#ifndef pgm_read_word
|
||||
#define pgm_read_word(addr) (*(const uint16_t*)(addr))
|
||||
#endif
|
||||
#ifndef pgm_read_dword
|
||||
#define pgm_read_dword(addr) (*(const uint32_t*)(addr))
|
||||
#endif
|
||||
#ifndef F
|
||||
#define F(x) (x)
|
||||
#endif
|
||||
@@ -142,6 +156,29 @@ inline void yield() { }
|
||||
// declares cleanly, exactly like on a real board.
|
||||
class __FlashStringHelper;
|
||||
|
||||
// Adafruit_GFX.h declares a getTextBounds(const String&, ...) overload
|
||||
// (variants/sim/thirdparty/gfx/) -- MeshCore's own app code never
|
||||
// constructs or passes a real Arduino String anywhere (this file's own
|
||||
// header comment), so this exists purely to satisfy that one declaration's
|
||||
// compile, not to be a real String replacement.
|
||||
#include <string>
|
||||
class String {
|
||||
std::string _s;
|
||||
public:
|
||||
String(const char* s = "") : _s(s ? s : "") {}
|
||||
const char* c_str() const { return _s.c_str(); }
|
||||
size_t length() const { return _s.length(); }
|
||||
};
|
||||
|
||||
// Real Arduino cores define these; Adafruit_GFX.cpp's drawArc() uses
|
||||
// radians(). Same DEG_TO_RAD/RAD_TO_DEG constants as the real macros.
|
||||
#ifndef radians
|
||||
#define radians(deg) ((deg) * 0.017453292519943295)
|
||||
#endif
|
||||
#ifndef degrees
|
||||
#define degrees(rad) ((rad) * 57.29577951308232)
|
||||
#endif
|
||||
|
||||
// --- Serial -------------------------------------------------------------
|
||||
// Only ever used for Serial.begin() (main.cpp, ignored) and MyMesh.cpp's
|
||||
// CLI-rescue debug command handler (Serial.print/println/printf as output,
|
||||
|
||||
Reference in New Issue
Block a user