Expanded verbose options
This commit is contained in:
@@ -16,7 +16,8 @@ class Button:
|
||||
presstime=0
|
||||
ignore=0
|
||||
|
||||
def __init__(self, gpio):
|
||||
def __init__(self, gpio,verbose=False):
|
||||
if verbose:
|
||||
print("initialize button on gpio %d" %gpio)
|
||||
self.gpio = gpio
|
||||
GPIO.setup(self.gpio, GPIO.IN, pull_up_down = GPIO.PUD_UP)
|
||||
|
||||
37
clocky.py
37
clocky.py
@@ -6,6 +6,7 @@ import time
|
||||
import sys
|
||||
import tm1637
|
||||
import max7219
|
||||
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
|
||||
import pygame
|
||||
from time import sleep,strftime
|
||||
import RPi.GPIO as GPIO
|
||||
@@ -13,6 +14,7 @@ import button
|
||||
import signal
|
||||
import clockytracklist
|
||||
|
||||
VERBOSE=False
|
||||
settings= {}
|
||||
looptype=0
|
||||
quit=0
|
||||
@@ -49,7 +51,10 @@ reload=False
|
||||
def receive_signal(signum, stack):
|
||||
global stopprogram
|
||||
global reload
|
||||
if VERBOSE:
|
||||
print('Received signal: %d' %signum)
|
||||
else:
|
||||
print("")
|
||||
if signum == signal.SIGHUP:
|
||||
reload=True
|
||||
if signum == signal.SIGINT:
|
||||
@@ -81,34 +86,39 @@ brightness=0
|
||||
snooze=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.SIGINT, receive_signal)
|
||||
|
||||
but1=button.Button(21)
|
||||
but2=button.Button(20)
|
||||
but3=button.Button(26)
|
||||
but1=button.Button(21,verbose=VERBOSE)
|
||||
but2=button.Button(20,verbose=VERBOSE)
|
||||
but3=button.Button(26,verbose=VERBOSE)
|
||||
|
||||
#------------------------------------------------------------------
|
||||
#------------------------------------------------------------------
|
||||
|
||||
while not stopprogram:
|
||||
if VERBOSE:
|
||||
print("Load config...")
|
||||
reload=False
|
||||
|
||||
# display=tm1637.TM1637(CLK=14, DIO=4, brightness=1)
|
||||
display=max7219.MAX7219(brightness=1)
|
||||
display=tm1637.TM1637(CLK=14, DIO=4, brightness=1)
|
||||
# display=max7219.MAX7219(brightness=1)
|
||||
|
||||
display.Clear()
|
||||
display.SetBrightnessRaw(o_defaultbrightness)
|
||||
|
||||
print("reading mp3s from directory:")
|
||||
tracks=clockytracklist.ClockyTracklist("mp3",recursive=True,verbose=True)
|
||||
if VERBOSE:
|
||||
print("Reading mp3s from directory:")
|
||||
tracks=clockytracklist.ClockyTracklist("mp3",recursive=True,verbose=VERBOSE)
|
||||
allmp3s=tracks.tracklist
|
||||
|
||||
c=0
|
||||
if VERBOSE:
|
||||
print("\nTracks:")
|
||||
for m in allmp3s:
|
||||
print(" %2d : %s"%(c+1,m))
|
||||
print("%2d : %s"%(c+1,m))
|
||||
c+=1
|
||||
|
||||
stamp()
|
||||
@@ -129,6 +139,7 @@ while not stopprogram:
|
||||
handle.close()
|
||||
|
||||
else:
|
||||
if VERBOSE:
|
||||
print("Configfile: \""+o_configfilename+"\":")
|
||||
|
||||
with open(o_configfilename, 'rb') as handle:
|
||||
@@ -137,19 +148,25 @@ while not stopprogram:
|
||||
|
||||
a_mins=int(settings['alarmtime']%60)
|
||||
a_hour=int((settings['alarmtime']-a_mins)/60)
|
||||
if VERBOSE:
|
||||
print("Alarmtime : %02d:%02d"%(a_hour,a_mins))
|
||||
print("Alarmdisable: %d"%(settings['alarmdisabled']))
|
||||
print("Starttrack : %d"%(settings['starttrack']))
|
||||
|
||||
for i in range(0,10):
|
||||
if i==settings['starttrack']:
|
||||
if VERBOSE:
|
||||
print("=>",end='')
|
||||
else:
|
||||
if VERBOSE:
|
||||
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 VERBOSE:
|
||||
print("\""+allmp3s[settings["track%d"%i]-1]+"\"")
|
||||
else:
|
||||
if VERBOSE:
|
||||
print("")
|
||||
settings["track%d"%i]=0
|
||||
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
|
||||
|
||||
if colon:
|
||||
|
||||
Reference in New Issue
Block a user