1
Fork 0
mirror of https://github.com/RGBCube/GDUS synced 2025-07-28 05:27:45 +00:00

Fix led toggle code 4

This commit is contained in:
RGBCube 2024-01-10 09:14:20 +03:00
parent 91f0093f81
commit 48412cd4da
No known key found for this signature in database

View file

@ -19,6 +19,7 @@ app = FastAPI()
@app.get("/led/toggle")
async def toggle(number: int) -> str:
global leds
led = leds[number - 1]
led[1] = not led[1]
gpio.output(led[0], int(led[1]))
@ -26,8 +27,8 @@ async def toggle(number: int) -> str:
for i, iled in enumerate(leds):
if iled[0] == led[0]: continue
gpio.output(led[0], True)
leds[i][1] = True
iled[1] = True
gpio.output(iled[0], iled[1])
return f"TOGGLE OK, NEW STATE: {'ON' if led[1] else 'OFF'}"