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.
Fork of 01-04_Primer_Avance by
Diff: main.cpp
- Revision:
- 4:ba51736778e1
- Parent:
- 3:60722da62531
- Child:
- 5:6ca97bfe9406
--- a/main.cpp Fri Sep 07 03:42:26 2018 +0000
+++ b/main.cpp Fri Sep 07 23:58:14 2018 +0000
@@ -8,7 +8,7 @@
Serial command(USBTX, USBRX);
-
+DigitalIn button(USER_BUTTON);
int main() {
@@ -26,16 +26,16 @@
switch (read_cc) {
case 0x01:
- debug_m("Tc1\n");
+ debug_m("Tc 1 Iniciado..\n");
moving();
- debug_m("FTc1\n");
+ debug_m("Tc 1 Finalizado\n");
break;
case 0x02:
- debug_m("Tc2 :) \n");
- //moving();
- debug_m("FTc2\n");
+ debug_m("Tc 2 Iniciado.. \n");
+ pares();
+ debug_m("Tc 2 Finalizado\n");
break;
- default: debug_m("error de comando. \nSe espera 0x01 - 0x08 \n");break ;
+ default: debug_m("Error de comando. \nSe espera entre 0x01 - 0x08 \n");break ;
}
}
}
@@ -49,20 +49,47 @@
// Datos | Inicio | Tele-comando | Numero Motor | Grados | Cierre
//char intc=command.getc();
buffer[0] = command.getc();
- buffer[1] = command.getc();
- buffer[2] = command.getc();
- buffer[3] = command.getc();
- buffer[4] = command.getc();
+
+ inicio:
+
+ while(buffer[0] != 0xFF ){
- char intc = buffer[0];
- while(intc != 0xFF){
-
- intc=command.getc();
+ buffer[0] = command.getc();
debug_m("comando inicio invalido \n");
}
- printf("encontrado: %c \n", buffer[0] );
+ printf("inicio encontrado: %c \n", buffer[0] );
+
+ buffer[1] = command.getc();
+ if (buffer[1] != 0xFF && buffer[1] != 0xFD){
+ buffer[2] = command.getc();
+ }else{
+ buffer[0] = buffer[1];
+ goto inicio;
+ }
+ if (buffer[2] != 0xFF && buffer[2] != 0xFD){
+ buffer[3] = command.getc();
+ }else{
+ buffer[0] = buffer[2];
+ goto inicio;
+ }
+ if (buffer[3] != 0xFF && buffer[3] != 0xFD){
+ buffer[4] = command.getc();
+ }else{
+ buffer[0] = buffer[3];
+ goto inicio;
+ }
+ //para que evalue el cierre
+ if (buffer[4] != 0xFF && buffer[4] == 0xFD){
+ debug_m("comando Cierre valido \n");
+ }else{
+ buffer[0] = buffer[4];
+ goto inicio;
+ }
+
+
+
//intc=command.getc();
int tele = buffer[1];
printf("Tele siguente: %c \n", tele );
@@ -87,14 +114,28 @@
printf("Motor: %c \n", nmotor );
char grados = buffer[3];
printf("Grados: %c \n", grados );
- char endc = buffer[4];
- printf("Cierre: %c \n", endc );
+ //char endc = buffer[4];
+ //printf("Cierre: %c \n", endc );
mover_ser(nmotor,grados);
debug_m("fin del comado mover..\n");
}
-
+void pares(){
+ debug_m("se inicia el comado pares..\n");
+
+ char par = buffer[2];
+ printf("Par: %c \n", par );
+ char dire = buffer[3];
+ printf("Dir: %c \n", dire );
+ char endcc = buffer[4];
+ printf("Cierre: %c \n", endcc );
+ while(button == 0) {
+ mover_par(par,dire);
+ }
+ centro(par);
+ debug_m("fin del comado pares..\n");
+ }
void debug_m(char *s , ... ){
#if DEBUG
command.printf(s);
