feat: add 4-level grayscale display calibration - #35
Open
markomitranic wants to merge 1 commit into
Open
Conversation
Settings → Calibrate Display: a two-step wizard to tune the two middle grays of the 4-level UC8276 panel (black/white are fixed anchors). Both steps preview a photo dithered to the 4 real levels so you judge each gray against a real image; values persist in /data and re-apply at boot. Brings the grayscale rendering pipeline the screen depends on: Display switches to the eink singleton draw API (mode: :grayscale, self-dithering), Screen forwards a :render_opts assign, DisplayMock simulates the 4 levels, and the EInk singleton is supervised + configured. Depends on protolux-electronics/eink#12 (EInk.set_waveform/2 + the 4-gray pipeline); eink is pinned to that PR's head until it merges and releases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The UC8276 panel can render 4 gray levels, but only the two middle grays are tunable — black and white are fixed. Getting those two mids right is a per-panel, by-eye judgement, and there was no way to do it on the device. This adds a Settings → Calibrate Display screen to dial them in and remember the result.
What
A two-step wizard, because two buttons can only tune one gray at a time:
Both steps show the same photo dithered to the 4 real levels, so you judge each gray against a real image rather than a swatch. Values persist to
/data/display_calibration.jsonand re-apply at boot (EInk forgets waveform overrides on restart).The screen leans on a grayscale rendering pipeline the badge didn't have yet, so this PR brings it along:
Displayswitches from the oldEInk.new/…handle + manual 1-bit bit-packing to the eink singleton draw API (EInk.draw(dither, opts)), which does its own dithering and understandsmode: :grayscale.Screennow forwards a:render_optsassign into the draw call, so any screen can opt intomode: :grayscalethe same way it sets:button_hints.DisplayMockgained aquantize4path so the host simulator shows the 4 real levels instead of hard black/white.EInksingleton is supervised (beforeDisplay) and configured viaconfig :einkinconfig/target.exs.NameBadge.Calibration(the persistence + LUT logic) andNameBadge.Screen.Settings.Calibrate(the wizard UI), plus a settings-menu entry.Notes for reviewers
ditherbumped~> 0.1.1→~> 0.2.4(override: true) — the new eink pipeline requires it.mix.exssays what to swap it to.host,einkisn't compiled (targets: [:trellis]), soEInkxref warnings during a host compile are expected — the simulator usesDisplayMockand never calls intoEInk.