Accordeur
/
accordeurguit
programme accordeur guitare valide
Diff: main.cpp
- Revision:
- 0:608629a8a61c
- Child:
- 2:86f6d5733ae7
diff -r 000000000000 -r 608629a8a61c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jun 05 09:40:07 2019 +0000 @@ -0,0 +1,69 @@ +#include "fonctions.h" + +Ticker recupp; +/*USBSerial port;*/ +Serial port(USBTX,USBRX,9600); +Timer tps; + + + +volatile donnees t[REC]; +volatile int i; +volatile int flag; + +void here(){ + if(i<REC){ + recup(t,tps.read(),i); + i++; + } + else{ + flag=1; + } + } + +int main() { + port.printf("bonjour \r\n "); + int flagV=1, flagR1=1, flagR2=1; + led_set(flagV,flagR1,flagR2); + wait(1); + flag=0; + i=0; + recupp.attach(&here,0.00001); + while(1) { + tps.start(); + if(flag==1){ + tps.stop(); + /* flagV=1; + flagR1=1; + flagR2=1; + led_set(flagV,flagR1,flagR2); + wait(0.5); + flagV=0; + flagR1=0; + flagR2=0; + led_set(flagV,flagR1,flagR2);*/ + /*tps.start(); + for(int k;k<REC;k++){ + recup(t,tps.read(),k); + } + tps.stop();*/ + recupp.detach(); + float mo=moy(t); + port.printf("la moyenne %f \r\n ",mo); + float pf=period(t,mo); + pf=1/pf; + port.printf("la freq %f\r\n ",pf); + affichage(pf,frequ(pf),&flagV,&flagR1,&flagR2); + led_set(flagV,flagR1,flagR2); + wait(0.5); + flagV=0; + flagR1=0; + flagR2=0; + led_set(flagV,flagR1,flagR2); + i=0; + flag=0; + tps.start(); + recupp.attach(&here,0.00001); + } + } +}