Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: debug.cpp
- Revision:
- 4:ad9b7355332e
- Parent:
- 3:3ba377aafdfd
- Child:
- 5:34ed652f8c31
--- a/debug.cpp Wed Jul 15 17:51:04 2020 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
-// Nom du fichier : debug.cpp
-#include "pins.h"
-
-// Variables globales & timerse
-Serial pc(USBTX, USBRX);
-Ticker ticker_affUS;
-Ticker ticker_affcd;
-bool aff_US[6];
-bool aff_cd[4];
-int cmdType=0;
-
-void serialIT()
-{
- //pc.printf("\n\rserialIT on\n\r");
- static int i=0;
- static char buffer[10]=""; // Tableau qui contient la chaine de caractère rentrée dans le terminal.
- static char cmd[Lcmd]=""; // Variable qui retient que les premiers caractères qui représentent la commande.
- char tampon = pc.getc();
-
- if((tampon >= 48 && tampon <=57) || (tampon>=97 && tampon<=122) || tampon==13) {
- buffer[i]=tampon; // Ajout du caractère dans le tableau buffer
- pc.putc(buffer[i]); // Réécriture sur le terminal du caractère envoyé
- i++;
- }
-
- if(buffer[i-1]=='\r') { // Attente un appui sur la touche entrée
- i=0;
- copieTab(buffer,cmd); // Sauvegarde la commande dans le tableau cmd
-
- switch(cmdType) {
- case 1 : // Commande test angle
- StringToAngle(cmd);
- cmdType=0;
- break;
- default : // Commande par défaut
- cmdChoice(cmd);
- }
- }
-}
-
-void copieTab(char *tab1,char *tab2) // Fonction qui recopie un tableau dans un autre
-{
- //pc.printf("\n\rcopieTab on\n\r");
- //pc.printf("\n\r");
- for(int j=0; j<Lcmd; j++) {
- tab2[j]=tab1[j];
- //pc.printf("%c",tab2[j]);
- }
- //pc.printf("\n\r");
-}
-
-void cmdChoice(char *cmd) // Fonction qui permet de choisir de l'activation d'une commande
-{
- //pc.printf("\n\rcmdChoice on\n\rcmd =");
-
- const char *options[]= {
- "help", //0
- "usao", //1
- "us1o", //2
- "us2o", //3
- "us3o", //4
- "us4o", //5
- "us5o", //6
- "us6o", //7
- "tdrv", //8
- "cdon", //9
- "cdga", //10
- "cdgb", //11
- "tagl", //12
- 0
- };
-
- long option=-1;
-
- for (long a=0; options[a] && option<0; a++) {
- if (!strcmp(cmd,options[a]) || strcmp(cmd,options[a])==1) { // strcmp(cmd,options[a])==1 permet de contourner le problème, à revoir !!!
- option=a;
- }
- //pc.printf("res = %d",strcmp(cmd,options[a]));
- }
-
- switch (option) {
- case 0: //help
- pc.printf("\n\n\r###HELP###\n\r");
- pc.printf("usao : Affichage resultats capteurs a ultrasons\n\r");
- pc.printf("usxo : Affichage resultat capteur ultrasons x\n\r");
- pc.printf("tdrv : Lance la fonction test_drv()\n\r");
- pc.printf("cdon : Affichage resultats codeurs\n\r");
- pc.printf("cdgx : Affichage resultats codeur gauche phase x (a ou b)\n\r");
- pc.printf("tagl : Tourne le robot sur lui-meme avec un angle a preciser\r\n");
- pc.printf("\n\r");
- break;
- case 1: //usao
- pc.printf("Capt US ALL ON/OFF\n\r");
- aff_US[0]=!aff_US[0];
- aff_US[1]=!aff_US[1];
- aff_US[2]=!aff_US[2];
- aff_US[3]=!aff_US[3];
- aff_US[4]=!aff_US[4];
- aff_US[5]=!aff_US[5];
- break;
- case 2: //us1o
- pc.printf("Capt US 1 ON/OFF\n\r");
- aff_US[0]=!aff_US[0];
- break;
- case 3: //us2o
- pc.printf("Capt US 2 ON/OFF\n\r");
- aff_US[1]=!aff_US[1];
- break;
- case 4: //us3o
- pc.printf("Capt US 3 ON/OFF\n\r");
- aff_US[2]=!aff_US[2];
- break;
- case 5: //us4o
- pc.printf("Capt US 4 ON/OFF\n\r");
- aff_US[3]=!aff_US[3];
- break;
- case 6: //us5o
- pc.printf("Capt US 5 ON/OFF\n\r");
- aff_US[4]=!aff_US[4];
- break;
- case 7: //us6o
- pc.printf("Capt US 6 ON/OFF\n\r");
- aff_US[5]=!aff_US[5];
- break;
- case 8: //tdrv
- pc.printf("Fonction test_drv()\n\r");
- test_drv();
- break;
- case 9: //cdon
- pc.printf("Results ALL Encoders ON/OFF\n\r");
- aff_cd[0]=!aff_cd[0];
- aff_cd[1]=!aff_cd[1];
- break;
- case 10: //cdga
- pc.printf("Results Encoder Left A ON/OFF\n\r");
- aff_cd[0]=!aff_cd[0];
- break;
- case 11: //cdgb
- pc.printf("Results Encoder Left B ON/OFF\n\r");
- aff_cd[1]=!aff_cd[1];
- break;
- case 12: //tagl
- pc.printf("Cmd Angle robot\r\n");
- pc.printf("Angle (entre 0 et 360 degres sous la forme xxx): ");
- cmdType=1;
- break;
- default:
- pc.printf("Commande invalide\n\r");
- }
-}
-
-void StringToAngle(char *cmd)
-{
- int cmd2 = 0;
- cmd2 += (cmd[0]-48)*100;
- cmd2 += (cmd[1]-48)*10;
- cmd2 += (cmd[2]-48)*1;
-
- if (cmd2>=0 && cmd2<=360) {
- pc.printf("\r\nCommande envoyee au robot : %d\r\n",cmd2);
- testAngle(cmd2);
- } else {
- pc.printf("\r\nAngle incorrect\r\n\n");
- cmd2 = 0;
- }
-}
-
-void affUltrasons()
-{
- if(aff_US[0]) printf("Tps US1 = %5.0f uS\n\r", us_out[0]);
- if(aff_US[1]) printf("Tps US2 = %5.0f uS\n\r", us_out[1]);
- if(aff_US[2]) printf("Tps US3 = %5.0f uS\n\r", us_out[2]);
- if(aff_US[3]) printf("Tps US4 = %5.0f uS\n\r", us_out[3]);
- if(aff_US[4]) printf("Tps US5 = %5.0f uS\n\r", us_out[4]);
- if(aff_US[5]) printf("Tps US6 = %5.0f uS\n\r", us_out[5]);
- if(aff_US[0]||aff_US[1]||aff_US[2]||aff_US[3]||aff_US[4]||aff_US[5]) printf("\n\r");
-}
-
-void affCodeurs()
-{
- if(aff_cd[0]) printf("CdgA = %d\n\r", cpt_cdgA);
- //if(aff_cd[1]) printf("CdgB = %d\n\r", cpt_cdgB);
-}