fix variable issue?

This commit is contained in:
jane 2020-11-07 22:33:55 -05:00
parent d2a4cf3bc2
commit a4ad0da943
1 changed files with 14 additions and 11 deletions

25
leds.py
View File

@ -7,14 +7,17 @@
# #
from time import sleep from time import sleep
import sys
import lcd_manager import lcd_manager
import light_manager import light_manager
import logging import logging
level = 0 this = sys.modules[__name__]
level_max = 14
level_state = 0 this.level = 0
color_state = 0 this.level_max = 14
this.level_state = 0
this.color_state = 0
def lightlevel(lcd, level): def lightlevel(lcd, level):
@ -34,11 +37,11 @@ def color(lcd):
def get_state(): def get_state():
if level_state > 0: if this.level_state > 0:
level_state -= 1 this.level_state -= 1
return "level" return "level"
elif color_state > 0: elif this.color_state > 0:
color_state -= 1 this.color_state -= 1
return "color" return "color"
else: else:
return "idle" return "idle"
@ -59,9 +62,9 @@ def loop():
state = get_state() state = get_state()
if state == "level": if state == "level":
if lights.get_light_level() != (level / level_max): if lights.get_light_level() != (this.level / this.level_max):
lights.set_light_level(level / level_max) lights.set_light_level(this.level / this.level_max)
lightlevel(lcd, level) lightlevel(lcd, this.level)
elif state == "color": elif state == "color":
color(lcd) color(lcd)
else: else: