by adom
2020 Addressable RGB LED · 800 Kbps single-line cascade · 16 mA per channel (V1.0 sheet), 12 mA from V1.2
← Commit history
hero_post_callout.py: self-contained (no local imports)
1 file changed
+11−2
provenance/tools/hero_post_callout.py+11−2@@ -10,8 +10,17 @@ chip and readable from below: all in one declared layer (extras.adomLayer key 'datasheet_note'), so a reader can switch it off. usage: ws_callout.py HERO.glb (in place; refuses to run twice)""" import io, json, math, struct, sys-sys.path.insert(0, "/home/adom/project/basic-parts-overhaul")-from hero_copper import read_glb, write_glb+++def read_glb(p):+ b = open(p, "rb").read(); n = struct.unpack("<I", b[12:16])[0]; js = json.loads(b[20:20 + n]); o = 20 + n+ return js, bytearray(b[o + 8:o + 8 + struct.unpack("<I", b[o:o + 4])[0]] if o < len(b) else b"")+++def write_glb(p, js, bin_):+ j = json.dumps(js, separators=(",", ":")).encode(); j += b" " * (-len(j) % 4); bin_ += b"\0" * (-len(bin_) % 4)+ open(p, "wb").write(struct.pack("<III", 0x46546C67, 2, 12 + 8 + len(j) + 8 + len(bin_)) + struct.pack("<II", len(j), 0x4E4F534A) + j+ + struct.pack("<II", len(bin_), 0x004E4942) + bytes(bin_)) from PIL import Image, ImageDraw, ImageFont glb = sys.argv[1]