Accordeur
/
accordeurguit
programme accordeur guitare valide
main.cpp@0:608629a8a61c, 2019-06-05 (annotated)
- Committer:
- achille
- Date:
- Wed Jun 05 09:40:07 2019 +0000
- Revision:
- 0:608629a8a61c
- Child:
- 2:86f6d5733ae7
avec les notes ;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
achille | 0:608629a8a61c | 1 | #include "fonctions.h" |
achille | 0:608629a8a61c | 2 | |
achille | 0:608629a8a61c | 3 | Ticker recupp; |
achille | 0:608629a8a61c | 4 | /*USBSerial port;*/ |
achille | 0:608629a8a61c | 5 | Serial port(USBTX,USBRX,9600); |
achille | 0:608629a8a61c | 6 | Timer tps; |
achille | 0:608629a8a61c | 7 | |
achille | 0:608629a8a61c | 8 | |
achille | 0:608629a8a61c | 9 | |
achille | 0:608629a8a61c | 10 | volatile donnees t[REC]; |
achille | 0:608629a8a61c | 11 | volatile int i; |
achille | 0:608629a8a61c | 12 | volatile int flag; |
achille | 0:608629a8a61c | 13 | |
achille | 0:608629a8a61c | 14 | void here(){ |
achille | 0:608629a8a61c | 15 | if(i<REC){ |
achille | 0:608629a8a61c | 16 | recup(t,tps.read(),i); |
achille | 0:608629a8a61c | 17 | i++; |
achille | 0:608629a8a61c | 18 | } |
achille | 0:608629a8a61c | 19 | else{ |
achille | 0:608629a8a61c | 20 | flag=1; |
achille | 0:608629a8a61c | 21 | } |
achille | 0:608629a8a61c | 22 | } |
achille | 0:608629a8a61c | 23 | |
achille | 0:608629a8a61c | 24 | int main() { |
achille | 0:608629a8a61c | 25 | port.printf("bonjour \r\n "); |
achille | 0:608629a8a61c | 26 | int flagV=1, flagR1=1, flagR2=1; |
achille | 0:608629a8a61c | 27 | led_set(flagV,flagR1,flagR2); |
achille | 0:608629a8a61c | 28 | wait(1); |
achille | 0:608629a8a61c | 29 | flag=0; |
achille | 0:608629a8a61c | 30 | i=0; |
achille | 0:608629a8a61c | 31 | recupp.attach(&here,0.00001); |
achille | 0:608629a8a61c | 32 | while(1) { |
achille | 0:608629a8a61c | 33 | tps.start(); |
achille | 0:608629a8a61c | 34 | if(flag==1){ |
achille | 0:608629a8a61c | 35 | tps.stop(); |
achille | 0:608629a8a61c | 36 | /* flagV=1; |
achille | 0:608629a8a61c | 37 | flagR1=1; |
achille | 0:608629a8a61c | 38 | flagR2=1; |
achille | 0:608629a8a61c | 39 | led_set(flagV,flagR1,flagR2); |
achille | 0:608629a8a61c | 40 | wait(0.5); |
achille | 0:608629a8a61c | 41 | flagV=0; |
achille | 0:608629a8a61c | 42 | flagR1=0; |
achille | 0:608629a8a61c | 43 | flagR2=0; |
achille | 0:608629a8a61c | 44 | led_set(flagV,flagR1,flagR2);*/ |
achille | 0:608629a8a61c | 45 | /*tps.start(); |
achille | 0:608629a8a61c | 46 | for(int k;k<REC;k++){ |
achille | 0:608629a8a61c | 47 | recup(t,tps.read(),k); |
achille | 0:608629a8a61c | 48 | } |
achille | 0:608629a8a61c | 49 | tps.stop();*/ |
achille | 0:608629a8a61c | 50 | recupp.detach(); |
achille | 0:608629a8a61c | 51 | float mo=moy(t); |
achille | 0:608629a8a61c | 52 | port.printf("la moyenne %f \r\n ",mo); |
achille | 0:608629a8a61c | 53 | float pf=period(t,mo); |
achille | 0:608629a8a61c | 54 | pf=1/pf; |
achille | 0:608629a8a61c | 55 | port.printf("la freq %f\r\n ",pf); |
achille | 0:608629a8a61c | 56 | affichage(pf,frequ(pf),&flagV,&flagR1,&flagR2); |
achille | 0:608629a8a61c | 57 | led_set(flagV,flagR1,flagR2); |
achille | 0:608629a8a61c | 58 | wait(0.5); |
achille | 0:608629a8a61c | 59 | flagV=0; |
achille | 0:608629a8a61c | 60 | flagR1=0; |
achille | 0:608629a8a61c | 61 | flagR2=0; |
achille | 0:608629a8a61c | 62 | led_set(flagV,flagR1,flagR2); |
achille | 0:608629a8a61c | 63 | i=0; |
achille | 0:608629a8a61c | 64 | flag=0; |
achille | 0:608629a8a61c | 65 | tps.start(); |
achille | 0:608629a8a61c | 66 | recupp.attach(&here,0.00001); |
achille | 0:608629a8a61c | 67 | } |
achille | 0:608629a8a61c | 68 | } |
achille | 0:608629a8a61c | 69 | } |