Skip to content

feat: drive OLED with a testable screen-content model (PR 3/9) - #38

Merged
thePunderWoman merged 1 commit into
mainfrom
firmware-rewrite/pr3-oled-driver
Sep 7, 2026
Merged

feat: drive OLED with a testable screen-content model (PR 3/9)#38
thePunderWoman merged 1 commit into
mainfrom
firmware-rewrite/pr3-oled-driver

Conversation

@thePunderWoman

Copy link
Copy Markdown
Owner

Summary

PR 3 of the firmware rewrite (PR 1: #35, PR 2: #36). Adds the SSD1306 OLED per PCB/README.md's hardware table (128x64, I2C on pins 8/9).

  • ScreenBuffer (include/screen.h / src/screen.cpp): pure content model — a small grid of text lines (8 rows x 21 cols, sized for the default 6x8px GFX font on this display), fully unit tested. Decides what text should be shown; knows nothing about I2C or Adafruit.
  • OledDisplay (include/oled.h / src/oled.cpp): thin adapter wrapping Adafruit_SSD1306/GFX — draws whatever a ScreenBuffer currently holds. No content decisions live here.
  • Later PRs (menu, complications, gesture feedback) drive the display purely by changing ScreenBuffer content — nothing after this PR should need to touch oled.cpp directly.
  • oled.cpp is hardware-touching with no branching logic worth testing, so it joins SnipsController.ino in the native build/coverage exclusion list (platformio.ini + ci.yml, both updated).
  • Two assumptions flagged in include/oled.h for real-hardware bring-up, since neither is documented in the PCB docs: the module's I2C address (assumed 0x3C) and that it needs no dedicated reset pin.

For now SnipsController.ino just shows a static boot message on the two top lines — real content lands with the menu/complications PRs.

Test plan

  • pio test -e native — all 24 test cases pass
  • gcovr --exclude 'src/SnipsController\.ino' --exclude 'src/oled\.cpp' --fail-under-line 90 — 100% across buttons.cpp/power_latch.cpp/screen.cpp
  • pio run -e esp32s3 — builds successfully, Adafruit SSD1306/GFX libs resolve and link
  • Flash to real hardware once boards arrive: confirm "Snips Controller" / "OLED OK" renders; if the display comes up blank, try I2C address 0x3D (see include/oled.h)

🤖 Generated with Claude Code

Adds the SSD1306 OLED per PCB/README.md's hardware table (128x64, I2C).
Split the same way as the rest of this rewrite: ScreenBuffer
(screen.h/.cpp) is pure content — just a small grid of text lines,
fully unit tested — and OledDisplay (oled.cpp) is a thin adapter over
Adafruit_SSD1306/GFX that draws whatever a ScreenBuffer holds. Later
PRs (menu, complications, gesture feedback) drive the display by
changing ScreenBuffer content, never by touching the display directly.

oled.cpp is hardware-touching (I2C/Adafruit_SSD1306) and has no
branching logic worth testing, so it's excluded from native
build/coverage the same way SnipsController.ino already is — extended
platformio.ini's build_src_filter and ci.yml's gcovr --exclude to match.

For now SnipsController.ino just shows a static boot message — real
content lands with the menu/complications PRs. Flagged two assumptions
in oled.h for real-hardware bring-up: the module's I2C address (0x3C)
and that it needs no dedicated reset pin — neither is documented in the
PCB docs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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