fixed volume bug
This commit is contained in:
16
clocky.py
16
clocky.py
@@ -36,8 +36,8 @@ GPIO.setup(20, GPIO.IN, pull_up_down = GPIO.PUD_UP)
|
|||||||
|
|
||||||
def showclock(tstr):
|
def showclock(tstr):
|
||||||
"Show da clock"
|
"Show da clock"
|
||||||
# sys.stdout.write( "%s [%d]\r" % (tstr,looptype))
|
sys.stdout.write( "%s [%d]\r" % (tstr,looptype))
|
||||||
# sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
d=0
|
d=0
|
||||||
if tstr[2]==':':
|
if tstr[2]==':':
|
||||||
@@ -169,7 +169,6 @@ writesettings()
|
|||||||
print ""
|
print ""
|
||||||
|
|
||||||
print strftime("Starting: %d %b %Y %H:%M:%S")
|
print strftime("Starting: %d %b %Y %H:%M:%S")
|
||||||
sys.stdout.flush()
|
|
||||||
#------------------------------------------------------------------
|
#------------------------------------------------------------------
|
||||||
while quit!=True:
|
while quit!=True:
|
||||||
count+=1;
|
count+=1;
|
||||||
@@ -286,7 +285,6 @@ while quit!=True:
|
|||||||
writesettings()
|
writesettings()
|
||||||
sys.stdout.write(strftime("%d %b %Y %H:%M:%S : "))
|
sys.stdout.write(strftime("%d %b %Y %H:%M:%S : "))
|
||||||
print "set alarmtime = %d%d:%d%d"%(dh,sh,dm,sm)
|
print "set alarmtime = %d%d:%d%d"%(dh,sh,dm,sm)
|
||||||
sys.stdout.flush()
|
|
||||||
else:
|
else:
|
||||||
showtime+=o_loopdelay
|
showtime+=o_loopdelay
|
||||||
|
|
||||||
@@ -316,7 +314,6 @@ while quit!=True:
|
|||||||
if but2.WasPressed():
|
if but2.WasPressed():
|
||||||
if settings["track%d"%track]>0:
|
if settings["track%d"%track]>0:
|
||||||
print (allmp3s[settings["track%d"%track]-1])
|
print (allmp3s[settings["track%d"%track]-1])
|
||||||
sys.stdout.flush()
|
|
||||||
if not pygame.mixer.get_init():
|
if not pygame.mixer.get_init():
|
||||||
pygame.mixer.init()
|
pygame.mixer.init()
|
||||||
pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1])
|
pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1])
|
||||||
@@ -440,7 +437,6 @@ while quit!=True:
|
|||||||
sys.stdout.write(strftime("%d %b %Y %H:%M:%S : "))
|
sys.stdout.write(strftime("%d %b %Y %H:%M:%S : "))
|
||||||
track=settings['starttrack'];
|
track=settings['starttrack'];
|
||||||
print "[%d] - %02d %s"%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))
|
print "[%d] - %02d %s"%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))
|
||||||
sys.stdout.flush()
|
|
||||||
if not pygame.mixer.get_init():
|
if not pygame.mixer.get_init():
|
||||||
pygame.mixer.init()
|
pygame.mixer.init()
|
||||||
pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1])
|
pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1])
|
||||||
@@ -460,19 +456,15 @@ while quit!=True:
|
|||||||
brightness=(playtime / o_timetomaxvol)*6
|
brightness=(playtime / o_timetomaxvol)*6
|
||||||
volume = float(int((playtime*100) / o_timetomaxvol))/100
|
volume = float(int((playtime*100) / o_timetomaxvol))/100
|
||||||
# print "------> %d / %d => %f - %f"%(playtime,o_timetomaxvol,tvol,volume)
|
# print "------> %d / %d => %f - %f"%(playtime,o_timetomaxvol,tvol,volume)
|
||||||
else:
|
|
||||||
volume=1
|
|
||||||
|
|
||||||
if pygame.mixer.get_init():
|
|
||||||
pygame.mixer.music.set_volume(volume)
|
pygame.mixer.music.set_volume(volume)
|
||||||
|
else:
|
||||||
|
pygame.mixer.music.set_volume(1)
|
||||||
playtime+=o_loopdelay
|
playtime+=o_loopdelay
|
||||||
|
|
||||||
if not pygame.mixer.music.get_busy():
|
if not pygame.mixer.music.get_busy():
|
||||||
track=settings['starttrack']
|
track=settings['starttrack']
|
||||||
sys.stdout.write(strftime("%d %b %Y %H:%M:%S : "))
|
sys.stdout.write(strftime("%d %b %Y %H:%M:%S : "))
|
||||||
print "[%d] - %02d %s"%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))
|
print "[%d] - %02d %s"%(track,settings["track%d"%track],(allmp3s[settings["track%d"%track]-1]))
|
||||||
sys.stdout.flush()
|
|
||||||
pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1])
|
pygame.mixer.music.load(allmp3s[settings["track%d"%track]-1])
|
||||||
pygame.mixer.music.play()
|
pygame.mixer.music.play()
|
||||||
track+=1
|
track+=1
|
||||||
|
|||||||
Reference in New Issue
Block a user