indication for array position while learning

This commit is contained in:
Alex
2026-04-11 15:32:04 -05:00
parent 81e9b12349
commit 14809d0194

View File

@@ -714,14 +714,50 @@ if __name__ == "__main__":
if "--learn" in sys.argv:
logging.basicConfig(level=logging.INFO)
info = learn_devices()
if not info.get("left") or not info.get("right"):
mgr = XVF3800Manager()
mgr.assign() # discovers and assigns by bus address order
if not mgr.left or not mgr.right:
print("[HEADMIC] Need 2 XVF3800 arrays connected for --learn")
sys.exit(1)
# Light up the first array and ask the user
print()
print("[HEADMIC] Identifying mic arrays...")
print(" One array should be lighting up GREEN now.")
mgr.left.led_solid(0x00FF00)
mgr.right.led_off()
answer = input(" Is the LEFT mic array lit up? [Y/n/swap] ").strip().lower()
mgr.left.led_off()
if answer in ("n", "no", "swap"):
print("[HEADMIC] Swapping left/right assignment")
mgr.left, mgr.right = mgr.right, mgr.left
# Confirm: light up both with their side color
print("[HEADMIC] Confirming: LEFT = green, RIGHT = blue")
mgr.left.led_solid(0x00FF00)
mgr.right.led_solid(0x0000FF)
time.sleep(2)
mgr.left.led_off()
mgr.right.led_off()
# Save config
info = {}
for label, dev in [("left", mgr.left), ("right", mgr.right)]:
entry = {"usb_serial": dev.serial}
alsa = mgr.serial_to_alsa(dev.serial)
if alsa:
entry["alsa_card"] = alsa
info[label] = entry
cfg = load_config()
cfg["ears"] = info
save_config(cfg)
print(f"[HEADMIC] Learned ear config → {CONFIG_PATH}")
print(f"[HEADMIC] Saved ear config → {CONFIG_PATH}")
print(json.dumps(info, indent=2))
sys.exit(0)