From af3153b5b37858304b79007d7d1f3fce7571431f Mon Sep 17 00:00:00 2001 From: RGBCube Date: Fri, 29 Dec 2023 15:20:11 +0300 Subject: [PATCH] Fix bug in led closing logic --- rpid/main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rpid/main.py b/rpid/main.py index ea99905..e93b975 100644 --- a/rpid/main.py +++ b/rpid/main.py @@ -25,12 +25,15 @@ async def toggle(number: int) -> str: gpio.output(led[0], int(led[1])) - turn_off = leds.copy().remove(led) - del turn_off[0] # () + turn_off = leds.copy() + turn_off.remove(led) + turn_off.remove(()) - for i, led in enumerate(turn_off): + # 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[i + 1][1] = True + leds[leds.index(led)][1] = True return f"TOGGLE OK, NEW STATE: {'ON' if led[1] else 'OFF'}"