mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-09-14 15:16:40 +00:00
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:
@@ -258,11 +258,12 @@ public:
|
|||||||
// real board it's mirroring.
|
// real board it's mirroring.
|
||||||
bool isSingleFont() const override { return true; }
|
bool isSingleFont() const override { return true; }
|
||||||
|
|
||||||
// Amber-on-black palette (a common OLED look) for LIGHT/DARK; the other
|
// White-on-black palette (matches a real monochrome SSD1306/SH1106 OLED)
|
||||||
// Color enumerators (RED/GREEN/BLUE/YELLOW/ORANGE) aren't used on the real
|
// for LIGHT/DARK; the other Color enumerators (RED/GREEN/BLUE/YELLOW/
|
||||||
// monochrome OLED boards this sim mirrors either (DisplayDriver.h's own
|
// ORANGE) aren't used on the real monochrome OLED boards this sim mirrors
|
||||||
// comment: "on b/w screen, colors will be !=0 synonym of light").
|
// either (DisplayDriver.h's own comment: "on b/w screen, colors will be
|
||||||
static const char* jsColor(Color c) { return c == DARK ? "#000" : "#ffb000"; }
|
// !=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
|
// 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),
|
// 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 {
|
void fillRect(int x, int y, int w, int h) override {
|
||||||
EM_ASM({
|
EM_ASM({
|
||||||
if (!Module.__simCtx) return;
|
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);
|
Module.__simCtx.fillRect($0, $1, $2, $3);
|
||||||
}, x, y, w, h, (_color != DARK) ? "L" : "D");
|
}, x, y, w, h, (_color != DARK) ? "L" : "D");
|
||||||
}
|
}
|
||||||
@@ -304,7 +305,7 @@ public:
|
|||||||
EM_ASM({
|
EM_ASM({
|
||||||
if (!Module.__simCtx) return;
|
if (!Module.__simCtx) return;
|
||||||
var ctx = Module.__simCtx;
|
var ctx = Module.__simCtx;
|
||||||
ctx.strokeStyle = UTF8ToString($4) === 'L' ? '#ffb000' : '#000';
|
ctx.strokeStyle = UTF8ToString($4) === 'L' ? '#fff' : '#000';
|
||||||
ctx.lineWidth = 1;
|
ctx.lineWidth = 1;
|
||||||
ctx.strokeRect($0 + 0.5, $1 + 0.5, $2 - 1, $3 - 1);
|
ctx.strokeRect($0 + 0.5, $1 + 0.5, $2 - 1, $3 - 1);
|
||||||
}, x, y, w, h, (_color != DARK) ? "L" : "D");
|
}, x, y, w, h, (_color != DARK) ? "L" : "D");
|
||||||
@@ -329,7 +330,7 @@ public:
|
|||||||
var bits = $4;
|
var bits = $4;
|
||||||
var lit = UTF8ToString($5) === 'L';
|
var lit = UTF8ToString($5) === 'L';
|
||||||
var widthInBytes = (w + 7) >> 3;
|
var widthInBytes = (w + 7) >> 3;
|
||||||
ctx.fillStyle = lit ? '#ffb000' : '#000';
|
ctx.fillStyle = lit ? '#fff' : '#000';
|
||||||
for (var ry = 0; ry < h; ry++) {
|
for (var ry = 0; ry < h; ry++) {
|
||||||
for (var rx = 0; rx < w; rx++) {
|
for (var rx = 0; rx < w; rx++) {
|
||||||
var byteOff = bits + ry * widthInBytes + (rx >> 3);
|
var byteOff = bits + ry * widthInBytes + (rx >> 3);
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ void SimDisplayDriverCanvas::print(const char* str) {
|
|||||||
gfx.resetDirty();
|
gfx.resetDirty();
|
||||||
gfx.setCursor(_cursor_x, _cursor_y);
|
gfx.setCursor(_cursor_x, _cursor_y);
|
||||||
// color arg is just our own internal "lit" marker (1) -- the real on-screen
|
// 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
|
// 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) --
|
// size (set via setTextSize(), e.g. the Clock screen's big digits) --
|
||||||
// miscFixedPrint()/miscFixedDrawGlyph() scale both the glyph pixels and
|
// miscFixedPrint()/miscFixedDrawGlyph() scale both the glyph pixels and
|
||||||
@@ -141,7 +141,7 @@ void SimDisplayDriverCanvas::print(const char* str) {
|
|||||||
if (!Module.__simCtx) return;
|
if (!Module.__simCtx) return;
|
||||||
var ctx = Module.__simCtx;
|
var ctx = Module.__simCtx;
|
||||||
var buf = $0;
|
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 y = $2; y <= $4; y++) {
|
||||||
for (var x = $1; x <= $3; x++) {
|
for (var x = $1; x <= $3; x++) {
|
||||||
if (HEAPU8[buf + y * 128 + x]) ctx.fillRect(x, y, 1, 1);
|
if (HEAPU8[buf + y * 128 + x]) ctx.fillRect(x, y, 1, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user