mirror of
https://github.com/RGBCube/GDUS
synced 2025-07-28 13:37:45 +00:00
Fix led toggle code 2
This commit is contained in:
parent
04a391db82
commit
bbebd7b63c
1 changed files with 4 additions and 9 deletions
13
rpid/main.py
13
rpid/main.py
|
@ -20,19 +20,14 @@ app = FastAPI()
|
|||
async def toggle(number: int) -> str:
|
||||
global leds
|
||||
led = leds[number - 1]
|
||||
|
||||
led[1] = not led[1]
|
||||
gpio.output(led[0], int(led[1]))
|
||||
|
||||
turn_off = leds.copy()
|
||||
turn_off.remove(led)
|
||||
for i, iled in enumerate(turn_off):
|
||||
if iled[0] == led[0]: continue
|
||||
|
||||
leds[number - 1][1] = not led[1]
|
||||
|
||||
# Horrible code, but time is running out and so is
|
||||
# my motivation for this project.
|
||||
for led in turn_off:
|
||||
gpio.output(led[0], True)
|
||||
leds[leds.index(led)][1] = True
|
||||
leds[i][1] = True
|
||||
|
||||
return f"TOGGLE OK, NEW STATE: {'ON' if led[1] else 'OFF'}"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue