Firmware para placa Praxis
Dependencies: mbed BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
Revision 3:b12ac8d9c397, committed 2017-09-19
- Comitter:
- DiegoColl
- Date:
- Tue Sep 19 20:54:07 2017 +0000
- Parent:
- 2:997b65c65e65
- Commit message:
- praxis 0.1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Aug 14 19:41:43 2017 +0000 +++ b/main.cpp Tue Sep 19 20:54:07 2017 +0000 @@ -1,4 +1,3 @@ -#include<string> #include "mbed.h" #include "TS_DISCO_F746NG.h" #include "LCD_DISCO_F746NG.h" @@ -6,10 +5,10 @@ //-------------------------------------------- definicion de uarts -//Serial pc(USBTX, USBRX); //activar para manejar las dos conexiones uart.(no olvidar ordenar los cambios) +Serial pc(USBTX, USBRX); //activar para manejar las dos conexiones uart.(no olvidar ordenar los cambios) -Serial uart(USBTX, USBRX); //cambiar por el de abajo a la ahora de cargarlo en la placa, para testear con los modulos. -//Serial uart(PC_6, PC_7); +//Serial uart(USBTX, USBRX); //cambiar por el de abajo a la ahora de cargarlo en la placa, para testear con los modulos. +Serial uart(PC_6, PC_7); //-------------------------------------------- definicion de etiquetas @@ -25,11 +24,20 @@ //const char* ECHO_SERVER_ADDRESS = "192.168.2.2"; //const int ECHO_SERVER_PORT = 7; -string ID="C1",ST="OK",AC="",AK=""; +char ID[3]="C1"; +char ST[3]="OK"; +char AC[3]=""; +char AK[3]=""; + //char IDs[]="",STs[]="",ACs[]="",AKs[]=""; char buffer[32]=""; char* aux[10]; + +unsigned int L=0; + +uint8_t text[30]; + //char* acc[4]={"CN","DT","OK","ER"}; int SP=1; int OP=1; @@ -41,6 +49,18 @@ //-------------------------------------------- definicion de funciones +void first_connection(){ + + //------------------------------ programa + + if(strcmp(aux[2],"CN") == 0){ + uart.printf("<C1;OK;YE;51>"); + //time.start(); + } + } + + + void encabezado_lcd(){ //------------------------------ programa @@ -87,7 +107,7 @@ //------------ programa - uart.printf("<%s;%s;S%i;2F>",ID,ST,SP); + uart.printf("<C1;OK;S%i;2F>",SP); SP++; @@ -105,7 +125,9 @@ //------------ programa for(i=0;i<31;i++){ + //pc.putc(cadena[i]); cadena[i]=0x00; + } }; @@ -139,20 +161,104 @@ aux[i]=strtok(buffer,";"); //------------ separa la cadena do{ + //pc.puts(aux[i]); + //pc.putc('-'); i++; aux[i]=strtok(NULL, ";"); }while(aux[i]!=NULL); - + //if(strcmp(aux[??],chksm) == 0){ //------------ comparar checksum (FALTA) - // uart.printf("checksum igual"); + // pc.printf("checksum igual"); // } - if(strcmp(aux[2],"CN") == 0){ //------------ toma de decision + if(strcmp(aux[0],"T1") == 0){ //------------ tipo de sensor TIMER + if(strcmp(aux[2],"CN") == 0){ + uart.printf("<C1;OK;YE;51>"); + lcd.Clear(LCD_COLOR_BLACK); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"TIMER", CENTER_MODE); + //time.start(); + } + + if(strcmp(aux[2],"D1") == 0){ + + + lcd.DisplayStringAt(0, LINE(2+L), (uint8_t *) "Tiempo:", LEFT_MODE); + lcd.DisplayStringAt(130, LINE(2+L), (uint8_t *) aux[3], LEFT_MODE); + lcd.DisplayStringAt(160, LINE(2+L), (uint8_t *) ":", LEFT_MODE); + lcd.DisplayStringAt(170, LINE(2+L), (uint8_t *) aux[4], LEFT_MODE); + lcd.DisplayStringAt(200, LINE(2+L), (uint8_t *) ":", LEFT_MODE); + lcd.DisplayStringAt(210, LINE(2+L), (uint8_t *) aux[5], LEFT_MODE); + + L = L + 1; + + if(L==9){ + L=0; + } + } + } - uart.printf("<%s;%s;YE;51>",ID,ST); + if(strcmp(aux[0],"A1") == 0){ //------------ tipo de sensor TIMER + if(strcmp(aux[2],"CN") == 0){ + uart.printf("<C1;OK;YE;51>"); + lcd.Clear(LCD_COLOR_BLACK); + //lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"ACEL - GIRO - MAG", CENTER_MODE); + //time.start(); + } + + if(strcmp(aux[2],"D1") == 0){ + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"ACELEROMETRO", CENTER_MODE); + + lcd.DisplayStringAt(00, LINE(2+L), (uint8_t *) "X:", LEFT_MODE); + lcd.DisplayStringAt(30, LINE(2+L), (uint8_t *) aux[3], LEFT_MODE); + lcd.DisplayStringAt(80, LINE(2+L), (uint8_t *) "Y:", LEFT_MODE); + lcd.DisplayStringAt(110, LINE(2+L), (uint8_t *) aux[4], LEFT_MODE); + lcd.DisplayStringAt(160, LINE(2+L), (uint8_t *) "Z:", LEFT_MODE); + lcd.DisplayStringAt(190, LINE(2+L), (uint8_t *) aux[5], LEFT_MODE); + + L = L + 1; + + if(L==9){ + L=0; + } + } + if(strcmp(aux[2],"D2") == 0){ + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"GIROSCOPIO", CENTER_MODE); + + lcd.DisplayStringAt(00, LINE(2+L), (uint8_t *) "X:", LEFT_MODE); + lcd.DisplayStringAt(30, LINE(2+L), (uint8_t *) aux[3], LEFT_MODE); + lcd.DisplayStringAt(80, LINE(2+L), (uint8_t *) "Y:", LEFT_MODE); + lcd.DisplayStringAt(110, LINE(2+L), (uint8_t *) aux[4], LEFT_MODE); + lcd.DisplayStringAt(160, LINE(2+L), (uint8_t *) "Z:", LEFT_MODE); + lcd.DisplayStringAt(190, LINE(2+L), (uint8_t *) aux[5], LEFT_MODE); + + L = L + 1; + + if(L==9){ + L=0; + } + } + if(strcmp(aux[2],"D3") == 0){ + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)"MAGNETOMETRO", CENTER_MODE); + + lcd.DisplayStringAt(00, LINE(2+L), (uint8_t *) "X:", LEFT_MODE); + lcd.DisplayStringAt(30, LINE(2+L), (uint8_t *) aux[3], LEFT_MODE); + lcd.DisplayStringAt(80, LINE(2+L), (uint8_t *) "Y:", LEFT_MODE); + lcd.DisplayStringAt(110, LINE(2+L), (uint8_t *) aux[4], LEFT_MODE); + lcd.DisplayStringAt(160, LINE(2+L), (uint8_t *) "Z:", LEFT_MODE); + lcd.DisplayStringAt(190, LINE(2+L), (uint8_t *) aux[5], LEFT_MODE); + + L = L + 1; + + if(L==9){ + L=0; + } + } } + + + /* if(strcmp(aux[2],"D1") == 0){ yx= 120 - *aux[3]; yy= 190 - *aux[4]; @@ -174,6 +280,7 @@ mz= 260 - *aux[5]; //uart.printf("<%s;%s;DT;2F>",ID,ST); } + */ } borrar_buffer(buffer); }; @@ -182,8 +289,8 @@ int main() { - //pc.printf("Inicio de programa\n"); //cambiar uart de destino al final - uart.printf("Inicio de programa\n"); + pc.printf("Inicio de programa\n"); //cambiar de destino al final + //uart.printf("Inicio de programa\n"); encabezado_lcd(); //------------------------------ Interrupciones @@ -195,7 +302,7 @@ while(1) { - refrescar_lcd(); + //refrescar_lcd(); //blinkled(); } }