mirror of
https://github.com/RGBCube/GDUS
synced 2025-07-28 13:37:45 +00:00
Fix led toggle code 4
This commit is contained in:
parent
91f0093f81
commit
48412cd4da
1 changed files with 3 additions and 2 deletions
|
@ -19,6 +19,7 @@ app = FastAPI()
|
||||||
@app.get("/led/toggle")
|
@app.get("/led/toggle")
|
||||||
async def toggle(number: int) -> str:
|
async def toggle(number: int) -> str:
|
||||||
global leds
|
global leds
|
||||||
|
|
||||||
led = leds[number - 1]
|
led = leds[number - 1]
|
||||||
led[1] = not led[1]
|
led[1] = not led[1]
|
||||||
gpio.output(led[0], int(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):
|
for i, iled in enumerate(leds):
|
||||||
if iled[0] == led[0]: continue
|
if iled[0] == led[0]: continue
|
||||||
|
|
||||||
gpio.output(led[0], True)
|
iled[1] = True
|
||||||
leds[i][1] = True
|
gpio.output(iled[0], iled[1])
|
||||||
|
|
||||||
return f"TOGGLE OK, NEW STATE: {'ON' if led[1] else 'OFF'}"
|
return f"TOGGLE OK, NEW STATE: {'ON' if led[1] else 'OFF'}"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue