Skip to content

Refactor platform support - #13

Open
JohnAZoidberg wants to merge 6 commits into
mainfrom
platforms
Open

JohnAZoidberg wants to merge 6 commits into
mainfrom
platforms

Conversation

@JohnAZoidberg

@JohnAZoidberg JohnAZoidberg commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Preparing for merging Laptop 12 into this branch by extracting the platform specific logic.

Pure move, no code changes except module paths. Prepares for adding
more platforms next to it.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
Otherwise changes in src/platform/ don't trigger a rebuild.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
GOP setup, input protocol and OS indications don't depend on the platform.
Same split as on the sunflower branch.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
Text boxes, image drawing, the low battery warning and clearing the screen
are the same on every platform. Also add decode_png() instead of repeating
the decoder in every bitmap getter.

Two side-effects:
- clear_screen() now clears the whole GOP buffer instead of a fixed
  2560x1600 area, same as 'Clear the whole screen' on the sunflower branch.
  No difference on the native Laptop 16 panel.
- Release binary shrinks from 923KiB to 409KiB, because the PNG decoder is now
  instantiated once instead of once per image.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
Expansion bay, input deck, fan speed and the QEMU mock data only make
sense on Laptop 16.

Power button, HW diag, version and UEFI app mode are
common to all platforms and stay in ec_comm.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
The UI loop in app.rs is now generic over a Platform. It handles everything
that isn't platform specific: power button short and long press, ESC, F12
(reboot into BIOS setup), '?' (verbose) and redrawing only on changes.

Laptop 16 implements Platform. Its hardware state is now one Snapshot
struct, and the outdated firmware countdown, the 'p' mock key and the
interposer cold reboot use the Platform hooks.

BIOS settings and the 'info' output move from main.rs to
platform/laptop16/status.rs.

To add a platform, implement Platform in platform/<name>/ and point
platform::Current at it.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
@github-actions

Copy link
Copy Markdown

📦 Binary Size Comparison (Nix Build)

Metric Base PR Difference
Size 783.50 KiB 404.50 KiB 📉 -388096 bytes (-48.37%)
SHA256 6bdc9b873849a0fb... 1a3a5ac4b11dc87f... ⚠️ Changed
Full hashes
  • Base: 6bdc9b873849a0fbafeb0e971f8fe03e2540b264fc564fdd77558f5b374e5a61
  • PR: 1a3a5ac4b11dc87f181bd6cff5f75464ef005a7e5e68b70fcdbff616208b8c85

@JohnAZoidberg

Copy link
Copy Markdown
Member Author

Wow, the binary size is halved!

Explanation: include_bytes! gives each PNG its own array type (&[u8; N], with a different N per file), so the generic PngDecoder was compiled once per image;
decode_png(&[u8]) turns every image into the same slice type, so only one copy of the decoder is compiled.

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