{"id":50337389,"url":"https://github.com/fdb/fri3d-wasm-badge","last_synced_at":"2026-05-29T14:30:54.907Z","repository":{"id":337797609,"uuid":"1122726987","full_name":"fdb/fri3d-wasm-badge","owner":"fdb","description":"Badge OS for Fri3d Camp Badge","archived":false,"fork":false,"pushed_at":"2026-04-19T13:24:08.000Z","size":2912,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-19T13:28:21.930Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fdb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-12-25T11:24:11.000Z","updated_at":"2026-04-19T13:24:12.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/fdb/fri3d-wasm-badge","commit_stats":null,"previous_names":["fdb/fri3d-wasm-badge"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fdb/fri3d-wasm-badge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdb%2Ffri3d-wasm-badge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdb%2Ffri3d-wasm-badge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdb%2Ffri3d-wasm-badge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdb%2Ffri3d-wasm-badge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fdb","download_url":"https://codeload.github.com/fdb/fri3d-wasm-badge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdb%2Ffri3d-wasm-badge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33657690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-29T14:30:54.838Z","updated_at":"2026-05-29T14:30:54.896Z","avatar_url":"https://github.com/fdb.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fri3d WASM Badge\n\nA WebAssembly runtime for the [Fri3d Camp 2024 badge](https://github.com/Fri3dCamp/badge_2024_hw)\n(ESP32-S3, 240×296 color LCD). Rust apps compile to WASM and run on the\nreal hardware via wasm3, in the browser via Emscripten, and natively for\noffline testing — all from the same C++ host.\n\n![Fri3d Badge UI Teaser](fri3d-badge-teaser.gif)\n\n### **[Try the Live Demo in your Browser](https://fdb.github.io/fri3d-wasm-badge/)**\n\n## Architecture\n\n```\n┌─────────────────────────────┐\n│  Rust app (fri3d-app-*)     │  compiles to wasm32-unknown-unknown\n│  + fri3d-wasm-api SDK       │  (the 24 host functions the app imports)\n└───────────┬─────────────────┘\n            │ .wasm\n            ▼\n┌─────────────────────────────────────────────────────────────┐\n│  C++ host in firmware/src (canvas, random, wasm_host, font) │\n│  ─ shared across three targets ─                            │\n└───────┬──────────────┬──────────────┬─────────────────────────┘\n        │              │              │\n        ▼              ▼              ▼\n ESP32-S3 badge    browser       native CLI\n (PlatformIO)      (Emscripten)  (app-runner, parity tests)\n```\n\nCanvas primitives are kept **byte-exact** with the Rust reference\nimplementation in `fri3d-runtime/src/canvas.rs` via a parity test harness —\nsee [CLAUDE.md](CLAUDE.md) for details.\n\n## Display dimensions\n\nApps draw into a **128×64 monochrome** framebuffer. That's the virtual\ncanvas size the WASM API and every primitive operate on — independent of\nthe physical target.\n\n| Target | Physical screen | What we show |\n| --- | --- | --- |\n| ESP32-S3 badge | 240 × 296 colour IPS LCD (landscape: 296 × 240) | 128×64 canvas upscaled 2× to 256×128, centred, green-on-black |\n| Browser | 256 × 128 `\u003ccanvas\u003e` (CSS-scaled 2×) | same 128×64 canvas, nearest-neighbour 2× |\n| Native `app-runner` | 128 × 64 PNG | raw canvas, 1 output pixel per canvas pixel |\n\nThe WASM app never sees the 240×296 physical pixels — it draws against\na fixed 128×64 grid, and the C++ host in `firmware/src/main.cpp` handles\nthe upscale + centering to the hardware LCD. This keeps apps portable\nacross targets and keeps the SDK surface tiny.\n\n## Prerequisites\n\n- Rust toolchain (via rustup) with `wasm32-unknown-unknown` target\n- `wasm-opt` ([binaryen](https://github.com/WebAssembly/binaryen)) for shrinking app WASM\n- [PlatformIO](https://platformio.org/install) for the badge firmware\n- [Emscripten](https://emscripten.org/) for the browser build\n- `uv` (Python runner) for optional parity sweeps\n\n```bash\nrustup target add wasm32-unknown-unknown\nbrew install binaryen emscripten\n```\n\n## Building \u0026 running\n\n### Browser emulator (fastest feedback loop)\n\n```bash\nfirmware/web/build.sh\ncd firmware/web/dist \u0026\u0026 python3 -m http.server 8080\n# open http://localhost:8080/\n```\n\n### Hardware firmware\n\n```bash\ncd firmware\npio run                 # build\npio run -t upload       # flash (requires USB-C to the badge)\n```\n\n### Native app runner (offline rendering to PNG)\n\n```bash\nfirmware/tools/app-runner/build.sh\nfirmware/tools/app-runner/app_runner firmware/build/fri3d_app_circles_opt.wasm \\\n    --out /tmp/circles.png\n```\n\n## Tests\n\n### Canvas parity (C++ vs Rust reference)\n\n```bash\nfirmware/tools/canvas-parity/run.sh\n```\n\nRegenerates Rust-side golden framebuffers, builds the C++ tester, and\ndiffs byte-for-byte. Fails loudly on any drift.\n\n### Visual parity (full apps)\n\n```bash\nfirmware/tools/app-runner/visual_parity.sh\n```\n\nRuns every app that has a Rust-generated `tests/visual/apps/\u003capp\u003e/golden/*.png`\nthrough the native C++ runner and compares pixel-for-pixel.\n\n## Controls (hardware \u0026 browser)\n\n- D-pad / WASD / arrow keys: navigate\n- A / Z / Enter: OK / Select\n- B / X / Backspace: Back\n\n## Project structure\n\n```\nfirmware/\n  src/                 # Shared C++: canvas, random, wasm_host, font, fonts\n  lib/wasm3/           # Vendored wasm3 v0.5.0\n  web/                 # Emscripten browser build (index.html, test.html, tests.js)\n  tools/\n    app-runner/        # Native WASM runner, dumps PNG\n    canvas-parity/     # C++ parity tester\n  platformio.ini       # Hardware build config\n  scripts/embed_app.sh # Rust app -\u003e optimized embedded_app.h\n\nfri3d-runtime/         # Canvas/Random reference (used only by parity-gen)\nfri3d-wasm-api/        # App SDK — 24 host imports\nfri3d-app-*/           # Rust WASM apps\n\ntools/\n  canvas-parity-gen/   # Rust binary that emits golden framebuffers\n  transpile_fonts.py   # One-shot fonts.rs → fonts.h extractor\n\ntests/\n  canvas-golden/       # Golden framebuffers for primitive tests\n  visual/apps/         # Golden PNGs for full-app visual parity\n```\n\n## License\n\nSee individual crate licenses where applicable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdb%2Ffri3d-wasm-badge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffdb%2Ffri3d-wasm-badge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdb%2Ffri3d-wasm-badge/lists"}