Piccolo

Dependencies:   mbed

Fork of 02_LAB_serial_protocol by ferney alberto beltran molina

Committer:
Vanessa620
Date:
Wed Oct 11 01:03:06 2017 +0000
Revision:
12:92abcf61971b
Parent:
11:b4a3db5a0305
Child:
13:94013a19713a
Continuaci?n de la entrega del viernes 13.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fabeltranm 0:55d11eeb0faf 1 #include "mbed.h"
Vanessa620 12:92abcf61971b 2 #define DEBUG 1
fabeltranm 0:55d11eeb0faf 3
Vanessa620 12:92abcf61971b 4 //PUERTOS O/I DE SISTEMA EMBEBIDO NUCLEO-F411RE
fabeltranm 0:55d11eeb0faf 5 Serial command(USBTX, USBRX);
fabeltranm 2:200a9507b696 6 DigitalOut led(LED1);
Vanessa620 12:92abcf61971b 7 PwmOut myServoX(PB_3); //Servo X
Vanessa620 12:92abcf61971b 8 PwmOut myServoY(PB_6); //Servo Y
Vanessa620 12:92abcf61971b 9 PwmOut myServoZ(PB_4); //Servo Z
Vanessa620 12:92abcf61971b 10
fabeltranm 0:55d11eeb0faf 11 //*****************************************************************************
fabeltranm 0:55d11eeb0faf 12 // COMANDO MOVER MOTOR
fabeltranm 0:55d11eeb0faf 13 // |POS 1|POS 2|POS 3|POS 4| POS 5|
fabeltranm 7:fab201aa45b7 14 // | < | #C | a | b | > |
Vanessa620 11:b4a3db5a0305 15 // | 3C |0 al A| D1 | D2 | D3 | D4 | 3E |
Vanessa620 11:b4a3db5a0305 16 // #C -> indica el comando. En este caso es de 0 a 10 (en hexadesimal para enviar comando desde techado de 0 a A)
fabeltranm 6:cb6b868465c3 17 // a,b,c,d parametros del comando
fabeltranm 6:cb6b868465c3 18 // <,> -> inicio, y fin de comando
fabeltranm 0:55d11eeb0faf 19 // el inicio de comando no se almacena en el buffer
fabeltranm 0:55d11eeb0faf 20 //*****************************************************************************
fabeltranm 0:55d11eeb0faf 21
fabeltranm 0:55d11eeb0faf 22 // VARIABLES PARA DEFINIR EL COMMANDO
Vanessa620 12:92abcf61971b 23 #define BUFF_SIZE 6 // tamaño del comando enviado desde CoolTerm
Vanessa620 12:92abcf61971b 24 #define COMM_N 0 //
Vanessa620 12:92abcf61971b 25 #define INITPARAMETER 1 //
Vanessa620 12:92abcf61971b 26 #define MAXPOS 50 // Posicion maxima de la matriz de dibujo x,y en mm
Vanessa620 12:92abcf61971b 27 #define POSDRAW 10 // Posicion del servomotor Z para dibujar
Vanessa620 12:92abcf61971b 28 #define SS_TIME 100 //
Vanessa620 12:92abcf61971b 29 #define PI 3.1415926 //
Vanessa620 12:92abcf61971b 30 int RSTEP = 5; // Inicializacion de la variable de Resolucion para el dibujo
Vanessa620 11:b4a3db5a0305 31
Vanessa620 11:b4a3db5a0305 32
Vanessa620 11:b4a3db5a0305 33
Vanessa620 11:b4a3db5a0305 34 // COMANDOS
Vanessa620 11:b4a3db5a0305 35 #define LED_NC 0 //ok
Vanessa620 11:b4a3db5a0305 36 #define DOT_NC 1 //ok
Vanessa620 11:b4a3db5a0305 37 #define LINE_NC 2 //ok
Vanessa620 12:92abcf61971b 38 #define RECTANGULO_NC 3 //ok
Vanessa620 11:b4a3db5a0305 39 #define CICLE_NC 4 //ok
Vanessa620 11:b4a3db5a0305 40 #define HOME_NC 5 //ok
Vanessa620 11:b4a3db5a0305 41 #define RESOLUCION_NC 6 //ok
Vanessa620 12:92abcf61971b 42 #define TIEMPOPASOS_NC 7 // No se a que se refiere
Vanessa620 12:92abcf61971b 43 #define STOP_NC 8 // Pendiente
Vanessa620 12:92abcf61971b 44 #define PAUSA_NC 9 // Pendiente
Vanessa620 12:92abcf61971b 45 #define REANUDAR_NC 10 //Pendiente
Vanessa620 12:92abcf61971b 46 #define MOVER_NC 11 // No se a que se refiere
Vanessa620 11:b4a3db5a0305 47
fabeltranm 7:fab201aa45b7 48
Vanessa620 12:92abcf61971b 49 int coord2pulse(float coord) //
Vanessa620 12:92abcf61971b 50 {
manuelitoys 8:38ae341e2a4f 51 if(0 <= coord <= MAXPOS)
manuelitoys 8:38ae341e2a4f 52 return int(750+coord*1900/50);// u6
Vanessa620 12:92abcf61971b 53 return 750;
Vanessa620 12:92abcf61971b 54 }
Vanessa620 12:92abcf61971b 55
Vanessa620 12:92abcf61971b 56 void vertex2d(float x, float y) // Funcion para enviarle la posicion a (x,y)
Vanessa620 12:92abcf61971b 57 {
manuelitoys 9:5008f9501dbf 58 int pulseX = coord2pulse(x);
manuelitoys 9:5008f9501dbf 59 int pulseY = coord2pulse(y);
manuelitoys 9:5008f9501dbf 60
manuelitoys 9:5008f9501dbf 61 myServoX.pulsewidth_us(pulseX);
manuelitoys 9:5008f9501dbf 62 myServoY.pulsewidth_us(pulseY);
Vanessa620 12:92abcf61971b 63 wait_ms(SS_TIME);
Vanessa620 12:92abcf61971b 64 }
Vanessa620 12:92abcf61971b 65
Vanessa620 12:92abcf61971b 66 void draw() // Funcion para enviarle la posicion de dibujo a z.
Vanessa620 12:92abcf61971b 67 {
manuelitoys 8:38ae341e2a4f 68 myServoZ.pulsewidth_us(POSDRAW);
manuelitoys 8:38ae341e2a4f 69 // myServoY.pulsewidth_us(750);
Vanessa620 12:92abcf61971b 70 }
Vanessa620 12:92abcf61971b 71 void nodraw() // Funcion para enviarle la posicion de no dibujar a z.
Vanessa620 12:92abcf61971b 72 {
manuelitoys 8:38ae341e2a4f 73 myServoZ.pulsewidth_us(MAXPOS);
manuelitoys 8:38ae341e2a4f 74 // myServoY.pulsewidth_us(2000);
Vanessa620 12:92abcf61971b 75 }
fabeltranm 7:fab201aa45b7 76
Vanessa620 12:92abcf61971b 77 uint8_t buffer_command[BUFF_SIZE]={0,0,0,0,0}; // Matriz donde sera guardado el Comando enviado del CoolTerm
fabeltranm 1:0bcd96e56022 78
Vanessa620 12:92abcf61971b 79 void print_num(uint8_t val) //
Vanessa620 12:92abcf61971b 80 {
Vanessa620 12:92abcf61971b 81 if (val <10)
fabeltranm 1:0bcd96e56022 82 command.putc(val+0x30);
fabeltranm 1:0bcd96e56022 83 else
Vanessa620 12:92abcf61971b 84 command.putc(val-9+0x40);
Vanessa620 12:92abcf61971b 85 }
Vanessa620 12:92abcf61971b 86
Vanessa620 12:92abcf61971b 87 void print_bin2hex (uint8_t val) // Funcion para imprimir el comando enviado desde CoolTerm en Hexadecimal
Vanessa620 12:92abcf61971b 88 {
fabeltranm 1:0bcd96e56022 89 command.printf(" 0x");
fabeltranm 1:0bcd96e56022 90 print_num(val>>4);
Vanessa620 12:92abcf61971b 91 print_num(val&0x0f);
Vanessa620 12:92abcf61971b 92 }
fabeltranm 1:0bcd96e56022 93
fabeltranm 0:55d11eeb0faf 94 // TODO : TIMEOUT UART SERIAL
Vanessa620 12:92abcf61971b 95 void Read_command() //Funcion para leer el comando que se digito en CoolTerm
Vanessa620 12:92abcf61971b 96 {
fabeltranm 0:55d11eeb0faf 97 for (uint8_t i=0; i<BUFF_SIZE;i++)
fabeltranm 0:55d11eeb0faf 98 buffer_command[i]=command.getc();
Vanessa620 12:92abcf61971b 99 }
fabeltranm 0:55d11eeb0faf 100
Vanessa620 12:92abcf61971b 101 void echo_command() //
Vanessa620 12:92abcf61971b 102 {
fabeltranm 0:55d11eeb0faf 103 for (uint8_t i=0; i<BUFF_SIZE;i++)
Vanessa620 12:92abcf61971b 104 print_bin2hex(buffer_command[i]);
Vanessa620 12:92abcf61971b 105 }
fabeltranm 0:55d11eeb0faf 106
Vanessa620 12:92abcf61971b 107 uint8_t check_command() //Funcion para verificar e que el ultimo valor del comando enviado sea '>' para terminar el comando
Vanessa620 12:92abcf61971b 108 {
Vanessa620 12:92abcf61971b 109 if (buffer_command[BUFF_SIZE-1]== '>'){
fabeltranm 0:55d11eeb0faf 110 #if DEBUG
Vanessa620 12:92abcf61971b 111 command.printf("\nComando: ");
Vanessa620 12:92abcf61971b 112 print_bin2hex(buffer_command[COMM_N]);
Vanessa620 12:92abcf61971b 113 command.printf(" -> ");
Vanessa620 12:92abcf61971b 114 #endif
Vanessa620 12:92abcf61971b 115 return 1;
Vanessa620 12:92abcf61971b 116 }
Vanessa620 12:92abcf61971b 117 #if DEBUG
Vanessa620 12:92abcf61971b 118 command.printf("\n ERROR EN EL COMANDO -> ");
Vanessa620 12:92abcf61971b 119 echo_command();
fabeltranm 0:55d11eeb0faf 120 #endif
Vanessa620 12:92abcf61971b 121 return 0;
Vanessa620 12:92abcf61971b 122 }
Vanessa620 12:92abcf61971b 123
Vanessa620 12:92abcf61971b 124 //FUNCIONES PARA DIBUJAR FIGURAS
Vanessa620 12:92abcf61971b 125 void Led(int tm) //Funcion para definir el tiempo de led
Vanessa620 12:92abcf61971b 126 {
Vanessa620 11:b4a3db5a0305 127 #if DEBUG
Vanessa620 12:92abcf61971b 128 command.printf("Segundos: %i/n", tm);
Vanessa620 11:b4a3db5a0305 129 #endif
Vanessa620 12:92abcf61971b 130 led=1;
Vanessa620 12:92abcf61971b 131 wait(tm);
Vanessa620 12:92abcf61971b 132 led=0;
Vanessa620 11:b4a3db5a0305 133 }
Vanessa620 12:92abcf61971b 134
Vanessa620 12:92abcf61971b 135 void punto(uint8_t x, uint8_t y) //Funcion para dibujar un punto
Vanessa620 12:92abcf61971b 136 {
Vanessa620 12:92abcf61971b 137 #if DEBUG
Vanessa620 12:92abcf61971b 138 command.printf("Coordenadas x=%i, y=%i \n",x,y);
Vanessa620 12:92abcf61971b 139 #endif
Vanessa620 11:b4a3db5a0305 140 vertex2d(x,y);
Vanessa620 11:b4a3db5a0305 141 draw();
Vanessa620 11:b4a3db5a0305 142 wait(1);
Vanessa620 11:b4a3db5a0305 143 nodraw();
Vanessa620 11:b4a3db5a0305 144 }
Vanessa620 11:b4a3db5a0305 145
Vanessa620 11:b4a3db5a0305 146 void linea(float xi, float xf, float yi, float yf)
Vanessa620 12:92abcf61971b 147 {
Vanessa620 12:92abcf61971b 148 #if DEBUG
Vanessa620 12:92abcf61971b 149 command.printf("linea coordenadas xi=%f, xf=%f, yi=%f, yf=%f \n", xi,xf,yi,yf);
Vanessa620 12:92abcf61971b 150 #endif
Vanessa620 11:b4a3db5a0305 151 float xp; float yp;
Vanessa620 11:b4a3db5a0305 152 float m= (yf-yi)/(xf-xi);
Vanessa620 11:b4a3db5a0305 153 float b=yf-m*xf;
Vanessa620 11:b4a3db5a0305 154 vertex2d(xi,yi);
Vanessa620 11:b4a3db5a0305 155 draw();
Vanessa620 12:92abcf61971b 156 for (xp=xi; xp<=xf; xp+=RSTEP)
Vanessa620 11:b4a3db5a0305 157 {
Vanessa620 12:92abcf61971b 158 yp =m*xp+b;
Vanessa620 12:92abcf61971b 159 vertex2d(xp,yp);
Vanessa620 12:92abcf61971b 160 #if DEBUG
Vanessa620 12:92abcf61971b 161 command.printf("Coordenadas x=%f,yf=%f \n", xp,yp);
Vanessa620 12:92abcf61971b 162 #endif
Vanessa620 11:b4a3db5a0305 163 }
Vanessa620 11:b4a3db5a0305 164 nodraw();
Vanessa620 12:92abcf61971b 165 }
Vanessa620 12:92abcf61971b 166
Vanessa620 12:92abcf61971b 167 void Rectangulo(uint8_t x, uint8_t y, uint8_t a, uint8_t h)
Vanessa620 12:92abcf61971b 168 {
Vanessa620 12:92abcf61971b 169 #if DEBUG
Vanessa620 12:92abcf61971b 170 command.printf("Coordenadas x=%i, y=%i, ancho=%i, alto=%i, resolucion=%i\n", x,y,a,h,RSTEP);
Vanessa620 12:92abcf61971b 171 #endif
Vanessa620 12:92abcf61971b 172 vertex2d(x,y);
Vanessa620 12:92abcf61971b 173 #if DEBUG
Vanessa620 12:92abcf61971b 174 command.printf("Cordenadas x=%i, y= %i/n", x,y);
Vanessa620 12:92abcf61971b 175 #endif
Vanessa620 12:92abcf61971b 176 draw();
Vanessa620 12:92abcf61971b 177 for(x=x;x<=x+a;x+=RSTEP)
Vanessa620 12:92abcf61971b 178 {
Vanessa620 12:92abcf61971b 179 vertex2d(x,y);
Vanessa620 12:92abcf61971b 180 }
Vanessa620 12:92abcf61971b 181 #if DEBUG
Vanessa620 12:92abcf61971b 182 command.printf("Cordenadas x=%i, y= %i/n", x,y);
manuelitoys 8:38ae341e2a4f 183 #endif
Vanessa620 12:92abcf61971b 184 for(y=y;y<=y+h;y+=RSTEP)
Vanessa620 12:92abcf61971b 185 {
Vanessa620 12:92abcf61971b 186 vertex2d(x,y);
Vanessa620 12:92abcf61971b 187 }
Vanessa620 12:92abcf61971b 188 #if DEBUG
Vanessa620 12:92abcf61971b 189 command.printf("Cordenadas x=%i, y= %i/n", x,y);
manuelitoys 8:38ae341e2a4f 190 #endif
Vanessa620 12:92abcf61971b 191 for(x=x;x>=x-a;x-=RSTEP)
Vanessa620 12:92abcf61971b 192 {
Vanessa620 12:92abcf61971b 193 vertex2d(x,y);
Vanessa620 12:92abcf61971b 194 }
Vanessa620 12:92abcf61971b 195 #if DEBUG
Vanessa620 12:92abcf61971b 196 command.printf("Cordenadas x=%i, y= %i/n", x,y);
manuelitoys 8:38ae341e2a4f 197 #endif
Vanessa620 12:92abcf61971b 198 for(y=y;y>=y-h;y-=RSTEP)
Vanessa620 12:92abcf61971b 199 {
Vanessa620 12:92abcf61971b 200 vertex2d(x,y);
Vanessa620 12:92abcf61971b 201 }
Vanessa620 12:92abcf61971b 202 #if DEBUG
Vanessa620 12:92abcf61971b 203 command.printf("Cordenadas x=%i, y= %i/n", x,y);
manuelitoys 8:38ae341e2a4f 204 #endif
manuelitoys 8:38ae341e2a4f 205 wait_ms(SS_TIME);
Vanessa620 12:92abcf61971b 206 nodraw();
Vanessa620 12:92abcf61971b 207 }
Vanessa620 12:92abcf61971b 208
Vanessa620 12:92abcf61971b 209 void resolucion(int res) // Funcion para definir la resolucion del dibujo
Vanessa620 12:92abcf61971b 210 {
Vanessa620 12:92abcf61971b 211 RSTEP = res;
Vanessa620 12:92abcf61971b 212 #if DEBUG
Vanessa620 12:92abcf61971b 213 command.printf("Resolucion definida en=%i \n", RSTEP);
Vanessa620 12:92abcf61971b 214 #endif
Vanessa620 12:92abcf61971b 215 }
Vanessa620 11:b4a3db5a0305 216
Vanessa620 12:92abcf61971b 217 void home()
Vanessa620 12:92abcf61971b 218 {
Vanessa620 10:3eab080dbc12 219 vertex2d(0,0);
Vanessa620 10:3eab080dbc12 220 }
Vanessa620 11:b4a3db5a0305 221
Vanessa620 10:3eab080dbc12 222 void circle(uint8_t cx, uint8_t cy, uint8_t radio)
Vanessa620 10:3eab080dbc12 223 {
Vanessa620 10:3eab080dbc12 224 int y;
Vanessa620 10:3eab080dbc12 225 int x;
Vanessa620 11:b4a3db5a0305 226 vertex2d(cx,cy);
Vanessa620 11:b4a3db5a0305 227
Vanessa620 11:b4a3db5a0305 228 for(double i=0; i<=PI/2 ;i+=RSTEP)
Vanessa620 12:92abcf61971b 229 {
Vanessa620 10:3eab080dbc12 230 x=radio*cos(i);
Vanessa620 10:3eab080dbc12 231 y=radio*sin(i);
Vanessa620 10:3eab080dbc12 232 vertex2d(x+cx,y+cy);
Vanessa620 11:b4a3db5a0305 233 draw();
Vanessa620 11:b4a3db5a0305 234 #if DEBUG
Vanessa620 12:92abcf61971b 235 command.printf("Coordenadas x =%li, y =%li, Resolcion:%i \n",x,y,RSTEP);
Vanessa620 12:92abcf61971b 236 #endif
Vanessa620 10:3eab080dbc12 237 }
Vanessa620 12:92abcf61971b 238 for(double i=PI/2; i<=PI ;i+=RSTEP)
Vanessa620 12:92abcf61971b 239 {
Vanessa620 11:b4a3db5a0305 240 x=radio*cos(i);
Vanessa620 11:b4a3db5a0305 241 y=radio*sin(i);
Vanessa620 11:b4a3db5a0305 242 vertex2d(cx-x,cy-y);
Vanessa620 11:b4a3db5a0305 243 #if DEBUG
Vanessa620 12:92abcf61971b 244 command.printf("Coordenadas x =%li, y =%li, Resolcion:%i \n",x,y,RSTEP);
Vanessa620 11:b4a3db5a0305 245 #endif
Vanessa620 11:b4a3db5a0305 246 }
Vanessa620 12:92abcf61971b 247 for(double i=PI; i<=(3*PI)/2 ;i+=RSTEP)
Vanessa620 12:92abcf61971b 248 {
Vanessa620 10:3eab080dbc12 249 x=radio*cos(i);
Vanessa620 10:3eab080dbc12 250 y=radio*sin(i);
Vanessa620 10:3eab080dbc12 251 vertex2d(x+y,cx+cy);
Vanessa620 11:b4a3db5a0305 252 #if DEBUG
Vanessa620 12:92abcf61971b 253 command.printf("Coordenadas x =%li, y =%li, Resolcion:%i \n",x,y,RSTEP);
Vanessa620 11:b4a3db5a0305 254 #endif
Vanessa620 12:92abcf61971b 255 }
Vanessa620 12:92abcf61971b 256 for(double i=3*PI/2; i<=2*PI ;i+=RSTEP)
Vanessa620 12:92abcf61971b 257 {
Vanessa620 10:3eab080dbc12 258 x=radio*cos(i);
Vanessa620 10:3eab080dbc12 259 y=radio*sin(i);
Vanessa620 10:3eab080dbc12 260 vertex2d(cx+x,cy-y);
Vanessa620 11:b4a3db5a0305 261 #if DEBUG
Vanessa620 12:92abcf61971b 262 command.printf("Coordenadas x =%li, y =%li, Resolcion:%i \n",x,y,RSTEP);
Vanessa620 11:b4a3db5a0305 263 #endif
Vanessa620 10:3eab080dbc12 264 }
Vanessa620 11:b4a3db5a0305 265 nodraw();
Vanessa620 10:3eab080dbc12 266 }
Vanessa620 12:92abcf61971b 267
Vanessa620 12:92abcf61971b 268 void TiempoPasos(int tm) //Funcion para definir el tiempo de led
Vanessa620 12:92abcf61971b 269 {
Vanessa620 12:92abcf61971b 270 #if DEBUG
Vanessa620 12:92abcf61971b 271 command.printf("Tiempo en pasos:%i/n", tm);
Vanessa620 12:92abcf61971b 272 #endif
Vanessa620 12:92abcf61971b 273 }
Vanessa620 12:92abcf61971b 274
Vanessa620 12:92abcf61971b 275 void Stop(int tm) //Funcion para definir el tiempo de led
Vanessa620 12:92abcf61971b 276 {
Vanessa620 12:92abcf61971b 277 #if DEBUG
Vanessa620 12:92abcf61971b 278 command.printf("STOP/n", tm);
Vanessa620 12:92abcf61971b 279 #endif
Vanessa620 12:92abcf61971b 280 }
Vanessa620 12:92abcf61971b 281
Vanessa620 12:92abcf61971b 282 void Pausa(int tm) //Funcion para definir el tiempo de led
Vanessa620 12:92abcf61971b 283 {
Vanessa620 12:92abcf61971b 284 #if DEBUG
Vanessa620 12:92abcf61971b 285 command.printf("PAUSA/n", tm);
Vanessa620 12:92abcf61971b 286 #endif
Vanessa620 12:92abcf61971b 287 }
Vanessa620 12:92abcf61971b 288
Vanessa620 12:92abcf61971b 289 void Reanudar(int tm) //Funcion para definir el tiempo de led
Vanessa620 12:92abcf61971b 290 {
Vanessa620 12:92abcf61971b 291 #if DEBUG
Vanessa620 12:92abcf61971b 292 command.printf("Reanudando imagen...%i/n", tm);
Vanessa620 12:92abcf61971b 293 #endif
Vanessa620 12:92abcf61971b 294 }
Vanessa620 12:92abcf61971b 295
Vanessa620 12:92abcf61971b 296 void Mover(int tm) //Funcion para definir el tiempo de led
Vanessa620 12:92abcf61971b 297 {
Vanessa620 12:92abcf61971b 298 #if DEBUG
Vanessa620 12:92abcf61971b 299 command.printf("Mover a: %i/n", tm);
Vanessa620 12:92abcf61971b 300 #endif
Vanessa620 12:92abcf61971b 301 }
Vanessa620 10:3eab080dbc12 302
fabeltranm 7:fab201aa45b7 303 void command_exe()
Vanessa620 12:92abcf61971b 304 {
Vanessa620 12:92abcf61971b 305 switch (buffer_command[COMM_N]){
Vanessa620 12:92abcf61971b 306
Vanessa620 12:92abcf61971b 307 case (LED_NC):
Vanessa620 12:92abcf61971b 308 #if DEBUG
Vanessa620 12:92abcf61971b 309 command.printf("Led on/off\n");
Vanessa620 12:92abcf61971b 310 #endif
Vanessa620 12:92abcf61971b 311 Led(buffer_command[INITPARAMETER]);
Vanessa620 12:92abcf61971b 312 break;
Vanessa620 12:92abcf61971b 313
Vanessa620 12:92abcf61971b 314 case (DOT_NC):
Vanessa620 12:92abcf61971b 315 #if DEBUG
Vanessa620 12:92abcf61971b 316 command.printf("Punto\n");
Vanessa620 12:92abcf61971b 317 #endif
Vanessa620 12:92abcf61971b 318 punto(buffer_command[INITPARAMETER], buffer_command[INITPARAMETER+1]);
Vanessa620 12:92abcf61971b 319 break;
fabeltranm 7:fab201aa45b7 320
Vanessa620 12:92abcf61971b 321 case (LINE_NC):
Vanessa620 12:92abcf61971b 322 #if DEBUG
Vanessa620 12:92abcf61971b 323 command.printf("Linea o Pendiente\n");
Vanessa620 12:92abcf61971b 324 #endif
Vanessa620 12:92abcf61971b 325 linea(buffer_command[INITPARAMETER],buffer_command[INITPARAMETER+1],buffer_command[INITPARAMETER+2],buffer_command[INITPARAMETER+3]);
Vanessa620 12:92abcf61971b 326 break;
fabeltranm 7:fab201aa45b7 327
Vanessa620 12:92abcf61971b 328 case (RECTANGULO_NC):
Vanessa620 12:92abcf61971b 329 #if DEBUG
Vanessa620 12:92abcf61971b 330 command.printf("Rectangulo \n");
Vanessa620 12:92abcf61971b 331 #endif
Vanessa620 12:92abcf61971b 332 Rectangulo(buffer_command[INITPARAMETER],buffer_command[INITPARAMETER+1],buffer_command[INITPARAMETER+2],buffer_command[INITPARAMETER+3]);
Vanessa620 12:92abcf61971b 333 break;
Vanessa620 12:92abcf61971b 334
Vanessa620 12:92abcf61971b 335 case (CICLE_NC):
Vanessa620 12:92abcf61971b 336 #if DEBUG
Vanessa620 12:92abcf61971b 337 command.printf("Circulo\n");
Vanessa620 12:92abcf61971b 338 #endif
Vanessa620 12:92abcf61971b 339 circle(buffer_command[INITPARAMETER],buffer_command[INITPARAMETER+1],buffer_command[INITPARAMETER+2]);
Vanessa620 12:92abcf61971b 340 break;
fabeltranm 7:fab201aa45b7 341
Vanessa620 12:92abcf61971b 342 case (HOME_NC):
Vanessa620 12:92abcf61971b 343 #if DEBUG
Vanessa620 12:92abcf61971b 344 command.printf("Home \n");
Vanessa620 12:92abcf61971b 345 #endif
Vanessa620 12:92abcf61971b 346 home();
Vanessa620 12:92abcf61971b 347 break;
Vanessa620 12:92abcf61971b 348
Vanessa620 12:92abcf61971b 349 case (RESOLUCION_NC):
Vanessa620 12:92abcf61971b 350 #if DEBUG
Vanessa620 12:92abcf61971b 351 command.printf("Resolucion");
Vanessa620 12:92abcf61971b 352 #endif
Vanessa620 12:92abcf61971b 353 resolucion(buffer_command[INITPARAMETER]);
Vanessa620 12:92abcf61971b 354 break;
fabeltranm 7:fab201aa45b7 355
Vanessa620 12:92abcf61971b 356 case (TIEMPOPASOS_NC):
Vanessa620 12:92abcf61971b 357 #if DEBUG
Vanessa620 12:92abcf61971b 358 command.printf("Tiempo pasos");
Vanessa620 12:92abcf61971b 359 #endif
Vanessa620 12:92abcf61971b 360 TiempoPasos(buffer_command[INITPARAMETER]);
Vanessa620 12:92abcf61971b 361 break;
Vanessa620 12:92abcf61971b 362
Vanessa620 12:92abcf61971b 363 case (STOP_NC):
Vanessa620 12:92abcf61971b 364 #if DEBUG
Vanessa620 12:92abcf61971b 365 command.printf("Stop");
Vanessa620 12:92abcf61971b 366 #endif
Vanessa620 12:92abcf61971b 367 Stop(buffer_command[INITPARAMETER]);
Vanessa620 12:92abcf61971b 368 break;
Vanessa620 12:92abcf61971b 369
Vanessa620 12:92abcf61971b 370 case (PAUSA_NC):
Vanessa620 12:92abcf61971b 371 #if DEBUG
Vanessa620 12:92abcf61971b 372 command.printf("Pausa");
Vanessa620 12:92abcf61971b 373 #endif
Vanessa620 12:92abcf61971b 374 Pausa(buffer_command[INITPARAMETER]);
Vanessa620 12:92abcf61971b 375 break;
Vanessa620 12:92abcf61971b 376
Vanessa620 12:92abcf61971b 377 case (REANUDAR_NC):
Vanessa620 12:92abcf61971b 378 #if DEBUG
Vanessa620 12:92abcf61971b 379 command.printf("Reanudar");
Vanessa620 12:92abcf61971b 380 #endif
Vanessa620 12:92abcf61971b 381 Reanudar(buffer_command[INITPARAMETER]);
Vanessa620 12:92abcf61971b 382 break;
Vanessa620 12:92abcf61971b 383
Vanessa620 12:92abcf61971b 384 case (MOVER_NC):
Vanessa620 12:92abcf61971b 385 #if DEBUG
Vanessa620 12:92abcf61971b 386 command.printf("Mover");
Vanessa620 12:92abcf61971b 387 #endif
Vanessa620 12:92abcf61971b 388 Mover(buffer_command[INITPARAMETER]);
Vanessa620 12:92abcf61971b 389 break;
Vanessa620 12:92abcf61971b 390
Vanessa620 12:92abcf61971b 391 default:
Vanessa620 12:92abcf61971b 392 #if DEBUG
Vanessa620 12:92abcf61971b 393 command.printf("Comando no encontrado\n");
Vanessa620 12:92abcf61971b 394 #endif
Vanessa620 12:92abcf61971b 395 }
fabeltranm 7:fab201aa45b7 396 }
fabeltranm 7:fab201aa45b7 397
Vanessa620 12:92abcf61971b 398 int main()
Vanessa620 12:92abcf61971b 399 {
Vanessa620 12:92abcf61971b 400 myServoX.period_ms(20);
Vanessa620 12:92abcf61971b 401 myServoY.period_ms(20);
Vanessa620 12:92abcf61971b 402 myServoZ.period_ms(20);
Vanessa620 12:92abcf61971b 403
fabeltranm 0:55d11eeb0faf 404 #if DEBUG
fabeltranm 0:55d11eeb0faf 405 command.printf("inicio con debug\n");
fabeltranm 0:55d11eeb0faf 406 #else
fabeltranm 0:55d11eeb0faf 407 command.printf("inicio sin debug\n");
fabeltranm 0:55d11eeb0faf 408 #endif
fabeltranm 0:55d11eeb0faf 409 uint8_t val;
fabeltranm 0:55d11eeb0faf 410 while(1){
fabeltranm 0:55d11eeb0faf 411 val=command.getc();
fabeltranm 0:55d11eeb0faf 412 if (val== '<'){
fabeltranm 0:55d11eeb0faf 413 Read_command();
fabeltranm 4:bcc2d1bebb95 414 if (check_command()){
Vanessa620 11:b4a3db5a0305 415 nodraw();
fabeltranm 7:fab201aa45b7 416 command_exe();
fabeltranm 6:cb6b868465c3 417 #if DEBUG
Vanessa620 12:92abcf61971b 418 echo_command();
Vanessa620 12:92abcf61971b 419 #endif
Vanessa620 12:92abcf61971b 420 }
Vanessa620 12:92abcf61971b 421 }
Vanessa620 12:92abcf61971b 422 }
fabeltranm 0:55d11eeb0faf 423 }
fabeltranm 0:55d11eeb0faf 424