debugging

This commit is contained in:
janeptrv 2020-11-06 23:12:10 -05:00
parent bbb394e3c1
commit 88ed80b17f
3 changed files with 17 additions and 15 deletions

21
leds.py
View file

@ -9,31 +9,24 @@
from time import sleep
import lcd_manager
import light_manager
debug_statements = True
def debug(msg):
if debug_statements:
print(msg)
import logging
def lightlevel(lcd, level):
debug("display level")
logging.debug("display level")
lcd.clear()
lcd.message("Light Level:\n]" + "-"*level + "[")
def querylightlevel():
debug("NYI")
logging.debug("NYI")
return 7
def color(lcd):
lcd.clear()
lcd.message("new pattern loaded.")
debug("NYI")
logging.debug("NYI")
def loop():
@ -45,10 +38,10 @@ def loop():
idle_max = 15
cur_color = (255, 255, 255)
while True:
debug("loop")
logging.debug("loop")
query_level = querylightlevel()
idle = idle + 1
debug("idle value: {}".format(idle))
logging.debug("idle value: {}".format(idle))
lights.tick()
if query_level != level:
level = query_level
@ -58,7 +51,7 @@ def loop():
lcd.display()
lightlevel(lcd, level)
elif idle >= idle_max:
debug("hit idle threshold")
logging.debug("hit idle threshold")
idle = idle_max
lcd.noDisplay()
else:

View file

@ -1,6 +1,7 @@
from time import sleep
import neopixel
import board
import logging
def defaultPattern(n, t):
return (255, 0, 200)
@ -26,6 +27,6 @@ class LightStrip:
col = self.pattern(i, t)
if np[i] != col:
np[i] = col
#print("CHANGE COLOR OF PIXEL {} ON TICK {}".format(col, t))
logging.debug("CHANGE COLOR OF PIXEL {} TO {} ON TICK {}".format(i, col, t))
break;
self.cur_tick = t + 1

8
logging.py Normal file
View file

@ -0,0 +1,8 @@
debug_statements = True
def debug(msg):
if debug_statements:
print(msg)
def info(msg):
print(msg)