I’m asking for some ‘basic’ help here, or a least a guide in the right direction!
I’m wanting to build a pomodoro timer using the Touch pHAT with a Unicorn pHAT (or Blinkt but they don’t play nicely together yet).
I’d like to be able to pause the timer for when I’m interrupted; so essentially the same controls as a stopwatch, ‘stop, start, reset’.
I don’t know if I’m even using the correct or best approach, but I currently have a nested loop:
@touchphat.on_release('A') def handle_touch(event): endTime = datetime.datetime.now() + datetime.timedelta(minutes=20) while True: for t in range (20): # 20 x 60 seconds for t in range (60): # 60 seconds time.sleep(1) # 1 second if datetime.datetime.now() >= endTime: break # this loop locks up, and needs some kind of interrupt
My problem is that I don’t know the terminology or key words to search for with regards to this. I have found endless examples of timers of various kinds, but I can’t find answers to the questions I’m trying to ask!!
Could someone help please?