r75-firmware/sim/render.py
orca bc967ff54f R75 cyberdeck firmware: stock keymap, custom effects, host protocol
Vial firmware for the wired Royal Kludge R75 (WB32FQ95), based on
mossbed/r75 vialrgb and checked against RK's own R75 source:
- the keymap is generated from the factory keymap read off the keyboard
  (factory reset moved to Fn+RShift+Space)
- the Caps Lock LED uses RK's pin C4 instead of matrix column C9
- five custom RGB matrix effects (synthwave, glitch, heartbeat, plasma,
  scanner)
- raw HID command 0xC7: custom effect select, colour/speed for any
  effect, and alert overlays drawn over the running effect
- host simulator in sim/ to preview the effects as PNGs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 01:58:31 -04:00

23 lines
1 KiB
Python

#!/usr/bin/env python3
"""render.py EFFECT FRAMES STEP_MS OUT.png -> stacked frames of the keyboard from ./sim"""
import json, subprocess, sys
from PIL import Image, ImageDraw
eff, frames, step, out = int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), sys.argv[4]
pts = [(p["x"], p["y"]) for p in json.load(open("../keyboards/rk/r75/keyboard.json"))["rgb_matrix"]["layout"]]
rows = subprocess.run(["./sim", str(eff), str(frames), str(step)], capture_output=True, text=True).stdout.split()
data = {}
for r in rows:
f, i, rr, gg, bb = map(int, r.split(","))
data[(f, i)] = (rr, gg, bb)
S, KW, KH, FH = 3, 40, 30, 64 * 3 + 50
img = Image.new("RGB", (224 * S + 80, FH * frames), (10, 10, 16))
d = ImageDraw.Draw(img)
for f in range(frames):
oy = f * FH + 10
d.text((4, oy), f"t={f*step}ms", fill=(140, 140, 160))
for i, (x, y) in enumerate(pts):
c = data.get((f, i), (0, 0, 0))
cx, cy = 40 + x * S, oy + 14 + y * S
d.rectangle([cx - 18, cy - 13, cx + 18, cy + 13], fill=c, outline=(40, 40, 50))
img.save(out)
print(out, img.size)