tuanchris преди 3 месеца
родител
ревизия
71d6b6062b
променени са 3 файла, в които са добавени 14 реда и са изтрити 0 реда
  1. 8 0
      main.py
  2. 4 0
      modules/led/dw_led_controller.py
  3. 2 0
      requirements.txt

+ 8 - 0
main.py

@@ -1164,6 +1164,14 @@ async def set_led_config(request: LEDConfigRequest):
         )
         logger.info(f"DW LEDs configured: {state.dw_led_num_leds} LEDs on GPIO{state.dw_led_gpio_pin}")
 
+        # Check if initialization succeeded by checking status
+        status = state.led_controller.check_status()
+        if not status.get("connected", False) and status.get("error"):
+            error_msg = status["error"]
+            state.led_controller = None
+            state.led_provider = "none"
+            raise HTTPException(status_code=400, detail=error_msg)
+
     else:  # none
         state.wled_ip = None
         state.led_controller = None

+ 4 - 0
modules/led/dw_led_controller.py

@@ -363,6 +363,10 @@ class DWLEDController:
 
     def check_status(self) -> Dict:
         """Get current controller status"""
+        # Attempt initialization if not already initialized
+        if not self._initialized:
+            self._initialize_hardware()
+
         status = {
             "connected": self._initialized,
             "power_on": self._powered_on,

+ 2 - 0
requirements.txt

@@ -13,5 +13,7 @@ websockets>=11.0.3  # Required for FastAPI WebSocket support
 requests>=2.31.0
 Pillow
 aiohttp
+# GPIO/NeoPixel support for DW LEDs
+RPi.GPIO>=0.7.1  # Required by Adafruit Blinka on Raspberry Pi
 adafruit-circuitpython-neopixel>=6.3.0
 Adafruit-Blinka>=8.0.0