Skip to content

Simulator LEDs look like light; the REPL's arrows recall one clean line - #128

Merged
david-firia merged 2 commits into
mainfrom
sim-leds-terminal
Nov 25, 2026
Merged

david-firia merged 2 commits into
mainfrom
sim-leds-terminal

Conversation

@david-firia

Copy link
Copy Markdown
Contributor

LEDs in the simulator (CodeBot, CodeX, CodeAIR)

A lit LED or NeoPixel was a coloured box with a little glow. Now its body is the light alone (no painted colour), a little see-through, run hotter than full toward white with its hue kept, and its glow is stronger and wider.

The look is a set of numbers per board, LOOK_DEFAULTS in src/sim/view/led.js. A hidden panel sets them live:

  • Open it with ?tune=leds in the address, or Ctrl+Alt+Shift+L with the simulator showing (the same keys close it).
  • Sliders: body colour, emissive, body opacity, glow strength, glow size; checkboxes for an additive glow and tone mapping.
  • "Light them all" runs a program that lights every LED on CodeBot or CodeX.
  • Every board's numbers show as JSON: copy them to make them the defaults, or paste numbers in to set them. Kept in this browser, used only while the panel is open; closing it puts the defaults back.

The terminal

  • Colours were already drawn by xterm.js (16 and 256 colour, bold, reset). The stray characters were the REPL bug below.
  • History with the arrows. MicroPython's event-driven REPL, the one the simulator runs, took any key that left an empty line empty as Enter, an arrow's escape sequence part way included: Up printed a second prompt and then [A as text. sim/runtime/shared.patch makes it wait for the rest of the sequence; both runtimes are rebuilt. The page also feeds the REPL one character at a time, in order.
  • Long lines. Recalling a line longer than the terminal is wide redrew it on one row (the prompt overwritten, old text left below). The terminal now turns the line editor's cursor-left and erase-line into codes that step back over wrapped rows (src/ui/line-edits.js), so this holds on a board over Web Serial too. It loads with the first thing a board says, keeping the first visit within its 600 KB budget.

Tests

  • tests/terminal.mjs: the line-edit rewriting.
  • tests/sim-ui.mjs: colours drawn, Up and Down through history (a wrapped line included), no stray characters or second prompt, a pasted run of commands.
  • tests/sim.mjs: the runtimes match shared.patch; a lit NeoPixel keeps its hue, full and hotter.

🤖 Generated with Claude Code

david-firia and others added 2 commits November 24, 2026 19:48
MicroPython's event-driven REPL (the simulator's) took any key that left
an empty line empty as Enter, an arrow's escape sequence part way
included, so Up printed a second prompt and the rest of the sequence as
text. shared.patch waits for the rest of the sequence; both runtimes are
rebuilt. The page feeds the REPL one character at a time, in order.

A recalled line longer than the terminal is wide was redrawn on one row:
the terminal now turns the line editor's cursor-left and erase-line into
backspaces with reverse wraparound and erase-below (line-edits.js), so it
redraws over the wrapped rows, on a board too. It loads with the first
thing a board says, off the first visit's budget.

Colours were already drawn by xterm.js; the stray characters were the
REPL bug.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lit LED or NeoPixel is its light alone, a little see-through, hotter
than full toward white with its hue kept, with a stronger, wider glow.
The look is a set of numbers per board (LOOK_DEFAULTS in led.js); a
hidden panel sets them live (?tune=leds, or Ctrl+Alt+Shift+L), lights
every LED on the board, and shows the numbers as JSON to copy back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 3008f4d):

https://firialabs-open-editor--pr128-sim-leds-terminal-hmv02ktr.web.app

(expires Wed, 02 Dec 2026 02:04:49 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 81259a1fec315ca1af3747d225d9c7424890be3e

@david-firia
david-firia merged commit 716a23a into main Nov 25, 2026
4 checks 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.

1 participant