fix(sim): white-on-black display palette instead of amber

Real SSD1306/SH1106 OLEDs this sim mirrors are monochrome white-on-black,
not amber -- swap the canvas fillStyle/strokeStyle from #ffb000 to #fff
everywhere the sim display driver blits lit pixels.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018iubftDmKNWmkNnhJRz8UH
This commit is contained in:
Jakub
2026-09-03 23:05:04 +02:00
co-authored by Claude Sonnet 5
parent 1eb088a0db
commit f8ab4c3a98
2 changed files with 11 additions and 10 deletions
+9 -8
View File
@@ -258,11 +258,12 @@ public:
// real board it's mirroring.
bool isSingleFont() const override { return true; }
// 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
// comment: "on b/w screen, colors will be !=0 synonym of light").
static const char* jsColor(Color c) { return c == DARK ? "#000" : "#ffb000"; }
// White-on-black palette (matches a real monochrome SSD1306/SH1106 OLED)
// 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 comment: "on b/w screen, colors will be
// !=0 synonym of light").
static const char* jsColor(Color c) { return c == DARK ? "#000" : "#fff"; }
// 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),
@@ -295,7 +296,7 @@ public:
void fillRect(int x, int y, int w, int h) override {
EM_ASM({
if (!Module.__simCtx) return;
Module.__simCtx.fillStyle = UTF8ToString($4) === 'L' ? '#ffb000' : '#000';
Module.__simCtx.fillStyle = UTF8ToString($4) === 'L' ? '#fff' : '#000';
Module.__simCtx.fillRect($0, $1, $2, $3);
}, x, y, w, h, (_color != DARK) ? "L" : "D");
}
@@ -304,7 +305,7 @@ public:
EM_ASM({
if (!Module.__simCtx) return;
var ctx = Module.__simCtx;
ctx.strokeStyle = UTF8ToString($4) === 'L' ? '#ffb000' : '#000';
ctx.strokeStyle = UTF8ToString($4) === 'L' ? '#fff' : '#000';
ctx.lineWidth = 1;
ctx.strokeRect($0 + 0.5, $1 + 0.5, $2 - 1, $3 - 1);
}, x, y, w, h, (_color != DARK) ? "L" : "D");
@@ -329,7 +330,7 @@ public:
var bits = $4;
var lit = UTF8ToString($5) === 'L';
var widthInBytes = (w + 7) >> 3;
ctx.fillStyle = lit ? '#ffb000' : '#000';
ctx.fillStyle = lit ? '#fff' : '#000';
for (var ry = 0; ry < h; ry++) {
for (var rx = 0; rx < w; rx++) {
var byteOff = bits + ry * widthInBytes + (rx >> 3);
+2 -2
View File
@@ -123,7 +123,7 @@ void SimDisplayDriverCanvas::print(const char* str) {
gfx.resetDirty();
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
// white/black choice is applied once at blit time below, from _color, same
// 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
@@ -141,7 +141,7 @@ void SimDisplayDriverCanvas::print(const char* str) {
if (!Module.__simCtx) return;
var ctx = Module.__simCtx;
var buf = $0;
ctx.fillStyle = UTF8ToString($5) === 'L' ? '#ffb000' : '#000';
ctx.fillStyle = UTF8ToString($5) === 'L' ? '#fff' : '#000';
for (var y = $2; y <= $4; y++) {
for (var x = $1; x <= $3; x++) {
if (HEAPU8[buf + y * 128 + x]) ctx.fillRect(x, y, 1, 1);