AresENSEA-CDF2020
/
AresCDFMainCode_us2
Test
Diff: main.cpp
- Revision:
- 20:7d206773f39e
- Parent:
- 19:c419033c0967
- Child:
- 21:e5f0f5abb5ae
--- a/main.cpp Mon Oct 12 19:17:40 2020 +0000 +++ b/main.cpp Tue Oct 20 17:53:32 2020 +0000 @@ -1,6 +1,16 @@ // 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(); @@ -13,6 +23,19 @@ bt.printf("comptD = %d\r\n",comptD); } +void fctCptGlobal() +{ + cptGlobal++; + + if(cptGlobal==95) { + FlagGOTO(0); + } + + if(cptGlobal>=100) { + fnc=0; + } +} + /* void cordonDem() { @@ -21,16 +44,24 @@ xC = objX[indice]; yC = objY[indice]; mot_en(); + myled = 0; } */ + int main() { + captUS_init(); + 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); - //cordon.fall(&cordonDem); // debug pc.attach(&serialIT); // Interruption liaison série @@ -40,7 +71,7 @@ bt.baud(9600); bt.format(8,SerialBase::None,1); - //ticker_US.attach(&captUS_trig,0.2); // On apelle cette fonction toutes 0.2 secondes + ticker_US.attach(&captUS_trig,0.2); // On apelle cette fonction toutes 0.2 secondes //ticker_affUS.attach(&affUltrasons,1.0); //ticker_affcd.attach(&affCodeurs,1.0); //ticker_odo.attach(&odo2,0.02); @@ -72,9 +103,26 @@ cddA.mode(PullUp); while(1) { - if (indice>=4) { + 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(); + //mot_dis(); } }