A convention badge for the Pimoroni Tufty 2040
  • Python 98%
  • Makefile 2%
Find a file
2026-08-27 18:38:53 +02:00
art feat: pretty icons 2026-08-18 22:55:50 +02:00
badges feat: pretty icons 2026-08-18 22:55:50 +02:00
src feat: improved battery logging 2026-08-27 18:32:34 +02:00
tests feat: improved battery logging 2026-08-27 18:32:34 +02:00
tools feat: improved battery logging 2026-08-27 18:32:34 +02:00
.gitignore feat: improved battery logging 2026-08-27 18:32:34 +02:00
Makefile feat: badge layouts 2026-08-17 23:56:54 +02:00
openapi.json feat: convention map 2026-08-17 20:10:40 +02:00
pyproject.toml tests: Add unit tests 2026-08-17 12:29:43 +02:00
README.md docs: Add README.md 2026-08-27 18:38:53 +02:00
uv.lock feat: Initial commit 2026-08-16 21:15:15 +02:00

tuftybadge

A convention badge for the Pimoroni Tufty 2040 — a name badge, the convention schedule, a floorplan of the venue, and the handful of small things that make a badge worth wearing all week.

MicroPython, no networking on the device: everything that needs the internet happens on the host at build time and ships as packed binary in assets/.

Apps

Badge Name, pronouns, avatar, pride flags, status band
QR Whatever URL your badge.toml names
Gallery Your art, scrolling grid plus a full-screen viewer
Clock Big enough to read across a room, and the way to set it
Schedule One day at a time, saved events, alerts before they start
Map The convention centre's floorplan; "your event is here"
Life Conway's Game of Life
Standby Screen off, board still keeping time
Torch The whole panel, as bright as the board goes
Battery Voltage, charge estimate, history graph
Settings Display, power and schedule preferences
Debug View stack, heap, fault log

Five front buttons. A / C / up / down mean whatever the view says; tap B is usually the secondary action, and hold B always goes back — the case covers the BOOT button, so a hold is the one gesture left that collides with nothing.

Setup

uv is the only thing you need installed; everything else runs through uvx.

make stubs      # type stubs, gitignored, so a fresh clone needs this first
make test       # host suites: no badge required

Making it yours

cp -r badges/default badges/yourname
$EDITOR badges/yourname/badge.toml
make badge BADGE=yourname       # see what your choices render as
make deploy BADGE=yourname

badges/default/badge.toml documents every key inline. The short version: name, up to three fields under it, an avatar, a QR URL, up to two pride flags, a six-colour palette, and where your gallery images live (globs and paths outside the repo are fine).

The palette is worth reading the comments for. The panel is RGB332 — three bits of red, three of green, two of blue — so what you ask for and what you get differ, and make badge prints the real colours, checks the contrast of every pair the views rely on, and refuses a palette this screen cannot show legibly.

The default badge is deliberately nobody's: greyscale, no avatar, no flags.

Content

The schedule and map are fetched and packed on the host:

make schedule   # 810KB of JSON -> ~65KB, of which 7KB is ever resident
make map        # 132 requests, cached; the pack reads the cache
make deploy     # assets only move on a full deploy

The map fetch is four minutes of somebody else's server, so its cache (.navcache.json) is kept out of make clean's way and resumes if interrupted.

Working on it

make deploy-code        # code only: ~4s, against ~30s for a full deploy
make dev                # run the working tree over serial, no flash writes
make test T=schedule    # just the matching suites
make test-device        # the other half; needs a badge attached
make check              # ty + ruff
make repl / info / wipe

Two test halves, on purpose. tests/ fakes the MicroPython modules and imports the real device code, so it runs anywhere Python does. tests/device/ runs on the board and checks what a fake cannot know: whether a view finds the memory it needs, how long a frame takes, how the panel quantises a colour, what a flash write costs.

Layout

src/            device code — main.py, the app router, views/, hardware
src/apps.py     the launcher's registry; add a Tile to add an app
badges/         per-person configuration, layered over badges/default/
tools/          host-side: packers, fetchers, deploy helpers, test runners
tests/          host suites; tests/device/ runs on the board
assets/         copied to the badge verbatim

Views are imported when their tile is first opened, never at boot. That is not tidiness: importing all of them leaves the largest free block at about 5KB, and the QR encoder needs 8KB in one piece. The badge has 264KB of RAM, and most of the design notes in this codebase are measurements explaining a decision that looks odd until you see the number. They are in the module docstrings and the Makefile.

Hardware notes

The RP2040's RTC has no backup domain, so the power switch drops the clock to 2021-01-01 — the time is written to flash once a minute and restored at boot, and make deploy ends with a soft reset for the same reason. A watchdog arms itself the first time the badge is seen running on battery (it cannot be disarmed once started, and rebooting every eight seconds would make development impossible), and logs what it caught so the reboots are visible afterwards.