fixed volume bug

This commit is contained in:
Jan
2019-09-24 16:37:36 +02:00
parent f9472e4492
commit 4373290b66

View File

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