Commit f63fc344e51675b4f610fd7407753bffa5d60475
1 parent
a0b18c14
Commit rasp
Showing
2 changed files
with
58 additions
and
3 deletions
Show diff stats
main.py
1 | import python_midi | 1 | import python_midi |
2 | import dico_notes | 2 | import dico_notes |
3 | import sys | 3 | import sys |
4 | -import thread_dd | ||
5 | - | 4 | +import thread_fd |
6 | 5 | ||
7 | def main(args): | 6 | def main(args): |
8 | print "Bienvenue dans le programme de traitement des fichiers MIDI" | 7 | print "Bienvenue dans le programme de traitement des fichiers MIDI" |
9 | print '\n' | 8 | print '\n' |
10 | (p,v,t,f,r) = python_midi.midi_treatment_file("/home/pi/python-midi/mary.mid") | 9 | (p,v,t,f,r) = python_midi.midi_treatment_file("/home/pi/python-midi/mary.mid") |
11 | - print (p,v,t,f,r) | 10 | + thread1 = thread_fd.DD(18,f,t,r) |
11 | + thread2 = thread_fd.DD(13,f,t,r) | ||
12 | + thread1.start() | ||
13 | + thread2.start() | ||
14 | + thread1.join() | ||
15 | + thread2.join() | ||
16 | + | ||
12 | main(sys.argv) | 17 | main(sys.argv) |
@@ -0,0 +1,50 @@ | @@ -0,0 +1,50 @@ | ||
1 | +from threading import Thread | ||
2 | +import time | ||
3 | +from RPi import GPIO | ||
4 | + | ||
5 | +class DD(Thread): | ||
6 | + | ||
7 | + #Constructeur | ||
8 | + def __init__(self, pin, t_frequences, t_tps, res): | ||
9 | + Thread.__init__(self); | ||
10 | + self.pin = pin | ||
11 | + self.t_frequences = t_frequences | ||
12 | + self.t_tps = t_tps | ||
13 | + self.res = res | ||
14 | + | ||
15 | + def run(self): | ||
16 | + p = GPIO.PWM(self.pin,220) | ||
17 | + p.start(15) | ||
18 | + p.ChangeFrequency(self.t_frequences[0]) | ||
19 | + duree = (self.t_tps[0]*1.8)/1000 | ||
20 | + time.sleep(duree) | ||
21 | + i = 1 | ||
22 | + while(i<len(self.t_frequences)): | ||
23 | + p.ChangeFrequency(self.t_frequences[i]) | ||
24 | + duree = (self.t_tps[i]*1.8)/1000 | ||
25 | + time.sleep(duree) | ||
26 | + i+=1 | ||
27 | + p.stop() | ||
28 | + GPIO.cleanup() | ||
29 | + | ||
30 | +GPIO.setmode(GPIO.BCM) | ||
31 | +#DD1 | ||
32 | +GPIO.setup(23,GPIO.OUT) | ||
33 | +GPIO.setup(24,GPIO.OUT) | ||
34 | +GPIO.setup(25,GPIO.OUT) | ||
35 | +#DD2 | ||
36 | +GPIO.setup(16,GPIO.OUT) | ||
37 | +GPIO.setup(20,GPIO.OUT) | ||
38 | +GPIO.setup(21,GPIO.OUT) | ||
39 | +#PWM | ||
40 | +GPIO.setup(18,GPIO.OUT) | ||
41 | +GPIO.setup(13,GPIO.OUT) | ||
42 | +#Act DD1 | ||
43 | +GPIO.output(23,GPIO.LOW) | ||
44 | +GPIO.output(24,GPIO.LOW) | ||
45 | +GPIO.output(25,GPIO.LOW) | ||
46 | +#Act DD2 | ||
47 | +GPIO.output(16,GPIO.LOW) | ||
48 | +GPIO.output(20,GPIO.LOW) | ||
49 | +GPIO.output(21,GPIO.LOW) | ||
50 | + |