No description
  • Rust 89.4%
  • Python 5%
  • Nix 2.1%
  • Shell 1.9%
  • Just 1.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-31 17:33:15 +01:00
.cargo feat: overengineered hackers on t-dongle 2026-10-31 17:33:15 +01:00
dongle feat: overengineered hackers on t-dongle 2026-10-31 17:33:15 +01:00
src feat: overengineered hackers on t-dongle 2026-10-31 17:33:15 +01:00
tools feat: bad apple in rust on esp32 oled 2026-10-30 21:24:17 +01:00
.gitignore feat: overengineered hackers on t-dongle 2026-10-31 17:33:15 +01:00
Cargo.lock feat: bad apple in rust on esp32 oled 2026-10-30 21:24:17 +01:00
Cargo.toml feat: bad apple in rust on esp32 oled 2026-10-30 21:24:17 +01:00
justfile feat: overengineered hackers on t-dongle 2026-10-31 17:33:15 +01:00
README.md feat: overengineered hackers on t-dongle 2026-10-31 17:33:15 +01:00
rust-toolchain.toml feat: bad apple in rust on esp32 oled 2026-10-30 21:24:17 +01:00
shell.nix feat: overengineered hackers on t-dongle 2026-10-31 17:33:15 +01:00

badesp

Bad Apple!! at 30 fps on an ESP32-C3 SuperMini board with a 0.42" OLED, written in bare-metal Rust with esp-hal. dongle/ is a larger sibling that plays a whole film in colour with sound.

Hardware

Function Pin
OLED SDA GPIO5
OLED SCL GPIO6
Display SSD1306, 72x40, I2C at 0x3C

Build

assets/ is not tracked, so create the video data once:

nix-shell
mkdir -p assets
curl -L -o assets/badapple.mp4 'https://archive.org/download/TouhouBadApple/Touhou%20-%20Bad%20Apple.mp4'
just encode

Then flash, optionally with another frame file. If the board does not connect, hold BOOT while tapping RESET.

just flash
just flash assets/other.bin

Opening the serial port can drop the board into download mode. Tap RESET or replug the board to start playback.

T-Dongle S3

dongle/ plays the whole film in colour at 160x80 and 23.976 fps from an SD card, with its soundtrack on an Apple TV over AirPlay. It starts at a random position and loops. It has its own toolchain, so use nix-shell dongle/shell.nix and work from there.

The second core reads the card and draws frames, skipping one if it falls behind, and passes samples through a ring to the first core, which runs Wi-Fi and streams them. If AirPlay is unavailable the video plays silently after 25 seconds, with a red dot in the top left corner. A red screen means there is no readable video.

Video and audio are raw and written straight to the card without a filesystem. This erases the card.

just encode
just card /dev/sdX

Then flash from dongle/, where just lists the other recipes. With several boards attached, set ESPFLASH_PORT to choose one.

just flash

Click BOOT during playback to jump to a random position, or hold it to show diagnostics: connection progress in white, connection attempts in blue, the audio buffer in green, free heap in orange, and why the last session ended as text. That text gives the stage reached, the seconds it lasted and the error. Connecting takes about 15 seconds.

Opening the serial port drops this board into download mode too, so use the screen for debugging. A board that was started with BOOT held needs a replug to start new firmware.

cardplayer is the same player without audio. flashclip plays a reduced clip from internal flash without a card, made with dongle/flashclip.py, and probe draws a test pattern and shows card details and read speed on the screen.

Setup

Hold BOOT for 5 seconds during playback to restart into setup mode, which also starts by itself until the settings are complete. The LCD shows the address of a web page for choosing the Wi-Fi network and AirPlay receiver. Receivers are found automatically once the dongle is on a network. If it cannot join one, it starts its own network instead, and the LCD shows how to connect. Anyone on the network can use the page while setup mode is running.

just configure writes the same settings from the laptop, by default from assets/wifi.txt, with the SSID and password on separate lines, and assets/familyroom.key. Settings live in flash at 0xFF0000, outside the app partition, so flashing firmware keeps them.

AirPlay

Each receiver needs pairing once. Press Pair next to it on the setup page and type the PIN it shows, and the dongle stores the key and that receiver. Other receivers may not work: an LG C9 pairs but refuses to play.

Two details matter. Stream with pair_homekit parameters, even on Apple devices. And audio packets are 1494 byte frames, so .cargo/config.toml raises the Wi-Fi MTU, because a smaller one silently drops them. Wi-Fi also queues outgoing packets on the heap and stalls without an error if it runs out, so the player adds a second heap region.