mirror of
https://github.com/ruppert/fmini-1.git
synced 2026-12-05 12:24:36 +01:00
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QUF6pQ1NkTwmBC8SR8AK94
22 lines
1.3 KiB
Python
22 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
|
# FMini-1: the power-on picture (assets/fmini-splash.png) -> firmware/src/fmini_splash.h: 240 x 240, an adaptive
|
|
# 256-colour palette (RGB565) and one byte a pixel. python3 tools/gen_splash.py (the header is checked in)
|
|
import pathlib
|
|
from PIL import Image
|
|
root = pathlib.Path(__file__).resolve().parent.parent
|
|
im = Image.open(root / "assets" / "fmini-splash.png").convert("RGB").resize((240, 240), Image.LANCZOS)
|
|
q = im.quantize(256, method=Image.MEDIANCUT, dither=Image.FLOYDSTEINBERG)
|
|
pal = q.getpalette()[:768]
|
|
pal565 = [((pal[3 * i] & 0xF8) << 8) | ((pal[3 * i + 1] & 0xFC) << 3) | (pal[3 * i + 2] >> 3) for i in range(256)]
|
|
px = bytes(q.tobytes())
|
|
out = ["/* SPDX-License-Identifier: GPL-3.0-only",
|
|
" * Generated by tools/gen_splash.py from assets/fmini-splash.png (do not edit by hand). */",
|
|
"static const uint16_t FMINI_SPLASH_PAL[256] = {"]
|
|
out += [" " + ", ".join("0x%04X" % c for c in pal565[i:i + 12]) + "," for i in range(0, 256, 12)]
|
|
out += ["};", "static const uint8_t FMINI_SPLASH[240 * 240] = {"]
|
|
out += [" " + ",".join(str(b) for b in px[i:i + 40]) + "," for i in range(0, len(px), 40)]
|
|
out += ["};"]
|
|
(root / "firmware" / "src" / "fmini_splash.h").write_text("\n".join(out) + "\n")
|
|
print("wrote fmini_splash.h", len(px), "pixels")
|