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 02_LAB_serial_protocol by
Diff: main.cpp
- Revision:
- 6:cb6b868465c3
- Parent:
- 5:bf9591a365a4
- Child:
- 7:fab201aa45b7
--- a/main.cpp Wed Apr 26 18:45:43 2017 +0000 +++ b/main.cpp Sat Sep 23 13:49:55 2017 +0000 @@ -8,19 +8,18 @@ //***************************************************************************** // COMANDO MOVER MOTOR // |POS 1|POS 2|POS 3|POS 4| POS 5| -// | < | #M | , | #°G | > | +// | < | #C | a | b | c | d | > | // -// #M -> indica el motor que se va a mover -// #°G -> indica los grados a mover del servomotor -// <,> -> inicio, separdor y fin de comando +// #C -> indica el comando +// a,b,c,d parametros del comando +// <,> -> inicio, y fin de comando // el inicio de comando no se almacena en el buffer //***************************************************************************** // VARIABLES PARA DEFINIR EL COMMANDO #define BUFF_SIZE 4 -#define COMM_NUM_MOTOR 0 -#define COMM_SEPARADOR 1 -#define COMM_GRADOS_MOTOR 2 +#define COMM_N 0 +#define INITPARAMETER 1 uint8_t buffer_command[BUFF_SIZE]={0,0,0,0}; @@ -62,14 +61,12 @@ uint8_t check_command() { - if (buffer_command[BUFF_SIZE-1]== '>' && buffer_command[COMM_SEPARADOR]==','){ + if (buffer_command[BUFF_SIZE-1]== '>'){ #if DEBUG - command.printf("\nMover Motor:"); - print_bin2hex(buffer_command[COMM_NUM_MOTOR]); + command.printf("\nComando:"); + print_bin2hex(buffer_command[COMM_N]); command.printf(" -> "); - print_bin2hex(buffer_command[COMM_GRADOS_MOTOR]); - command.printf(" grados \n"); #endif return 1; } @@ -81,12 +78,11 @@ } -void command_motor(uint8_t nm,uint8_t grados) +void command_led(int tm) { - // aca se debe modificar el codigo del motor //EJEMPLO DE COMANDO led=1; - wait(1); + wait(tm); led=0; } @@ -102,8 +98,11 @@ if (val== '<'){ Read_command(); if (check_command()){ - command_motor(buffer_command[COMM_NUM_MOTOR],buffer_command[COMM_GRADOS_MOTOR]); - } + command_led(buffer_command[INITPARAMETER]); + #if DEBUG + echo_command(); + #endif + } } }