add ga, ufo, and bbq logos

This commit is contained in:
2026-11-15 17:44:52 -05:00
parent 5a839bce7a
commit 69e7a647eb
12 changed files with 47 additions and 8 deletions
+16 -7
View File
@@ -10,6 +10,7 @@ Speed notes (rpi-rgb-led-matrix):
- Draw into an offscreen canvas and SwapOnVSync() so you never show a half-drawn frame.
- Don't pre-apply gamma: the library's luminance correction (on by default) handles it.
"""
import re
import struct
from pathlib import Path
from PIL import Image
@@ -31,15 +32,23 @@ def load_atlas(path="out/atlas.bin"):
LOGOS = load_atlas()
FALLBACK = Image.open("fallback.png").convert("RGB") # your unidentified/GA icon
UFO = LOGOS["UFO"] # unidentified: no callsign, or a prefix we have no logo for
GA = LOGOS["GA"] # general aviation: US tail numbers
# US N-number: N + 1-5 digits + up to 2 letters (N123AB, N7, N99999). Doesn't match airline callsigns.
N_NUMBER = re.compile(r"^N\d{1,5}[A-Z]{0,2}$")
def logo_for(callsign: str) -> Image.Image:
# Airline callsigns are a 3-letter ICAO prefix + digits (DAL1234). N-numbers (N123AB) -> fallback.
prefix = callsign[:3].upper()
if len(callsign) > 3 and callsign[3].isdigit() and prefix.isalpha():
return LOGOS.get(prefix, FALLBACK)
return FALLBACK
def logo_for(callsign) -> Image.Image:
cs = (callsign or "").strip().upper()
if not cs:
return UFO
if N_NUMBER.match(cs):
return GA
# Airline callsign = 3-letter ICAO prefix + flight number (DAL1234)
if len(cs) > 3 and cs[:3].isalpha() and cs[3].isdigit():
return LOGOS.get(cs[:3], UFO)
return UFO
if __name__ == "__main__":