Repository navigation
A MicroPython / CircuitPython board in the device picker - #122
Merged
Merged
Conversation
…ith a Python prompt Picked, Connect lists every serial port and the board is the `generic` target. Its banner says which Python it speaks (src/device/flavor.js), and the blocks write that one; before a board is connected it is MicroPython, or what the student set in the device menu's switch. - Run sends the program through the raw REPL and runs it there: nothing is written to main.py or code.py, so the board's own program stays and a read-only CircuitPython drive is no obstacle. Stop is Ctrl-C. The terminal shows the program's output without the raw REPL's markers, and the Firia debug filter is off for it. - A Pins palette section of four blocks: set a pin, read a pin (pulled up), read an analog pin, milliseconds since start. MicroPython writes machine.Pin / ADC / time.ticks_ms; CircuitPython board / digitalio / analogio / time.monotonic, each pin claimed once after the imports. Python back to blocks reads those setup lines as the blocks' own. - On MicroPython, seconds since start is time.ticks_ms() / 1000 and Title Case is written out (it has neither time.monotonic nor str.title). - Blink and button examples; the simulator says it has no such board. - writeFile now reports a file that will not open (OSError 30 on a read-only drive) instead of the NameError after it, and error text drops the raw REPL's markers. Tests: generic-board.mjs (the DeviceManager against a scripted MicroPython and CircuitPython REPL), generic-ui.mjs (loopback as a generic board), and round-trip.mjs now covers the generic palette in both flavors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o copies to the board, flavor before the first Run
- Stop while a program is still being sent to the raw REPL stops the
sending first; before, the rest arrived at the prompt Stop left and the
final Ctrl-D soft-reset the board (tests/generic-board.mjs fails on the
parent).
- Each pin is claimed once, after the imports, in both flavors: a pin set
anywhere is an output and reading it reads back its value (a toggle works);
a pin only read is a pulled-up input. Before, a pin set and read was
claimed twice ("in use" on CircuitPython) or turned into an input
(MicroPython). Numbered MicroPython pins now come back from Python as
blocks too.
- Run copies none of the program's other .py files to a generic board: its
files are the student's own, and a CircuitPython drive is read-only to code.
A toast says so, once.
- A board busy with its own program when connected is stopped and asked
which Python it speaks before the first Run writes its program.
- The program is sent in byte pieces, so no character is cut in two.
- A setup line whose object and pin differ is the student's own, kept as
Python.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Visit the preview URL for this PR (updated for commit eb95421): https://firialabs-open-editor--pr122-generic-micropython-rcgjjg8v.web.app (expires Mon, 30 Nov 2026 19:52:26 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 81259a1fec315ca1af3747d225d9c7424890be3e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
One new entry in the device picker, MicroPython / CircuitPython board, for any board with a Python prompt over USB (a Raspberry Pi Pico, an ESP32, an Adafruit board). It makes "CodeBot, CodeX, CodeAIR, and more!" true.
generictarget.mpremote rundoes: nothing is written tomain.pyorcode.py(the board's own program stays; a read-only CircuitPython drive is no obstacle). Stop is Ctrl-C. Stop during sending stops the sending first. The terminal shows the program's output without the raw REPL's markers; the Firia debug filter is off for it. The program's other.pyfiles are not copied to the board (its files are the student's own, such as a driver orconfig.py, and a CircuitPython drive is read-only to code); a toast says so once.pin_LED.value(True)(setuppin_LED = Pin('LED', Pin.OUT))pin_LED.value = True(setupDigitalInOut(board.LED),switch_to_output())pin_GP14.value()pin_GP14.valueadc_GP26.read_u16()(setupADC(Pin('GP26')))adc_A0.value(setupAnalogIn(board.A0))time.ticks_ms()int(time.monotonic() * 1000)time.ticks_ms() / 1000and Title Case is written out: MicroPython has neithertime.monotonicnorstr.title.Also
Repl.writeFilenow reports a file that will not open (OSError: [Errno 30]) instead of theNameErrorthat followed it, and error text drops the raw REPL's markers. This touches the Firia boards' companion copy path too.Independent review
A reviewer subagent read the diff. Fixed from it: Stop during sending (the rest of the program reached the friendly prompt and the final Ctrl-D soft-reset the board; the new test fails on the parent commit), a pin set and read claimed twice, companion copies overwriting a student's own board files, the first Run on a busy board written in the wrong flavor, a character cut between pieces, and a setup line naming a different pin misread. Left: one pin used both digitally and as analog is claimed twice (CircuitPython refuses); noted in the README.
Tests
tests/generic-board.mjs: the DeviceManager against a scripted REPL in both flavors: banner sets the flavor, Run uses the raw REPL and writes no file, output without markers, an error's line, Stop on a forever program, a long program arrives whole, read-only drive message.tests/generic-ui.mjs: loopback as a generic board: picker, switch, Pins in both palettes, the Python per flavor and back, flavor following a CircuitPython banner, Run, a student's own block, the wrong-board check, examples, no simulator.tests/round-trip.mjscovers the generic palette in both flavors (80 block and choice pairs each).Not tested on hardware
No MicroPython board is on a bench, and bench1 has no CodeX or CodeAIR attached, so neither flavor has run on a real board yet. In particular: the raw REPL run and Stop on a real MicroPython (Pico) and CircuitPython board, and the
writeFilechange on a Firia board's companion copy.🤖 Generated with Claude Code