Files
julian 1cba9f30bc
Firmware / build (push) Successful in 10m49s
Reverse lights on DO0, Sport + Vehicle screens, per-DDE live data, ECU identification
- ReverseLight: isolated output DO0 (CH422G OC0 -> PC817 -> NPN sink) drives the
  reverse-lamp relay while the lever is in R on a live bus with ignition on; 10 Hz
  decision confirmed over 200 ms, written through the panel library's expander
  object so the backlight cannot undo it; `reverse status|on|off|force` console,
  default ON (NVS `revlight_en`). Wiki page reverse-lights-output with the wiring.
- Sport screen: BMW-style power + torque gauges (lv_meter on a dial-face image,
  image needle); PNG sources in assets/, tools/png2lvgl.py converter.
- Vehicle: final drive ratio + tyre circumference -> road speed, hp from torque;
  Settings > Vehicle page; `vehicle` console.
- Bench simulation (`sim` console) overlays torque / rpm / shaft on the snapshot.
- EcuIdent: KWP 1A 86 / 1A 80 read once, stored in NVS, shown on Settings >
  Vehicle, passive ECU CHANGED? check; `ecu` console.
- Ignition fallback from the 0x1D2 lever byte on buses without 0x3B4 (Patrol 2).
- Engine data: per-DDE `2C 10` identifier profiles (Patrol 1 vs Patrol 2
  rail 00C2 / boost 003A / battery 002F); DiagProbe liveConfigure().
- Wiki: Patrol 2 captures, vehicles page, obd identifier table per DDE, logs.
2026-10-28 16:46:42 +01:00

57 lines
1.6 KiB
Python

"""Convert a PNG with transparency into an LVGL 8 image C file (LV_IMG_CF_TRUE_COLOR_ALPHA).
Usage: python tools/png2lvgl.py assets/needle.png src/assets/needle_img.c needle_img
Pixel format matches this firmware's lv_conf.h: LV_COLOR_DEPTH 16, LV_COLOR_16_SWAP 0,
so every pixel is RGB565 little-endian followed by one alpha byte (3 bytes per pixel).
Requires Pillow (python -m pip install --user pillow).
"""
import sys
from PIL import Image
src, dst, name = sys.argv[1], sys.argv[2], sys.argv[3]
im = Image.open(src).convert("RGBA")
w, h = im.size
px = im.load()
data = bytearray()
for y in range(h):
for x in range(w):
r, g, b, a = px[x, y]
c = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)
data += bytes((c & 0xFF, c >> 8, a))
lines = []
for i in range(0, len(data), 24):
lines.append(" " + ", ".join("0x%02X" % v for v in data[i:i + 24]) + ",")
with open(dst, "w", encoding="utf-8", newline="\n") as f:
f.write(f"""/*
* {name}: generated by tools/png2lvgl.py from {src.replace(chr(92), '/')} ({w}x{h}).
* LV_IMG_CF_TRUE_COLOR_ALPHA, RGB565 little-endian + alpha, 3 bytes per pixel.
* Regenerate after editing the PNG; do not edit by hand.
*/
#include <lvgl.h>
#ifndef LV_ATTRIBUTE_MEM_ALIGN
#define LV_ATTRIBUTE_MEM_ALIGN
#endif
static const LV_ATTRIBUTE_MEM_ALIGN uint8_t {name}_map[] = {{
{chr(10).join(lines)}
}};
const lv_img_dsc_t {name} = {{
.header = {{
.cf = LV_IMG_CF_TRUE_COLOR_ALPHA,
.always_zero = 0,
.reserved = 0,
.w = {w},
.h = {h},
}},
.data_size = {len(data)},
.data = {name}_map,
}};
""")
print(f"{dst}: {w}x{h}, {len(data)} bytes")