AresENSEA-CDF2020
/
AresCDFMainCode_us2
Test
main.cpp
- Committer:
- Nanaud
- Date:
- 2020-10-25
- Revision:
- 21:e5f0f5abb5ae
- Parent:
- 20:7d206773f39e
- Child:
- 22:f891c2bce091
File content as of revision 21:e5f0f5abb5ae:
// Nom du fichier : main.cpp #include "pins.h" //#define TPS_DRAPEAU 20 // 95 //#define TPS_FIN 100 Ticker TimerGlobal; int cptGlobal = 0; bool Match = 0; DigitalOut led(LED1); DigitalIn tirette(PC_8); void btnFct() { mot_dis(); aff_cd[0] = 0; aff_cd[1] = 0; pc.printf("comptG = %d\r\n",comptG); pc.printf("comptD = %d\r\n",comptD); bt.printf("comptG = %d\r\n",comptG); bt.printf("comptD = %d\r\n",comptD); } void fctCptGlobal() { cptGlobal++; if(cptGlobal==5) { //95 FlagGOTO(0); } if(cptGlobal>=100) { fnc=0; } } /* void cordonDem() { indice++; fnc = objEtape[indice]; xC = objX[indice]; yC = objY[indice]; mot_en(); myled = 0; } */ int main() { //captUS_init(); tps.start(); FlagGOTO(90); TimerGlobal.attach(&fctCptGlobal, 1.0); tirette.mode(PullDown); //myled = 1; pc.printf("\r\nAresCDFMainCode\r\n"); bt.printf("\r\nAresCDFMainCode\r\n"); btn.rise(&btnFct); // debug pc.attach(&serialIT); // Interruption liaison série bt.attach(&bluetoothIT); // Interruption bluetooth pc.baud(9600); pc.format(8,SerialBase::None,1); bt.baud(9600); bt.format(8,SerialBase::None,1); ticker_US.attach(&captUS_trig,0.1); // 0.2 //ticker_affUS.attach(&affUltrasons,1.0); //ticker_affcd.attach(&affCodeurs,1.0); //ticker_odo.attach(&odo2,0.02); ticker_asserv.attach(&asserv,0.015); //ticker_affodo.attach(&affOdo,1.0); // Init capteurs à ultrasons //captUS_init(); echo1.rise(&echoRise1); echo1.fall(&echoFall1); echo2.rise(&echoRise2); echo2.fall(&echoFall2); echo3.rise(&echoRise3); echo3.fall(&echoFall3); echo4.rise(&echoRise4); echo4.fall(&echoFall4); echo5.rise(&echoRise5); echo5.fall(&echoFall5); echo6.rise(&echoRise6); echo6.fall(&echoFall6); // Init DRV8825 drv_init(); // Init codeurs cdgA.rise(&cdgaRise); cddA.rise(&cddaRise); cdgA.mode(PullUp); cddA.mode(PullUp); while(1) { if (tirette == 1 && Match == 0) { Match = 0; led = 1; } else if (tirette == 0 && Match == 0){ Match = 1; led = 0; //indice++; indice=1; fnc = objEtape[indice]; xC = objX[indice]; yC = objY[indice]; cptGlobal = 0; //mot_en(); } if (indice>=NbObj) { fnc = 0; //mot_dis(); } } }