Compare commits

..

No commits in common. "0f7c74fe78f3e40c84f5ebcad97591c70c1f9d28" and "d0f78ab0d8a23fb2fc1307315fb613312ef14a33" have entirely different histories.

1 changed files with 30 additions and 28 deletions

54
Pi/s.py
View File

@ -11,23 +11,9 @@ pygame.mixer.init(buffer=32)
#SoundC = pygame.mixer.Sound('ogg/C3v16.ogg') #SoundC = pygame.mixer.Sound('ogg/C3v16.ogg')
#SoundA = pygame.mixer.Sound('ogg/A3v16.ogg') #SoundA = pygame.mixer.Sound('ogg/A3v16.ogg')
#SoundFF = pygame.mixer.Sound('ogg/F#3v16.ogg') #SoundFF = pygame.mixer.Sound('ogg/F#3v16.ogg')
Sound = [pygame.mixer.Sound('guitar/guitar_C4_very-long_forte_normal.wav'), SoundC = pygame.mixer.Sound('guitar/guitar_C4_very-long_forte_normal.wav')
pygame.mixer.Sound('guitar/guitar_D4_very-long_forte_normal.wav'), SoundD = pygame.mixer.Sound('guitar/guitar_D4_very-long_forte_normal.wav')
pygame.mixer.Sound('guitar/guitar_E4_very-long_forte_normal.wav'), SoundE = pygame.mixer.Sound('guitar/guitar_E4_very-long_forte_normal.wav')
pygame.mixer.Sound('guitar/guitar_F4_very-long_forte_normal.wav'),
pygame.mixer.Sound('guitar/guitar_G4_very-long_forte_normal.wav'),
pygame.mixer.Sound('guitar/guitar_A4_very-long_forte_normal.wav'),
pygame.mixer.Sound('guitar/guitar_H4_very-long_forte_normal.wav'),
pygame.mixer.Sound('guitar/guitar_C5_very-long_forte_normal.wav')
]
#SoundC = pygame.mixer.Sound('guitar/guitar_C4_very-long_forte_normal.wav')
#SoundD = pygame.mixer.Sound('guitar/guitar_D4_very-long_forte_normal.wav')
#SoundE = pygame.mixer.Sound('guitar/guitar_E4_very-long_forte_normal.wav')
#SoundF = pygame.mixer.Sound('guitar/guitar_F4_very-long_forte_normal.wav')
#SoundG = pygame.mixer.Sound('guitar/guitar_G4_very-long_forte_normal.wav')
#SoundA = pygame.mixer.Sound('guitar/guitar_A4_very-long_forte_normal.wav')
#SoundH = pygame.mixer.Sound('guitar/guitar_H4_very-long_forte_normal.wav')
#SoundC2 = pygame.mixer.Sound('guitar/guitar_C5_very-long_forte_normal.wav')
# port = serial.Serial("/dev/ttyS0", baudrate=115200, timeout=.001) # port = serial.Serial("/dev/ttyS0", baudrate=115200, timeout=.001)
port = serial.Serial("/dev/ttyS0", baudrate=115200) port = serial.Serial("/dev/ttyS0", baudrate=115200)
@ -37,17 +23,33 @@ oldrcv = port.read()
while True: while True:
# rcv decodieren # rcv decodieren
rcv = port.read() rcv = port.read()
i=0
# Zustand merken, und nur "neu" starten, wenn sich etwas von 0 auf 1 veraendert hat. # Zustand merken, und nur "neu" starten, wenn sich etwas von 0 auf 1 veraendert hat.
for cs in Sound:
if rcv[0] & ( 1 << i ) : if rcv[0] & ( 1 << 2 ) :
if not oldrcv[0] & ( 1 << i ): if not oldrcv[0] & ( 1 << 2 ):
print(i) print("1");
cs.stop() SoundE.stop()
cs.play() SoundE.play()
i+=1
else: else:
cs.stop() SoundE.stop()
rcvstate0 = False rcvstate0 = False
if rcv[0] & ( 1 << 1 ) :
if not oldrcv[0] & ( 1 << 1 ):
print("1");
SoundD.stop()
SoundD.play()
else:
SoundD.stop()
rcvstate0 = False
if rcv[0] & ( 1 << 0 ) :
if not oldrcv[0] & ( 1 << 0 ):
print("0");
SoundC.stop()
SoundC.play()
else:
SoundC.stop()
oldrcv = rcv oldrcv = rcv