Test

Dependencies:   mbed DRV8825

main.cpp

Committer:
Nanaud
Date:
2020-10-12
Revision:
19:c419033c0967
Parent:
17:176a1b4a2fa8
Child:
20:7d206773f39e

File content as of revision 19:c419033c0967:

// Nom du fichier : main.cpp
#include "pins.h"

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 cordonDem()
{
    indice++;
    fnc = objEtape[indice];
    xC = objX[indice];
    yC = objY[indice];
    mot_en();
}
*/

int main()
{
    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
    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.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);
    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 (indice>=4) {
            fnc = 0;
            mot_dis();
        }

    }
}