Run the real firmware on the 3D model's touchscreen #2

Merged
paudrow merged 1 commit from claude/wizardly-gates-q0o1df into main 2026-09-29 09:13:10 -05:00
paudrow commented 2026-09-29 09:12:38 -05:00 (Migrated from github.com)

Compiles the clock firmware (src/main.cpp + include/alarm_face.hpp, unchanged) to WebAssembly and runs it on the 3D viewer's touchscreen, so you can use the clock's actual interface on the model.

What's in it

  • sim/: a firmware simulator.
    • shim/M5Unified.h and shim/Preferences.h stand in for the M5Stack libraries. They cover just what main.cpp uses.
    • Drawing, tones and brightness go to JavaScript. Touch and the clock chip come from it.
    • Settings persist in localStorage, like the clock's flash does through a power cut.
    • sim.cpp exports sim_init / sim_loop / sim_touch.
    • build.py builds clock.wasm (44 KB, no system imports) with Zig's C++ toolchain (pip install ziglang).
  • Viewer (hardware/cad/viewer_template.html, viewer.py):
    • Interact flies the camera onto the model's screen and turns clicks on the model into touches. Done or Esc leaves.
    • A Touchscreen panel shows the same screen flat and clickable.
    • Clock controls: real time, 60× or 600×, set the time, sound on/off, reset settings.
    • It runs at each screen's aspect: 616 × 284 for the 4.1″ AMOLED, 600 × 450 for the 2.41″.

Checked

  • Reproducible build: rebuilding from source produces a clock.wasm byte-identical to the committed one.
  • Stress test: 20,000 firmware loops each at 616 × 284, 600 × 450 and 320 × 240, with random taps, holds, drags and time jumps. No traps, no invalid draw calls, and saved settings reload after a reboot. Random taps reached every menu page.
  • Headless browser: tapping the gear on the 3D model opens the firmware's Menu on both the model and the panel, with no page errors.

Follow-up (not in this PR)

Nothing yet rebuilds clock.wasm when src/main.cpp changes. A CI step running sim/build.py would catch both a stale binary and a new M5Unified call the shim doesn't cover.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CL9u8wcccZXQeAVwboNhNa


Generated by Claude Code

Compiles the clock firmware (`src/main.cpp` + `include/alarm_face.hpp`, unchanged) to WebAssembly and runs it on the 3D viewer's touchscreen, so you can use the clock's actual interface on the model. ## What's in it - **`sim/`**: a firmware simulator. - `shim/M5Unified.h` and `shim/Preferences.h` stand in for the M5Stack libraries. They cover just what `main.cpp` uses. - Drawing, tones and brightness go to JavaScript. Touch and the clock chip come from it. - Settings persist in localStorage, like the clock's flash does through a power cut. - `sim.cpp` exports `sim_init` / `sim_loop` / `sim_touch`. - `build.py` builds `clock.wasm` (44 KB, no system imports) with Zig's C++ toolchain (`pip install ziglang`). - **Viewer** (`hardware/cad/viewer_template.html`, `viewer.py`): - **Interact** flies the camera onto the model's screen and turns clicks on the model into touches. Done or Esc leaves. - A **Touchscreen** panel shows the same screen flat and clickable. - Clock controls: real time, 60× or 600×, set the time, sound on/off, reset settings. - It runs at each screen's aspect: 616 × 284 for the 4.1″ AMOLED, 600 × 450 for the 2.41″. ## Checked - **Reproducible build:** rebuilding from source produces a `clock.wasm` byte-identical to the committed one. - **Stress test:** 20,000 firmware loops each at 616 × 284, 600 × 450 and 320 × 240, with random taps, holds, drags and time jumps. No traps, no invalid draw calls, and saved settings reload after a reboot. Random taps reached every menu page. - **Headless browser:** tapping the gear on the 3D model opens the firmware's Menu on both the model and the panel, with no page errors. ## Follow-up (not in this PR) Nothing yet rebuilds `clock.wasm` when `src/main.cpp` changes. A CI step running `sim/build.py` would catch both a stale binary and a new M5Unified call the shim doesn't cover. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01CL9u8wcccZXQeAVwboNhNa --- _Generated by [Claude Code](https://claude.ai/code/session_01CL9u8wcccZXQeAVwboNhNa)_
Sign in to join this conversation.
No description provided.