Skip to content

Add emulated SSD1306 render test#36

Closed
laurb9 wants to merge 1 commit into
masterfrom
sim-display-test
Closed

Add emulated SSD1306 render test#36
laurb9 wants to merge 1 commit into
masterfrom
sim-display-test

Conversation

@laurb9

@laurb9 laurb9 commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Follow-up to #32: the OLED itself is now emulated, so tests verify actual rendered pixels, not just the serial trace.

How it works

A small C runner (test/sim_display/sim_display.c, linked against Ubuntu jammy's libsimavr-dev 1.6) loads .pio/build/uno_sim/firmware.elf, attaches simavr's ssd1306_virt part over TWI at 0x3C, and steps the CPU until the firmware prints sim: TESTS COMPLETE — which lands right after the 5th display.display(), making the framebuffer snapshot deterministic. VRAM is dumped as 64x128 ASCII art ('#'/'.') and compared pixel-for-pixel against the golden test/uno-display.txt (which is git-diffable and human-reviewable — it clearly shows the rendered voltmeter screen).

make sim-display-test          # build + render + compare
make sim-display-test-update   # regenerate the golden after intentional UI changes

Licensing note

ssd1306_virt.{c,h} are vendored verbatim from simavr v1.6 examples/parts and are GPLv3 — test tooling only, compiled solely into the host-side runner, never linked into the MIT firmware. Documented in test/sim_display/README.md.

Changes

  • test/sim_display/ (runner + vendored part + README), test/sim-display-run.sh, golden baseline
  • Makefile targets; devcontainer gains gcc libsimavr-dev libelf-dev; display test added to the existing CI sim-test job (no duplicate pio builds)
  • AGENTS.md + verify skill updated

Verification (devcontainer)

  • make sim-display-test passes; second run identical (deterministic)
  • Negative test: single flipped pixel in the golden → FAIL with diff (comparison is real)
  • make sim-test still passes; all 5 pio envs build; devcontainer image builds

Found in passing: the MODE_BUTTON_PIN redefined warning in PlatformIO build logs is an artifact of PIO's .ino conversion pass (it registers all #defines while passing conditionals through unevaluated) — the compiled code is correct on every board. Cosmetic fix in a separate PR.

Agent: claude-opus-4-8 implement / claude-fable-5 validate, claude-sonnet-5 verify (claude-code)

🤖 Generated with Claude Code

Runs the uno_sim firmware on simavr with a virtual SSD1306 attached over
TWI at 0x3C, snapshots VRAM when the firmware prints its completion marker,
and compares the 128x64 framebuffer as ASCII art against a golden baseline
(test/uno-display.txt). Catches rendering regressions the serial-only smoke
test cannot see; the golden shows the voltmeter screen actually rendered.

- test/sim_display/sim_display.c: runner linking jammy's libsimavr 1.6
  (elf load, UART marker watch, deterministic snapshot, ASCII dump)
- test/sim_display/ssd1306_virt.{c,h}: vendored verbatim from simavr v1.6
  examples/parts (GPLv3 test tooling, never linked into the MIT firmware -
  see test/sim_display/README.md)
- test/sim-display-run.sh + make sim-display-test / sim-display-test-update
  (pixel-exact compare, no digit stripping)
- devcontainer: gcc, libsimavr-dev, libelf-dev; CI: display test added to
  the existing sim-test job
- AGENTS.md + verify skill updated

Verified in devcontainer: display test passes and is deterministic across
runs, mutated-golden negative test fails as expected, sim-test still passes,
all five pio envs build.

Agent: claude-opus-4-8 implement / claude-fable-5 validate,
claude-sonnet-5 verify (claude-code)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@laurb9

laurb9 commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Closing per maintainer decision: ssd1306_virt.{c,h} are GPLv3 and this repo is MIT — vendoring license-incompatible source isn't acceptable here, even as test-only tooling.

If display-level testing is ever wanted again, two GPL-free-repo approaches exist:

  1. Fetch at test time: keep only MIT runner code in the repo and have the Makefile/CI download ssd1306_virt from simavr's GitHub at a pinned commit — GPL source never enters this repo (the non-distributed test binary still links GPL libsimavr, like the existing sim-test uses the GPL simavr executable).
  2. Clean-room MIT part: the SSD1306 command subset the firmware uses (addressing mode, page/column ranges, display on/off, data writes) is small enough for a ~150-line MIT implementation.

The serial-trace smoke test (make sim-test) is unaffected and remains in place.

Agent: claude-fable-5 (claude-code)

@laurb9 laurb9 closed this Jul 12, 2026
@laurb9
laurb9 deleted the sim-display-test branch July 12, 2026 01:49
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