Files
wadamesh/scripts/build/gen-qr-icon.py
T
Kaj SchittecatandClaude Opus 4.8 76f0754d0d touch: emoji additions, Chats-header button reorder + QR icon, distance sort
Emoji: bake 4 more Noto colour glyphs (soccer, american football, moai,
transgender flag) and add them to the picker. The trans flag is a ZWJ sequence
the single-codepoint imgfont lookup can't render directly, so its combined Noto
image is keyed on the lead codepoint (U+1F3F3) with the trailing symbol mapped to
the zero-width glyph — the whole sequence renders as the one flag. Only the 4 new
glyphs are baked + spliced (scripts/build/add-emoji.py); the existing 252 stay
byte-identical (no Noto-main art drift).

Chats header: group the three actions at the LEFT edge in the order + (add) /
✓ (mark all read) / QR (share), and draw a real baked QR glyph (qr_icon.h, from
scripts/build/gen-qr-icon.py, recoloured to the text colour) instead of the old
LV_SYMBOL_IMAGE 'picture' stand-in.

Contacts sort: every sort option now toggles ascending/descending — re-tapping the
active row in the Sort sheet flips it and shows a ▲/▼ arrow. New 'Nearest first'
(distance) sort orders by distance from our GPS and excludes contacts that have
shared no location.

Discovered list: gains the same sort sheet (Recently heard / Name / Nearest, each
asc/desc) via a sort button at the top of the list; distance likewise excludes
no-location entries.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 18:06:24 +02:00

52 lines
2.0 KiB
Python

#!/usr/bin/env python3
# Generate src/ui-touch/qr_icon.h: a small, recolour-able "QR code" glyph baked to
# an LVGL TRUE_COLOR_ALPHA lv_img_dsc (white opaque modules, transparent ground —
# tinted to the button text colour at runtime via img_recolor). There is no QR
# glyph in the Montserrat/symbol font, so the Chats-header Share button draws this
# instead of the old stand-in LV_SYMBOL_IMAGE ("picture") icon.
#
# python3 scripts/build/gen-qr-icon.py
#
# Same pixel encoding as the emoji bake: [lo, hi, alpha], LV_COLOR_16_SWAP=0.
import os
SCALE = 2 # px per module -> 9 modules * 2 = 18x18 px
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.abspath(os.path.join(HERE, "..", ".."))
OUT = os.path.join(ROOT, "src", "ui-touch", "qr_icon.h")
# 9x9 module grid. Three finder patterns (ring: 111/101/111) at TL/TR/BL corners,
# scattered data modules + a small alignment block bottom-right so it reads as a QR.
P = [
[1,1,1,0,1,0,1,1,1],
[1,0,1,0,0,0,1,0,1],
[1,1,1,0,1,0,1,1,1],
[0,0,0,0,0,0,0,0,0],
[1,0,1,0,1,1,0,1,0],
[0,0,0,0,1,1,0,0,1],
[1,1,1,0,0,0,1,0,1],
[1,0,1,0,1,0,0,1,0],
[1,1,1,0,0,1,1,0,1],
]
MODS = len(P)
W = H = MODS * SCALE
data = bytearray()
for y in range(H):
for x in range(W):
on = P[y // SCALE][x // SCALE]
if on:
data += bytes((0xFF, 0xFF, 0xFF)) # white RGB565 (lo,hi) + alpha 255
else:
data += bytes((0x00, 0x00, 0x00)) # transparent
with open(OUT, "w") as f:
f.write("// AUTO-GENERATED by scripts/build/gen-qr-icon.py — do not edit.\n")
f.write("// %dx%d recolour-able QR glyph for the Chats-header Share button.\n#pragma once\n" % (W, H))
f.write('#include "lvgl.h"\n\n')
f.write("static const uint8_t qr_icon_map[] = {%s};\n" % ",".join(str(b) for b in data))
f.write("static const lv_img_dsc_t qr_icon_dsc = { { LV_IMG_CF_TRUE_COLOR_ALPHA, 0, 0, %d, %d }, sizeof(qr_icon_map), qr_icon_map };\n"
% (W, H))
print("wrote %s (%dx%d, %d bytes)" % (OUT, W, H, len(data)))