Skip to content

micro:bit: starter programs in the learner's microbit folder - #49

Merged
evangress merged 2 commits into
masterfrom
feature/microbit-examples
Nov 14, 2026
Merged

evangress merged 2 commits into
masterfrom
feature/microbit-examples

Conversation

@evangress

Copy link
Copy Markdown

Summary

Gives a learner something to start from in micro:bit mode. Pygame Zero already copies demo assets into the workspace on first use; micro:bit mode gave an empty folder.

  • Six starter programs in nu_microbit/examples/, each with a header saying what it does and what to try:
  • All six use only V1-and-V2 APIs.
  • MicrobitMode.ensure_workspace_assets copies them into <workspace>/microbit/examples the first time the mode is used. An existing folder is left alone, so the learner's edits and deletions stick.
  • A test parses every example and checks each name it takes from from microbit import * is one the micro:bit has (the mode's star_imports list).
  • The examples are excluded from ruff, because they're MicroPython for the board. They ship in the wheel (checked).
  • docs/microbit.md gets a table of the examples. README, TODO.md and CHANGES.md updated.
  • Also re-checked: the pinned firmware (V2 2.1.2, V1 1.1.1) is still the newest release of each.

Independent of #48, though score_keeper.py's header and the docs mention Files, so it reads best merged after it.

Tested

  • Windows 11: full suite 1781 passed, 20 skipped; ruff and mkdocs build --strict clean.
  • The built wheel contains nu_microbit/examples/*.py.
  • Not run on a micro:bit. The APIs used are the documented ones (display, Image.HEART_SMALL, button_*.was_pressed, accelerometer.was_gesture("shake"), open() on the board's file system).

🤖 Generated with Claude Code

evangress and others added 2 commits November 14, 2026 10:44
Six short examples for V1 and V2 (hello, buttons, heartbeat, dice,
tilt_plot for the Plotter, score_keeper saving a file on the board),
copied into <workspace>/microbit/examples by ensure_workspace_assets the
first time micro:bit mode is used; an existing folder is left alone. A
test checks every name each takes from `microbit` is one the micro:bit
has. Documented in docs/microbit.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…amples

# Conflicts:
#	plugins/microbit/README.md
@evangress
evangress merged commit 95400dd into master Nov 14, 2026
11 checks passed
@evangress
evangress deleted the feature/microbit-examples branch November 14, 2026 16:14
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