attempt idle timeout fix
This commit is contained in:
parent
76715d1dc2
commit
3217cf177d
1 changed files with 31 additions and 13 deletions
44
leds.py
44
leds.py
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue