Apr-15-2020, 10:02 AM
(This post was last modified: Apr-15-2020, 10:02 AM by gerrit1985.)
(Apr-09-2020, 12:26 PM)deanhystad Wrote:while True: key.wait_for_press(timeout) # timeout is seconds as a float, 120 = 2mins if not key.is_pressed(): resetstuff() else: key_down_time = time.time() #record the time when the key went down tone_obj.play(-1) #the -1 means to loop the sound
Thank you very much, i tried it but i get following response:
Quote:File "./morse-code2.py", line 72
else:
^
IndentationError: unindent does not match any outer indentation level
while True: key.wait_for_press(120) if not key.is_pressed(): os.system("clear") # Linux - OSX print("Welkom bij de morse emulator van maritiem centrum Ameland") else: key_down_time = time.time() #record the time when the key went down tone_obj.play(-1) #the -1 means to loop the sound key.wait_for_release() key_up_time = time.time() #record the time when the key was released key_down_length = key_up_time - key_down_time #get the length of time it was held down for tone_obj.stop() buffer.append(DASH if key_down_length > 0.20 else DOT)