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

Fix led toggle code

This commit is contained in:
RGBCube 2024-01-10 09:06:25 +03:00
parent 1b15f3798f
commit 04a391db82
No known key found for this signature in database

View file

@ -4,13 +4,12 @@ from fastapi import FastAPI
import RPi.GPIO as gpio
leds = [
(),
(17, True),
(18, True),
(19, True),
[17, True],
[18, True],
[19, True],
]
for led in leds[1::]:
for led in leds:
gpio.setmode(gpio.BCM)
gpio.setup(led[0], gpio.OUT)
gpio.output(led[0], int(led[1]))
@ -20,14 +19,14 @@ app = FastAPI()
@app.get("/led/toggle")
async def toggle(number: int) -> str:
global leds
led = leds[number]
leds[number] = (led[0], not led[1])
led = leds[number - 1]
gpio.output(led[0], int(led[1]))
turn_off = leds.copy()
turn_off.remove(led)
turn_off.remove(())
leds[number - 1][1] = not led[1]
# Horrible code, but time is running out and so is
# my motivation for this project.