Expanded verbose options
This commit is contained in:
@@ -16,8 +16,9 @@ class Button:
|
|||||||
presstime=0
|
presstime=0
|
||||||
ignore=0
|
ignore=0
|
||||||
|
|
||||||
def __init__(self, gpio):
|
def __init__(self, gpio,verbose=False):
|
||||||
print("initialize button on gpio %d" %gpio)
|
if verbose:
|
||||||
|
print("initialize button on gpio %d" %gpio)
|
||||||
self.gpio = gpio
|
self.gpio = gpio
|
||||||
GPIO.setup(self.gpio, GPIO.IN, pull_up_down = GPIO.PUD_UP)
|
GPIO.setup(self.gpio, GPIO.IN, pull_up_down = GPIO.PUD_UP)
|
||||||
GPIO.add_event_detect(self.gpio, GPIO.BOTH, callback=self.my_callback)
|
GPIO.add_event_detect(self.gpio, GPIO.BOTH, callback=self.my_callback)
|
||||||
|
|||||||
61
clocky.py
61
clocky.py
@@ -6,6 +6,7 @@ import time
|
|||||||
import sys
|
import sys
|
||||||
import tm1637
|
import tm1637
|
||||||
import max7219
|
import max7219
|
||||||
|
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
||||||
import pygame
|
import pygame
|
||||||
from time import sleep,strftime
|
from time import sleep,strftime
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
@@ -13,6 +14,7 @@ import button
|
|||||||
import signal
|
import signal
|
||||||
import clockytracklist
|
import clockytracklist
|
||||||
|
|
||||||
|
VERBOSE=False
|
||||||
settings= {}
|
settings= {}
|
||||||
looptype=0
|
looptype=0
|
||||||
quit=0
|
quit=0
|
||||||
@@ -49,7 +51,10 @@ reload=False
|
|||||||
def receive_signal(signum, stack):
|
def receive_signal(signum, stack):
|
||||||
global stopprogram
|
global stopprogram
|
||||||
global reload
|
global reload
|
||||||
print('Received signal: %d' %signum)
|
if VERBOSE:
|
||||||
|
print('Received signal: %d' %signum)
|
||||||
|
else:
|
||||||
|
print("")
|
||||||
if signum == signal.SIGHUP:
|
if signum == signal.SIGHUP:
|
||||||
reload=True
|
reload=True
|
||||||
if signum == signal.SIGINT:
|
if signum == signal.SIGINT:
|
||||||
@@ -81,35 +86,40 @@ brightness=0
|
|||||||
snooze=0
|
snooze=0
|
||||||
count=0
|
count=0
|
||||||
|
|
||||||
print('My PID is %d' %os.getpid())
|
if VERBOSE:
|
||||||
|
print('My PID is %d' %os.getpid())
|
||||||
signal.signal(signal.SIGHUP, receive_signal)
|
signal.signal(signal.SIGHUP, receive_signal)
|
||||||
signal.signal(signal.SIGINT, receive_signal)
|
signal.signal(signal.SIGINT, receive_signal)
|
||||||
|
|
||||||
but1=button.Button(21)
|
but1=button.Button(21,verbose=VERBOSE)
|
||||||
but2=button.Button(20)
|
but2=button.Button(20,verbose=VERBOSE)
|
||||||
but3=button.Button(26)
|
but3=button.Button(26,verbose=VERBOSE)
|
||||||
|
|
||||||
#------------------------------------------------------------------
|
#------------------------------------------------------------------
|
||||||
#------------------------------------------------------------------
|
#------------------------------------------------------------------
|
||||||
|
|
||||||
while not stopprogram:
|
while not stopprogram:
|
||||||
print("Load config...")
|
if VERBOSE:
|
||||||
|
print("Load config...")
|
||||||
reload=False
|
reload=False
|
||||||
|
|
||||||
# display=tm1637.TM1637(CLK=14, DIO=4, brightness=1)
|
display=tm1637.TM1637(CLK=14, DIO=4, brightness=1)
|
||||||
display=max7219.MAX7219(brightness=1)
|
# display=max7219.MAX7219(brightness=1)
|
||||||
|
|
||||||
display.Clear()
|
display.Clear()
|
||||||
display.SetBrightnessRaw(o_defaultbrightness)
|
display.SetBrightnessRaw(o_defaultbrightness)
|
||||||
|
|
||||||
print("reading mp3s from directory:")
|
if VERBOSE:
|
||||||
tracks=clockytracklist.ClockyTracklist("mp3",recursive=True,verbose=True)
|
print("Reading mp3s from directory:")
|
||||||
|
tracks=clockytracklist.ClockyTracklist("mp3",recursive=True,verbose=VERBOSE)
|
||||||
allmp3s=tracks.tracklist
|
allmp3s=tracks.tracklist
|
||||||
|
|
||||||
c=0
|
c=0
|
||||||
for m in allmp3s:
|
if VERBOSE:
|
||||||
print(" %2d : %s"%(c+1,m))
|
print("\nTracks:")
|
||||||
c+=1
|
for m in allmp3s:
|
||||||
|
print("%2d : %s"%(c+1,m))
|
||||||
|
c+=1
|
||||||
|
|
||||||
stamp()
|
stamp()
|
||||||
print("Started")
|
print("Started")
|
||||||
@@ -129,7 +139,8 @@ while not stopprogram:
|
|||||||
handle.close()
|
handle.close()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Configfile: \""+o_configfilename+"\":")
|
if VERBOSE:
|
||||||
|
print("Configfile: \""+o_configfilename+"\":")
|
||||||
|
|
||||||
with open(o_configfilename, 'rb') as handle:
|
with open(o_configfilename, 'rb') as handle:
|
||||||
settings = pickle.load(handle)
|
settings = pickle.load(handle)
|
||||||
@@ -137,21 +148,27 @@ while not stopprogram:
|
|||||||
|
|
||||||
a_mins=int(settings['alarmtime']%60)
|
a_mins=int(settings['alarmtime']%60)
|
||||||
a_hour=int((settings['alarmtime']-a_mins)/60)
|
a_hour=int((settings['alarmtime']-a_mins)/60)
|
||||||
print("Alarmtime : %02d:%02d"%(a_hour,a_mins))
|
if VERBOSE:
|
||||||
print("Alarmdisable: %d"%(settings['alarmdisabled']))
|
print("Alarmtime : %02d:%02d"%(a_hour,a_mins))
|
||||||
print("Starttrack : %d"%(settings['starttrack']))
|
print("Alarmdisable: %d"%(settings['alarmdisabled']))
|
||||||
|
print("Starttrack : %d"%(settings['starttrack']))
|
||||||
|
|
||||||
for i in range(0,10):
|
for i in range(0,10):
|
||||||
if i==settings['starttrack']:
|
if i==settings['starttrack']:
|
||||||
print("=>",end='')
|
if VERBOSE:
|
||||||
|
print("=>",end='')
|
||||||
else:
|
else:
|
||||||
print(" ",end='')
|
if VERBOSE:
|
||||||
print(" [T%01dM%02d] "%(i,settings["track%d"%i]),end='')
|
print(" ",end='')
|
||||||
|
if VERBOSE:
|
||||||
|
print(" [T%01dM%02d] "%(i,settings["track%d"%i]),end='')
|
||||||
if settings["track%d"%i] and (settings["track%d"%i]-1 < len(allmp3s)):
|
if settings["track%d"%i] and (settings["track%d"%i]-1 < len(allmp3s)):
|
||||||
|
if VERBOSE:
|
||||||
print("\""+allmp3s[settings["track%d"%i]-1]+"\"")
|
print("\""+allmp3s[settings["track%d"%i]-1]+"\"")
|
||||||
else:
|
else:
|
||||||
|
if VERBOSE:
|
||||||
print("")
|
print("")
|
||||||
settings["track%d"%i]=0
|
settings["track%d"%i]=0
|
||||||
writesettings()
|
writesettings()
|
||||||
|
|
||||||
|
|
||||||
@@ -472,7 +489,7 @@ while not stopprogram:
|
|||||||
|
|
||||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
if looptype==5: # Alarm!
|
if looptype==5: # Alarm loop!
|
||||||
#o_timetomaxvol = 60 # seconds it takes to go from 0% to 100% volume
|
#o_timetomaxvol = 60 # seconds it takes to go from 0% to 100% volume
|
||||||
|
|
||||||
if colon:
|
if colon:
|
||||||
|
|||||||
Reference in New Issue
Block a user