attempt idle timeout fix

This commit is contained in:
janeptrv 2020-11-03 20:44:08 -05:00
parent 76715d1dc2
commit 3217cf177d

44
leds.py
View file

@ -239,23 +239,33 @@ class Adafruit_CharLCD:
self.write4bits(ord(char), True)
debug_statements = True
def debug(msg):
if debug_statements:
print(msg)
def lightlevel(lcd, level):
print("display level")
debug("display level")
lcd.clear()
lcd.message("Light Level:\n]" + "-"*level + "[")
def querylightlevel():
print("NYI")
return 7
debug("NYI")
return 7
def color(lcd, col):
lcd.clear()
lcd.message("new color:\n#" + col)
print("NYI")
lcd.message("new color:\n#{}".format(col))
debug("NYI")
def querycolor():
print("NYI")
debug("NYI")
return "ffffff"
@ -267,22 +277,30 @@ def loop():
idle = 0
idle_max = 15
cur_color = "ffffff"
print("loop")
debug("loop")
query_color = querycolor()
level = querylightlevel()
query_level = querylightlevel()
idle = idle + 1
if idle >= idle_max:
idle = idle_max
lcd.noDisplay()
elif query_color != cur_color:
debug("idle value: {}".format(idle))
if query_color != cur_color:
if lcd.displaycontrol & lcd.LCD_DISPLAYON != lcd.displaycontrol:
lcd.display()
ccolor = query_color
idle = 0
color(lcd, cur_color)
else:
elif query_level != level:
level = query_level
idle = 0
if lcd.displaycontrol & lcd.LCD_DISPLAYON != lcd.displaycontrol:
lcd.display()
lightlevel(lcd, level)
elif idle >= idle_max:
debug("hit idle threshold")
idle = idle_max
lcd.noDisplay()
else:
lightlevel(lcd, level)
sleep(1)