Skip to content

Implement Desktop MJS simulator bridges - #277

Merged
jblanked merged 3 commits into
jblanked:devfrom
Slasher006:fix/desktop-mjs-stubs
Sep 4, 2026
Merged

Implement Desktop MJS simulator bridges#277
jblanked merged 3 commits into
jblanked:devfrom
Slasher006:fix/desktop-mjs-stubs

Conversation

@Slasher006

Copy link
Copy Markdown
Contributor

Summary

  • implement the Desktop native MJS bridge stubs for audio, Bluetooth, draw, HTTP, PSRAM, settings, storage, and WebSocket modules
  • keep simulator fallback behavior aligned with the native bridge, including storage chunk offsets and offline HTTP/WebSocket fixtures
  • add native Desktop and simulator MJS parity checks

Validation

  • PicoCalc Pico 2W firmware built and flashed
  • on-device MJS smoke test passed
  • Desktop native MJS check passed
  • MicroPython simulator shim MJS check passed
  • 30-frame headless Desktop runtime smoke passed

The broader simulator suite still has the separate pre-existing Library route-map mismatch for C/FlipSocial/Infrared.

Comment thread src/MicroPython/mjs/lib/lcd.c Outdated
void lcd_js_screenshot(struct mjs *mjs)
{
#ifdef LCD_MP_READ_ROW
#ifdef DESKTOP

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use LCD_MP_READ_ROW. a desktop version of that is better than implementing a separate approach

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am on it

Comment thread simulator/hardware/mjs.py Outdated
Comment on lines +473 to +517

def display():
value = sim_runtime.get_lcd()
return value if value is not None else lcd.LCD()

def draw_color(value):
if isinstance(value, str):
value = value.strip()
if value.startswith("#"):
value = value[1:]
elif value.lower().startswith("0x"):
value = value[2:]
try:
return int(value, 16)
except ValueError:
return 0
return int(value)

def draw_method(name, color_index=None):
def call(*args):
values = list(args)
if color_index is not None:
while len(values) <= color_index:
values.append(0xFFFF)
values[color_index] = draw_color(values[color_index])
return getattr(display(), "_" + name)(*values)

return call

methods = {
"char": ("char", 3),
"circle": ("circle", 3),
"clear": ("clear", 0),
"fillCircle": ("fill_circle", 3),
"fillRectangle": ("fill_rectangle", 4),
"fillRoundRectangle": ("fill_round_rectangle", 5),
"fillTriangle": ("fill_triangle", 6),
"line": ("line", 4),
"pixel": ("pixel", 2),
"rectangle": ("rectangle", 4),
"text": ("text", 3),
"triangle": ("triangle", 6),
}
for js_name, (name, color_index) in methods.items():
module[js_name] = draw_method(name, color_index)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the MJS c module

if self._fixture:
if self._websocket:
self._response += _websocket_frames(data)
self._request += data

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this file, just use the Picoware class

@jblanked
jblanked merged commit 6fdce88 into jblanked:dev Sep 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants