Files
python-editor/lib/machine.py
Jimmy a2318f2244 Ship MicroPython stubs from repo lib/ and seed workspace lib on startup
Move machine.py and neopixel.py into a tracked /lib/ at the repo root and
auto-copy them into WORKSPACE_ROOT/lib whenever files are missing, so empty
volumes and fresh per-user workspaces always have the read-only stubs
available to Jedi and Pyodide. Allow all users to browse lib/ in the UI
(writes still gated by the API), and add tests covering initial seeding
and re-population after the dir is wiped.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 02:59:34 +12:00

20 lines
492 B
Python

"""Minimal MicroPython-style machine module mock for browser simulation."""
class Pin:
IN = 0
OUT = 1
PULL_UP = 2
PULL_DOWN = 3
def __init__(self, pin_id: int, mode: int = OUT, value: int = 0):
self.id = int(pin_id)
self.mode = int(mode)
self._value = 1 if value else 0
def value(self, new_value=None):
if new_value is None:
return self._value
self._value = 1 if int(new_value) else 0
return self._value