Capteur_US

Dependencies:   mbed DRV8825

Committer:
g0dd4
Date:
Tue Oct 13 14:50:31 2020 +0000
Revision:
16:4c0b1647e8ae
Parent:
10:0714feaaaee1
Conversion du temps en distance ; Detection d'un obstacle; Changement de base; Test_fonctionnelle ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nanaud 4:ad9b7355332e 1 // Nom du fichier : debugBT.cpp
Nanaud 4:ad9b7355332e 2 #include "pins.h"
Nanaud 4:ad9b7355332e 3
Nanaud 4:ad9b7355332e 4 // Variables globales & timers
Nanaud 4:ad9b7355332e 5 Serial bt(PC_6,PC_7);
Nanaud 4:ad9b7355332e 6
Nanaud 4:ad9b7355332e 7 void bluetoothIT()
Nanaud 4:ad9b7355332e 8 {
Nanaud 4:ad9b7355332e 9 static int i=0;
Nanaud 4:ad9b7355332e 10 static char buffer[10]=""; // Tableau qui contient la chaine de caractère rentrée dans le terminal.
Nanaud 4:ad9b7355332e 11 static char cmd[Lcmd]=""; // Variable qui retient que les premiers caractères qui représentent la commande.
Nanaud 4:ad9b7355332e 12
Nanaud 4:ad9b7355332e 13 //printf("bt.readable = %d \r\n",bt.readable());
Nanaud 4:ad9b7355332e 14 while(bt.readable()) { // if(bt.readable())
Nanaud 4:ad9b7355332e 15 //pc.printf("bt.readable = %d \r\n",bt.readable());
Nanaud 4:ad9b7355332e 16 buffer[i]=bt.getc();
Nanaud 4:ad9b7355332e 17 pc.printf("%c",buffer[i]);
Nanaud 4:ad9b7355332e 18 bt.printf("%c",buffer[i]);
Nanaud 5:34ed652f8c31 19
Nanaud 5:34ed652f8c31 20 if((buffer[i] >= 48 && buffer[i] <=57) || (buffer[i]>=97 && buffer[i]<=122) || buffer[i]==13) i++;
Nanaud 4:ad9b7355332e 21 }
Nanaud 4:ad9b7355332e 22
Nanaud 4:ad9b7355332e 23 if(buffer[i-1]=='\r') {
Nanaud 4:ad9b7355332e 24 pc.printf("\r\n");
Nanaud 4:ad9b7355332e 25 bt.printf("\r\n");
Nanaud 4:ad9b7355332e 26 i=0;
Nanaud 4:ad9b7355332e 27
Nanaud 4:ad9b7355332e 28 copieTab(buffer,cmd);
Nanaud 4:ad9b7355332e 29
Nanaud 4:ad9b7355332e 30 switch(cmdType) {
Nanaud 4:ad9b7355332e 31 case 1 : // Commande test angle
Nanaud 4:ad9b7355332e 32 StringToAngle(cmd);
Nanaud 4:ad9b7355332e 33 cmdType=0;
Nanaud 4:ad9b7355332e 34 break;
Nanaud 5:34ed652f8c31 35 case 2 : // Commande test vitesse
Nanaud 5:34ed652f8c31 36 StringToVitesse(cmd);
Nanaud 5:34ed652f8c31 37 cmdType=0;
Nanaud 5:34ed652f8c31 38 break;
Nanaud 10:0714feaaaee1 39 case 3 : // Commande distance a parcourir
Nanaud 10:0714feaaaee1 40 StringToDist(cmd);
Nanaud 10:0714feaaaee1 41 cmdType=0;
Nanaud 10:0714feaaaee1 42 break;
Nanaud 4:ad9b7355332e 43 default : // Commande par défaut
Nanaud 4:ad9b7355332e 44 cmdChoice(cmd);
Nanaud 4:ad9b7355332e 45 }
Nanaud 4:ad9b7355332e 46 }
Nanaud 4:ad9b7355332e 47 }