Python Forum
reset on inactivity (building a morse decoder)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reset on inactivity (building a morse decoder)
#3
(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)
Reply


Messages In This Thread
RE: reset on inactivity (building a morse decoder) - by gerrit1985 - Apr-15-2020, 10:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  (python) Can i get some help fixing a English to Morse translator? Pls AlexPython 8 3,415 Dec-03-2024, 10:21 AM
Last Post: skylartyler
  How can i fix json.decoder.JSONDecodeError ? JgKSuperstar 9 7,288 Oct-30-2021, 11:23 PM
Last Post: JgKSuperstar
  How to fix bugs in Morse alphabet code? dokipo 10 4,955 Oct-26-2021, 06:43 PM
Last Post: deanhystad
  How to reset row value in pandas Mekala 0 2,056 Sep-19-2020, 09:36 AM
Last Post: Mekala
  coding a decoder... Popkhorn 2 2,865 May-28-2020, 07:26 AM
Last Post: Popkhorn
  Reset a variable mln4python 4 10,653 Aug-19-2019, 08:28 AM
Last Post: mln4python
  UTF-8 decoder reports bad byte that is not there Skaperen 0 2,988 Oct-11-2018, 04:46 AM
Last Post: Skaperen
  MP4 decoder jdewk 4 7,119 Jan-13-2018, 10:02 PM
Last Post: jdewk
  JSON Decoder issue Cronax3 2 10,738 Sep-13-2017, 09:23 AM
Last Post: Cronax3

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020