From a4ad0da943d899b38bf5cdaea0599fcf33c33135 Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Sat, 7 Nov 2020 22:33:55 -0500 Subject: [PATCH] fix variable issue? --- leds.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/leds.py b/leds.py index ef3fa55..0fc1214 100644 --- a/leds.py +++ b/leds.py @@ -7,14 +7,17 @@ # from time import sleep +import sys import lcd_manager import light_manager import logging -level = 0 -level_max = 14 -level_state = 0 -color_state = 0 +this = sys.modules[__name__] + +this.level = 0 +this.level_max = 14 +this.level_state = 0 +this.color_state = 0 def lightlevel(lcd, level): @@ -34,11 +37,11 @@ def color(lcd): def get_state(): - if level_state > 0: - level_state -= 1 + if this.level_state > 0: + this.level_state -= 1 return "level" - elif color_state > 0: - color_state -= 1 + elif this.color_state > 0: + this.color_state -= 1 return "color" else: return "idle" @@ -59,9 +62,9 @@ def loop(): state = get_state() if state == "level": - if lights.get_light_level() != (level / level_max): - lights.set_light_level(level / level_max) - lightlevel(lcd, level) + if lights.get_light_level() != (this.level / this.level_max): + lights.set_light_level(this.level / this.level_max) + lightlevel(lcd, this.level) elif state == "color": color(lcd) else: