From a4307e767a0bd75f93771cb8419217c57f1ff9c0 Mon Sep 17 00:00:00 2001 From: starcalc Date: Mon, 29 Jun 2020 22:41:53 +0100 Subject: [PATCH] Simultan korrigiert --- Pi/s.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) mode change 100644 => 100755 Pi/s.py diff --git a/Pi/s.py b/Pi/s.py old mode 100644 new mode 100755 index 5ada0f5..9b9aad2 --- a/Pi/s.py +++ b/Pi/s.py @@ -14,24 +14,30 @@ SoundFF = pygame.mixer.Sound('ogg/F#3v16.ogg') # port = serial.Serial("/dev/ttyS0", baudrate=115200, timeout=.001) port = serial.Serial("/dev/ttyS0", baudrate=115200) +# port = serial.Serial("/dev/ttyAMA0", baudrate=115200) SoundA.play(); - +oldrcv = port.read() while True: # rcv decodieren rcv = port.read() + # Zustand merken, und nur "neu" starten, wenn sich etwas von 0 auf 1 veraendert hat. if rcv[0] & ( 1 << 1 ) : - print("1"); - SoundC.stop() - SoundC.play() + if not oldrcv[0] & ( 1 << 1 ): + print("1"); + SoundC.stop() + SoundC.play() else: SoundC.stop() + rcvstate0 = False if rcv[0] & ( 1 << 0 ) : - print("0"); - SoundA.stop() - SoundA.play() + if not oldrcv[0] & ( 1 << 0 ): + print("0"); + SoundA.stop() + SoundA.play() else: SoundA.stop() + oldrcv = rcv