def playRoutine(self,routine):
moves = routine[0] # reads in list of moves
total = 0
moveBeats = []
for b in routine[1]: # constructs a list of beat to switch move
total += b
moveBeats.append(total)
beats = 0
move = 0
secPerBeat = 60/routine[2] #convert bpm to seconds per beat
startTime = time.time()
while beats < moveBeats[-1]:
try: #deals with end of list
self.ids.current.text = moves[move] #changes display
self.ids.next.text = moves[move+1]
except:
self.ids.current.text = moves[move]
self.ids.next.text = ""
while beats < moveBeats[move]:
beats += 1
#sleep for the correct time for next beat
time.sleep(startTime+beats*secPerBeat-time.time())
self.flash()
move += 1
def flash(self):
'''Temp: displays word flash every beat.
to do: switch to flash background and
add optional tick'''
self.ids.flasher.text = "flash"
time.sleep (0.05)
self.ids.flasher.text = ""