fixing leds

This commit is contained in:
Alex
2026-04-11 16:28:15 -05:00
parent 3b4799069d
commit f41b852b5d

View File

@@ -96,7 +96,7 @@ class XVF3800:
# --- LEDs --- # --- LEDs ---
def led_off(self): def led_off(self):
self._write(GPO_RESID, LED_EFFECT_CMD, struct.pack("<I", 0)) self._write(GPO_RESID, LED_EFFECT_CMD, bytes([0]))
@staticmethod @staticmethod
def _color_bytes(color: int) -> bytes: def _color_bytes(color: int) -> bytes:
@@ -109,23 +109,23 @@ class XVF3800:
def led_solid(self, color: int): def led_solid(self, color: int):
"""Solid color on all LEDs. color is 0xRRGGBB.""" """Solid color on all LEDs. color is 0xRRGGBB."""
self._write(GPO_RESID, LED_COLOR_CMD, self._color_bytes(color)) self._write(GPO_RESID, LED_COLOR_CMD, self._color_bytes(color))
self._write(GPO_RESID, LED_EFFECT_CMD, struct.pack("<I", 3)) self._write(GPO_RESID, LED_EFFECT_CMD, bytes([3]))
def led_breath(self, color: int, brightness: int = 128): def led_breath(self, color: int, brightness: int = 128):
"""Breathing effect.""" """Breathing effect."""
self._write(GPO_RESID, LED_COLOR_CMD, self._color_bytes(color)) self._write(GPO_RESID, LED_COLOR_CMD, self._color_bytes(color))
self._write(GPO_RESID, LED_BRIGHTNESS_CMD, struct.pack("<I", brightness)) self._write(GPO_RESID, LED_BRIGHTNESS_CMD, bytes([brightness]))
self._write(GPO_RESID, LED_EFFECT_CMD, struct.pack("<I", 1)) self._write(GPO_RESID, LED_EFFECT_CMD, bytes([1]))
def led_doa(self, base_color: int = 0x003333, doa_color: int = 0x00FFFF): def led_doa(self, base_color: int = 0x003333, doa_color: int = 0x00FFFF):
"""DoA indicator mode — shows beam direction on LED ring.""" """DoA indicator mode — shows beam direction on LED ring."""
data = self._color_bytes(base_color) + self._color_bytes(doa_color) data = self._color_bytes(base_color) + self._color_bytes(doa_color)
self._write(GPO_RESID, LED_DOA_COLOR_CMD, data) self._write(GPO_RESID, LED_DOA_COLOR_CMD, data)
self._write(GPO_RESID, LED_EFFECT_CMD, struct.pack("<I", 4)) self._write(GPO_RESID, LED_EFFECT_CMD, bytes([4]))
def led_rainbow(self, brightness: int = 128): def led_rainbow(self, brightness: int = 128):
self._write(GPO_RESID, LED_BRIGHTNESS_CMD, struct.pack("<I", brightness)) self._write(GPO_RESID, LED_BRIGHTNESS_CMD, bytes([brightness]))
self._write(GPO_RESID, LED_EFFECT_CMD, struct.pack("<I", 2)) self._write(GPO_RESID, LED_EFFECT_CMD, bytes([2]))
class XVF3800Manager: class XVF3800Manager: