From 2f7b45fa45684a2536a4666de39f2e9e8b2380f5 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 11 Apr 2026 15:58:56 -0500 Subject: [PATCH] fixing leds --- xvf3800.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/xvf3800.py b/xvf3800.py index 1099e93..4d8a8b0 100644 --- a/xvf3800.py +++ b/xvf3800.py @@ -32,12 +32,13 @@ CTRL_REQUEST_TYPE_IN = usb.util.CTRL_IN | usb.util.CTRL_TYPE_VENDOR | usb.util GPO_RESID = 20 # Command IDs (wValue in USB control transfer) +# Verified against official xvf_host.py WriteCMD output DOA_VALUE_CMD = 18 # returns (angle 0-359, vad 0/1) LED_EFFECT_CMD = 12 # 0=off, 1=breath, 2=rainbow, 3=solid, 4=doa, 5=ring -LED_BRIGHTNESS_CMD = 13 -LED_COLOR_CMD = 15 # single uint32 color -LED_DOA_COLOR_CMD = 16 # two uint32 values: base + indicator -LED_RING_COLOR_CMD = 17 # 12 × uint32 +LED_BRIGHTNESS_CMD = 14 +LED_COLOR_CMD = 16 # single uint32 color (confirmed: xvf_host LED_COLOR cmdid=16) +LED_DOA_COLOR_CMD = 17 # two uint32 values: base + indicator +LED_RING_COLOR_CMD = 18 # 12 × uint32 class XVF3800: @@ -94,20 +95,28 @@ class XVF3800: def led_off(self): self._write(GPO_RESID, LED_EFFECT_CMD, struct.pack(" bytes: + """Convert 0xRRGGBB to [R, G, B, 0] payload.""" + r = (color >> 16) & 0xFF + g = (color >> 8) & 0xFF + b = color & 0xFF + return bytes([r, g, b, 0]) + def led_solid(self, color: int): """Solid color on all LEDs. color is 0xRRGGBB.""" - self._write(GPO_RESID, LED_COLOR_CMD, struct.pack("