Para Juan

Dependencies:   NAVDATA RA8875 mbed VCODATA

Committer:
gstedile
Date:
Mon Apr 17 12:36:08 2017 +0000
Revision:
9:fe7de0e11862
Parent:
8:941a76c2d300
Child:
10:be7bcb936dcd
Se agregavalidacion de datos recolectados y promediado  antes del almacenamiento.; Tambien grafico interpolado con rectas.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gstedile 0:d92271b032c7 1
gstedile 0:d92271b032c7 2 #include "mbed.h" // v112
gstedile 0:d92271b032c7 3 #include "RA8875.h" // v102
gstedile 0:d92271b032c7 4 #include "MyFont18x32.h"
gstedile 0:d92271b032c7 5 #include "BPG_Arial08x08.h"
gstedile 0:d92271b032c7 6 #include "BPG_Arial10x10.h"
gstedile 0:d92271b032c7 7 #include "BPG_Arial20x20.h"
gstedile 0:d92271b032c7 8 #include "BPG_Arial31x32.h"
gstedile 0:d92271b032c7 9 #include "BPG_Arial63x63.h"
gstedile 0:d92271b032c7 10
gstedile 0:d92271b032c7 11 // Agrego includes para uso en la comunicacion con el gps.
gstedile 4:9901f6da64b7 12 #include "GPS.h"
gstedile 4:9901f6da64b7 13 // Agrego includes para la clase NAVDATA que maneja los datos de navegación del último período.
gstedile 4:9901f6da64b7 14 #include "NAVDATA.h"
gstedile 4:9901f6da64b7 15 // Agrego includes para la clase VCODATA que maneja los datos de navegación más recientes parametrizados por velocidad de cada período.
gstedile 3:0c9ee19fb976 16 #include "VCODATA.h"
gstedile 3:0c9ee19fb976 17
gstedile 9:fe7de0e11862 18 #include <sstream> //include this to use string streams
gstedile 4:9901f6da64b7 19 #include <string>
gstedile 0:d92271b032c7 20
gstedile 9:fe7de0e11862 21 float Counter=0; //Contador de pulsos del sensor de flujo.
gstedile 9:fe7de0e11862 22 float LCounter=0; //Consumo en litros
gstedile 9:fe7de0e11862 23 const int V_M=100; //Velocidad Maxima
gstedile 3:0c9ee19fb976 24 NAVDATA NAVIGATION_TABLE; //Objeto que maneja los datos de navegación del último período. $
gstedile 9:fe7de0e11862 25 VCODATA NAVIGATION_VMATRIX(NAVIGATION_TABLE, V_M); // Objeto que maneja la matriz de datos de navegación $
gstedile 9:fe7de0e11862 26 VCODATA NAVIGATION_V_INTRP_MTRX(NAVIGATION_TABLE, V_M); // Objeto que maneja la matriz de datos de navegación interpolados $
gstedile 0:d92271b032c7 27
gstedile 0:d92271b032c7 28
gstedile 0:d92271b032c7 29
gstedile 4:9901f6da64b7 30 LocalFileSystem local("local"); // Because I want <PrintScreen>
gstedile 4:9901f6da64b7 31 Serial pc(USBTX, USBRX); // And a little feedback
gstedile 0:d92271b032c7 32
gstedile 4:9901f6da64b7 33 RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
gstedile 0:d92271b032c7 34
gstedile 6:aebb3a0a040c 35 //>>>>>>>>>>>>>>>>>> SECCION AGREGADA PROVISORIAMENTE PARA EL TOUCH PANEL <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
gstedile 6:aebb3a0a040c 36
gstedile 6:aebb3a0a040c 37 extern "C" void mbed_reset();
gstedile 6:aebb3a0a040c 38
gstedile 6:aebb3a0a040c 39
gstedile 6:aebb3a0a040c 40 #define min(a,b) ((a<b)?a:b)
gstedile 6:aebb3a0a040c 41 #define max(a,b) ((a>b)?a:b)
gstedile 6:aebb3a0a040c 42
gstedile 6:aebb3a0a040c 43 bool Intersect(rect_t rect, point_t p)
gstedile 6:aebb3a0a040c 44 {
gstedile 6:aebb3a0a040c 45 if (p.x >= min(rect.p1.x, rect.p2.x) && p.x <= max(rect.p1.x, rect.p2.x)
gstedile 6:aebb3a0a040c 46 && p.y >= min(rect.p1.y, rect.p2.y) && p.y <= max(rect.p1.y, rect.p2.y))
gstedile 6:aebb3a0a040c 47 return true;
gstedile 6:aebb3a0a040c 48 else
gstedile 6:aebb3a0a040c 49 return false;
gstedile 6:aebb3a0a040c 50 }
gstedile 6:aebb3a0a040c 51
gstedile 6:aebb3a0a040c 52 int GetScreenCapture(void)
gstedile 6:aebb3a0a040c 53 {
gstedile 6:aebb3a0a040c 54 char fqfn[50];
gstedile 6:aebb3a0a040c 55 int i = 0;
gstedile 6:aebb3a0a040c 56
gstedile 6:aebb3a0a040c 57 pc.printf("Screen Capture... ");
gstedile 6:aebb3a0a040c 58 for (i=1; i< 100; i++) {
gstedile 6:aebb3a0a040c 59 snprintf(fqfn, sizeof(fqfn), "/local/Screen%02d.bmp", i);
gstedile 6:aebb3a0a040c 60 FILE * fh = fopen(fqfn, "rb");
gstedile 6:aebb3a0a040c 61 if (!fh) {
gstedile 6:aebb3a0a040c 62 lcd.PrintScreen(0,0,480,272,fqfn);
gstedile 6:aebb3a0a040c 63 pc.printf(" as /local/Screen%02d.bmp\r\n", i);
gstedile 6:aebb3a0a040c 64 return i;
gstedile 6:aebb3a0a040c 65 } else {
gstedile 6:aebb3a0a040c 66 fclose(fh); // close this and try the next
gstedile 6:aebb3a0a040c 67 }
gstedile 6:aebb3a0a040c 68 }
gstedile 6:aebb3a0a040c 69 return 0;
gstedile 6:aebb3a0a040c 70 }
gstedile 6:aebb3a0a040c 71 //>>>>>>>>>>>>>>>>>> FIN SECCION AGREGADA PROVISORIAMENTE PARA EL TOUCH PANEL <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
gstedile 6:aebb3a0a040c 72
gstedile 9:fe7de0e11862 73 //Función para la interrupción
gstedile 6:aebb3a0a040c 74
gstedile 9:fe7de0e11862 75 void trigger() {
gstedile 0:d92271b032c7 76 Counter++;
gstedile 0:d92271b032c7 77 LCounter=Counter/2500;
gstedile 0:d92271b032c7 78 }
gstedile 9:fe7de0e11862 79
gstedile 9:fe7de0e11862 80
gstedile 9:fe7de0e11862 81 /* Funcion print_VCO_curve : Imprime la curva de consumo/milla en funcion de la velocidad a partir del vector de objetos NAV_DATA de la clase VCODATA, con lineas (printline=1) o puntos (=0)*/
gstedile 5:56d63eaa8415 82
gstedile 9:fe7de0e11862 83 void print_VCO_curve(VCODATA Matrix_VCO, int printline){
gstedile 9:fe7de0e11862 84 float s; // Consumo
gstedile 9:fe7de0e11862 85 int y,x;
gstedile 7:93da358c67a1 86 int VCO= Matrix_VCO.get_VCO();
gstedile 9:fe7de0e11862 87 int y_offset=200;
gstedile 9:fe7de0e11862 88 int x_offset=25;
gstedile 9:fe7de0e11862 89 int y_i=y_offset; //Punto origen y
gstedile 9:fe7de0e11862 90 int x_i=x_offset; //Punto origen x
gstedile 9:fe7de0e11862 91 int x_scale=4; // Escala para graficar eje x.
gstedile 9:fe7de0e11862 92 int y_scale=50; // Escala para graficar eje y.
gstedile 6:aebb3a0a040c 93 lcd.background(RGB(255,255,255));
gstedile 6:aebb3a0a040c 94 lcd.foreground(Blue);
gstedile 6:aebb3a0a040c 95 lcd.SetTextCursor(0,0); // Pongo cursor en posicion
gstedile 6:aebb3a0a040c 96 lcd.cls();
gstedile 6:aebb3a0a040c 97 lcd.puts(">>>>>>>>>>>>>< Proyecto SNOCC ><<<<<<<<<<<<<<\r\n");
gstedile 8:941a76c2d300 98 lcd.roundrect( 5,25, 470,270, 10,8, RGB(255,255,0));
gstedile 8:941a76c2d300 99 //lcd.fillroundrect(415,165, 470,185, 5,3, Orange);
gstedile 8:941a76c2d300 100 lcd.fillroundrect(10,30, 465,264, 5,3, Green);
gstedile 8:941a76c2d300 101 lcd.background(Green);
gstedile 8:941a76c2d300 102 lcd.foreground(Blue);
gstedile 8:941a76c2d300 103 lcd.SetTextCursor(12,32);
gstedile 8:941a76c2d300 104 lcd.puts("Consumo(l/m)\r\n");
gstedile 8:941a76c2d300 105 lcd.SetTextCursor(240,240);
gstedile 8:941a76c2d300 106 lcd.puts("Velocidad(kn)\r\n");
gstedile 8:941a76c2d300 107 lcd.foreground(RGB(255,255,0));
gstedile 9:fe7de0e11862 108
gstedile 9:fe7de0e11862 109
gstedile 9:fe7de0e11862 110
gstedile 9:fe7de0e11862 111 for (int n=0;n<Matrix_VCO.vel_max;n++){ // Recorre x de 0 a vel_max.
gstedile 9:fe7de0e11862 112 s = Matrix_VCO.NAV_DATA[n].LAST_NAV_DATA[cons_mile_p]; // Consumo por milla del período
gstedile 9:fe7de0e11862 113 y=int(y_offset-y_scale*s); // El consumo máximo es alrededor de 100 l/m => Multiplico por y_scale para que ocupe mas pantalla.
gstedile 9:fe7de0e11862 114 x=n*x_scale+x_offset; // para aumentar el span (eje x)
gstedile 9:fe7de0e11862 115 if (printline)lcd.line(x_i,y_i,x,y); // Imprime linea
gstedile 9:fe7de0e11862 116 else{
gstedile 9:fe7de0e11862 117 lcd.SetTextCursor(x,y);
gstedile 5:56d63eaa8415 118 lcd.printf(".");
gstedile 5:56d63eaa8415 119 }
gstedile 9:fe7de0e11862 120 x_i=x;
gstedile 9:fe7de0e11862 121 y_i=y;
gstedile 9:fe7de0e11862 122 }
gstedile 8:941a76c2d300 123 if (VCO>0){
gstedile 9:fe7de0e11862 124 s = Matrix_VCO.NAV_DATA[VCO].LAST_NAV_DATA[cons_mile_p];; // Valor de consumo para VCO.
gstedile 9:fe7de0e11862 125 y=int(y_offset-y_scale*s); // el consumo máximo es alrededor de 2 l/m. Multiplico por y_scale para que ocupe mas pantalla.
gstedile 9:fe7de0e11862 126 x=VCO*x_scale+x_offset; // para aumentar el span (eje x)
gstedile 9:fe7de0e11862 127 if (printline)lcd.circle(x,y,5);
gstedile 9:fe7de0e11862 128 else{
gstedile 9:fe7de0e11862 129 lcd.SetTextCursor(x,y);
gstedile 9:fe7de0e11862 130 lcd.printf("o");
gstedile 9:fe7de0e11862 131 }
gstedile 9:fe7de0e11862 132 lcd.SetTextCursor(20+x_offset,y_offset-130);
gstedile 9:fe7de0e11862 133 lcd.printf("Consumo_VCO: %f",s);
gstedile 8:941a76c2d300 134 }
gstedile 8:941a76c2d300 135 else{
gstedile 9:fe7de0e11862 136 lcd.SetTextCursor(40,60);
gstedile 8:941a76c2d300 137 lcd.printf("No hay datos suficientes para obtener la VCO");
gstedile 8:941a76c2d300 138 //lcd.printf("%d",VCO);
gstedile 8:941a76c2d300 139 }
gstedile 6:aebb3a0a040c 140 lcd.foreground(RGB(255,255,0));
gstedile 6:aebb3a0a040c 141 lcd.background(Black);
gstedile 5:56d63eaa8415 142 }
gstedile 5:56d63eaa8415 143
gstedile 5:56d63eaa8415 144
gstedile 6:aebb3a0a040c 145 /* Funcion build_test_Mtrx: Carga los datos (consumo/milla) del vector LAST_NAV_DATA de los objetos NAVDATA de VCODATA para testing.*/
gstedile 5:56d63eaa8415 146
gstedile 5:56d63eaa8415 147 void build_test_Mtrx(VCODATA Test_Matrix_VCO){
gstedile 5:56d63eaa8415 148 NAVDATA TestNDO;
gstedile 9:fe7de0e11862 149
gstedile 9:fe7de0e11862 150 TestNDO.LAST_NAV_DATA[cons_mile_p]=3;
gstedile 9:fe7de0e11862 151 TestNDO.LAST_NAV_DATA[speed_p]=15;
gstedile 9:fe7de0e11862 152 Test_Matrix_VCO.store_data(TestNDO);
gstedile 9:fe7de0e11862 153 Test_Matrix_VCO.store_data(TestNDO);
gstedile 9:fe7de0e11862 154 TestNDO.LAST_NAV_DATA[cons_mile_p]=1;
gstedile 9:fe7de0e11862 155 TestNDO.LAST_NAV_DATA[speed_p]=30;
gstedile 9:fe7de0e11862 156 Test_Matrix_VCO.store_data(TestNDO);
gstedile 9:fe7de0e11862 157 Test_Matrix_VCO.store_data(TestNDO);
gstedile 9:fe7de0e11862 158 TestNDO.LAST_NAV_DATA[cons_mile_p]=2.5;
gstedile 9:fe7de0e11862 159 TestNDO.LAST_NAV_DATA[speed_p]=Test_Matrix_VCO.vel_max-1;
gstedile 9:fe7de0e11862 160 Test_Matrix_VCO.store_data(TestNDO);
gstedile 9:fe7de0e11862 161 Test_Matrix_VCO.store_data(TestNDO);
gstedile 9:fe7de0e11862 162 Test_Matrix_VCO.interpolate();
gstedile 9:fe7de0e11862 163
gstedile 9:fe7de0e11862 164 /*for (int i=0;i<30;i++){
gstedile 6:aebb3a0a040c 165 TestNDO.LAST_NAV_DATA[cons_mile_p]=i+1;
gstedile 5:56d63eaa8415 166 TestNDO.LAST_NAV_DATA[speed_p]=i;
gstedile 5:56d63eaa8415 167 Test_Matrix_VCO.store_data(TestNDO);
gstedile 5:56d63eaa8415 168 }
gstedile 7:93da358c67a1 169 for (int i=30,x=30;i>1;i--,x++){
gstedile 5:56d63eaa8415 170 TestNDO.LAST_NAV_DATA[cons_mile_p]=i;
gstedile 5:56d63eaa8415 171 TestNDO.LAST_NAV_DATA[speed_p]=x;
gstedile 5:56d63eaa8415 172 Test_Matrix_VCO.store_data(TestNDO);
gstedile 5:56d63eaa8415 173 }
gstedile 8:941a76c2d300 174 TestNDO.LAST_NAV_DATA[cons_mile_p]=1;
gstedile 8:941a76c2d300 175 TestNDO.LAST_NAV_DATA[speed_p]=55;
gstedile 8:941a76c2d300 176 Test_Matrix_VCO.store_data(TestNDO);
gstedile 7:93da358c67a1 177 for (int i=1,x=59;i<40;i++,x++){
gstedile 7:93da358c67a1 178 TestNDO.LAST_NAV_DATA[cons_mile_p]=i+1;
gstedile 7:93da358c67a1 179 TestNDO.LAST_NAV_DATA[speed_p]=x;
gstedile 7:93da358c67a1 180 Test_Matrix_VCO.store_data(TestNDO);
gstedile 9:fe7de0e11862 181 }*/
gstedile 5:56d63eaa8415 182 }
gstedile 5:56d63eaa8415 183
gstedile 0:d92271b032c7 184
gstedile 0:d92271b032c7 185 int main()
gstedile 0:d92271b032c7 186 {
gstedile 0:d92271b032c7 187 pc.baud(460800); // I like a snappy terminal, so crank it up!
gstedile 0:d92271b032c7 188 pc.printf("\r\nRA8875 Soft Fonts - Build " __DATE__ " " __TIME__ "\r\n");
gstedile 0:d92271b032c7 189
gstedile 0:d92271b032c7 190 lcd.init();
gstedile 6:aebb3a0a040c 191
gstedile 6:aebb3a0a040c 192 lcd.TouchPanelCalibrate("Calibrate the touch panel"); // 4 touch
gstedile 6:aebb3a0a040c 193 lcd.cls();
gstedile 6:aebb3a0a040c 194
gstedile 6:aebb3a0a040c 195 rect_t PrintScreenRect = { 425-65, 20, 425+65, 60};
gstedile 6:aebb3a0a040c 196
gstedile 4:9901f6da64b7 197
gstedile 4:9901f6da64b7 198 // **************************
gstedile 0:d92271b032c7 199 //RunTestSet(lcd, pc); // If the library was compiled for test mode...
gstedile 0:d92271b032c7 200
gstedile 0:d92271b032c7 201 lcd.foreground(RGB(255,255,0)); // Seteo del color de las letras.
gstedile 0:d92271b032c7 202 lcd.SelectUserFont(BPG_Arial20x20); // Seleccion de tipo y tamaño de letras
gstedile 0:d92271b032c7 203 //lcd.puts("BPG_Arial63x63");
gstedile 6:aebb3a0a040c 204
gstedile 0:d92271b032c7 205 GPS gps(p9, p10); // Agrego para comunicacion con el GPS
gstedile 0:d92271b032c7 206
gstedile 0:d92271b032c7 207
gstedile 4:9901f6da64b7 208 //----------------------------------------------------
gstedile 4:9901f6da64b7 209 // Sensor de flujo:
gstedile 0:d92271b032c7 210 //-----------------------------------------------------
gstedile 0:d92271b032c7 211 InterruptIn pulse_sensor(p11); // Defino pulse_sensor como una entrada de interrupción en p11.
gstedile 0:d92271b032c7 212 pulse_sensor.mode(PullUp); // PullUp para esa entrada.
gstedile 0:d92271b032c7 213 //DigitalOut led(LED1);
gstedile 0:d92271b032c7 214 pulse_sensor.rise(&trigger); // Dispara interrupción con flanco ascendente. (Podría tambien ser desecendente--> fall)
gstedile 0:d92271b032c7 215
gstedile 4:9901f6da64b7 216
gstedile 4:9901f6da64b7 217
gstedile 4:9901f6da64b7 218
gstedile 4:9901f6da64b7 219 while(1) {
gstedile 4:9901f6da64b7 220
gstedile 5:56d63eaa8415 221 lcd.SetTextCursor(0,0); // Pongo cursor en posicion
gstedile 5:56d63eaa8415 222 lcd.puts(">>>>>>>>>>>>>< Proyecto SNOCC ><<<<<<<<<<<<<<\r\n");
gstedile 4:9901f6da64b7 223
gstedile 0:d92271b032c7 224
gstedile 0:d92271b032c7 225 //-----------------------------------------------------
gstedile 0:d92271b032c7 226
gstedile 3:0c9ee19fb976 227 //lcd.SetTextCursor(0,20);
gstedile 0:d92271b032c7 228 //lcd.printf("M0: %s \r\n\r\n", gps.msg); //Imprimo el mensaje crudo proveniente de la uart
gstedile 9:fe7de0e11862 229
gstedile 0:d92271b032c7 230
gstedile 0:d92271b032c7 231 if(gps.sample()) { // Si es exitosa la obtencion de datos del gps.
gstedile 3:0c9ee19fb976 232 lcd.cls();
gstedile 5:56d63eaa8415 233 lcd.SetTextCursor(0,0); // Pongo cursor en posicion
gstedile 5:56d63eaa8415 234 lcd.puts(">>>>>>>>>>>>>< Proyecto SNOCC ><<<<<<<<<<<<<<\r\n");
gstedile 3:0c9ee19fb976 235
gstedile 4:9901f6da64b7 236 if (NAVIGATION_TABLE.rotate_data(gps.longitude, gps.latitude, gps.time, Counter)){
gstedile 9:fe7de0e11862 237 NAVIGATION_VMATRIX.store_data(NAVIGATION_TABLE);// Luego de rotar los datos en la tabla de navegacion, la guarda en la matriz segun criterios de la clase VCODATA
gstedile 5:56d63eaa8415 238 lcd.puts("Rotacion exitosa!-->");
gstedile 8:941a76c2d300 239 int i=int(NAVIGATION_TABLE.LAST_NAV_DATA[speed_p]);
gstedile 8:941a76c2d300 240 int VCO=NAVIGATION_VMATRIX.get_VCO();
gstedile 9:fe7de0e11862 241 float timetick_f_Last = NAVIGATION_TABLE.LAST_NAV_DATA[speed_p]; // DEBUG
gstedile 4:9901f6da64b7 242 float timetick_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[time_f]; // DEBUG
gstedile 4:9901f6da64b7 243 float distance_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[distance_p]; // DEBUG
gstedile 4:9901f6da64b7 244 float speed_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[speed_p]; // DEBUG
gstedile 9:fe7de0e11862 245 float speed_p_Last = NAVIGATION_TABLE.LAST_NAV_DATA[speed_p]; // DEBUG
gstedile 4:9901f6da64b7 246 float longitude_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[longitude_f]; // DEBUG
gstedile 4:9901f6da64b7 247 float latitude_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[latitude_f]; // DEBUG
gstedile 4:9901f6da64b7 248 float cons_hour_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[cons_hour_p];
gstedile 8:941a76c2d300 249 float cons_mile_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[cons_mile_p];
gstedile 8:941a76c2d300 250 //lcd.printf("Algunos datos guardados en la Matriz: \r\n"); // DEBUG
gstedile 8:941a76c2d300 251 lcd.printf("INDICE_Mtrx: %d\r\n\r\n",i); // DEBUG
gstedile 8:941a76c2d300 252 lcd.printf("Speed_f_Mtrx(%d): %f kn.\r\n",i, speed_p_Mtrx); // DEBUG
gstedile 9:fe7de0e11862 253 lcd.printf("Speed_f_Last(%d): %f km/h.\r\n\r\n",i, speed_p_Last*1.852); // DEBUG
gstedile 8:941a76c2d300 254 lcd.printf("Time_f_Mtrx(%d): %f Hours.\r\n",i, timetick_f_Mtrx); // DEBUG
gstedile 9:fe7de0e11862 255 lcd.printf("Time_f_Last(%d): %f Hours.\r\n",i, timetick_f_Last); // DEBUG
gstedile 8:941a76c2d300 256 lcd.printf("Dist_p_Mtrx(%d): %f miles.\r\n",i,distance_p_Mtrx); // DEBUG
gstedile 8:941a76c2d300 257 lcd.printf("Posicion: Long(%d): %f ; Lat: %f\r\n",i,longitude_f_Mtrx,latitude_f_Mtrx); // DEBUG
gstedile 8:941a76c2d300 258 lcd.printf("FlujoVCOmtrx(%d): %f Litros/Hora\r\n",i, cons_hour_p_Mtrx); // DEBUG
gstedile 8:941a76c2d300 259 lcd.printf("FlujoVCOmtrx(%d): %f Litros/Milla\r\n",i, cons_mile_p_Mtrx); // DEBUG
gstedile 9:fe7de0e11862 260 lcd.printf("Cons. Acumulado: %f l\r\n", LCounter);
gstedile 8:941a76c2d300 261 lcd.printf("VCO: %d km/h\r\n", VCO);
gstedile 9:fe7de0e11862 262
gstedile 9:fe7de0e11862 263
gstedile 9:fe7de0e11862 264 NAVIGATION_VMATRIX.interpolate();
gstedile 9:fe7de0e11862 265
gstedile 6:aebb3a0a040c 266 //build_test_Mtrx(NAVIGATION_VMATRIX); // DEBUG Curve
gstedile 9:fe7de0e11862 267 //print_VCO_curve(NAVIGATION_VMATRIX,1);
gstedile 4:9901f6da64b7 268 }
gstedile 3:0c9ee19fb976 269 else
gstedile 4:9901f6da64b7 270 {
gstedile 3:0c9ee19fb976 271 lcd.puts("Periodo no valido!\r\n");
gstedile 4:9901f6da64b7 272 int i=int(NAVIGATION_TABLE.LAST_NAV_DATA[speed_p]);
gstedile 4:9901f6da64b7 273 float timetick_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[time_f]; // DEBUG
gstedile 4:9901f6da64b7 274 float distance_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[distance_p]; // DEBUG
gstedile 4:9901f6da64b7 275 float speed_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[speed_p]; // DEBUG
gstedile 4:9901f6da64b7 276 float longitude_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[longitude_f]; // DEBUG
gstedile 4:9901f6da64b7 277 float latitude_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[latitude_f]; // DEBUG
gstedile 4:9901f6da64b7 278 float cons_hour_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[cons_hour_p]; // DEBUG
gstedile 4:9901f6da64b7 279 lcd.printf("Algunos datos guardados en la Matriz: \r\n"); // DEBUG
gstedile 5:56d63eaa8415 280 lcd.printf("INDICE_Mtrx: %d (Parte entera de speed)\r\n",i); // DEBUG
gstedile 5:56d63eaa8415 281 lcd.printf("Speed_f_Mtrx(%d): %f kn.\r\n",i, speed_p_Mtrx); // DEBUG
gstedile 5:56d63eaa8415 282 lcd.printf("Time_f_Mtrx(%d): %f Hours.\r\n",i, timetick_f_Mtrx); // DEBUG
gstedile 5:56d63eaa8415 283 lcd.printf("Distance_p_Mtrx(%d): %f miles.\r\n",i,distance_p_Mtrx); // DEBUG
gstedile 5:56d63eaa8415 284 lcd.printf("Posicion: Long(%d): %f, Lat: %f\r\n",i,longitude_f_Mtrx,latitude_f_Mtrx); // DEBUG
gstedile 5:56d63eaa8415 285 lcd.printf("FlujoVCOmtrx(%d): %f Litros/Hora\r\n",i, cons_hour_p_Mtrx); // DEBUG
gstedile 4:9901f6da64b7 286 }
gstedile 9:fe7de0e11862 287
gstedile 0:d92271b032c7 288
gstedile 4:9901f6da64b7 289 }
gstedile 4:9901f6da64b7 290 else {
gstedile 0:d92271b032c7 291 lcd.cls();
gstedile 5:56d63eaa8415 292 lcd.SetTextCursor(0,0); // Pongo cursor en posicion
gstedile 5:56d63eaa8415 293 lcd.puts(">>>>>>>>>>>>>< Proyecto SNOCC ><<<<<<<<<<<<<<\r\n");
gstedile 0:d92271b032c7 294 lcd.SetTextCursor(0,100);
gstedile 6:aebb3a0a040c 295 lcd.printf("Aun no hay datos disponibles :(\r\n");
gstedile 3:0c9ee19fb976 296 lcd.SetTextCursor(0,180);
gstedile 6:aebb3a0a040c 297 lcd.printf("Timetick %f h\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[time_f]);
gstedile 6:aebb3a0a040c 298 lcd.printf("Flujo Mtrx: %f Litros/Hora\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[cons_hour_p]);
gstedile 6:aebb3a0a040c 299 lcd.printf("Flujo Counter: %f Litros\r\n", LCounter);
gstedile 9:fe7de0e11862 300
gstedile 9:fe7de0e11862 301 //build_test_Mtrx(NAVIGATION_VMATRIX); //DEBUG
gstedile 9:fe7de0e11862 302
gstedile 0:d92271b032c7 303 }
gstedile 6:aebb3a0a040c 304
gstedile 6:aebb3a0a040c 305
gstedile 8:941a76c2d300 306 for (int i=0;i<200;i++) {
gstedile 6:aebb3a0a040c 307 point_t p;
gstedile 6:aebb3a0a040c 308 lcd.fillrect(PrintScreenRect, Green);
gstedile 6:aebb3a0a040c 309 lcd.foreground(Blue);
gstedile 6:aebb3a0a040c 310 lcd.background(Green);
gstedile 6:aebb3a0a040c 311 lcd.puts(425-60, 22, "GET CURVE");
gstedile 6:aebb3a0a040c 312 lcd.background(Black);
gstedile 9:fe7de0e11862 313 //wait_us(1);
gstedile 6:aebb3a0a040c 314 if (lcd.TouchPanelReadable(&p)) {
gstedile 6:aebb3a0a040c 315 //lcd.foreground(Blue);
gstedile 6:aebb3a0a040c 316 //lcd.SetTextCursor(10, 15);
gstedile 6:aebb3a0a040c 317 //lcd.printf("(%3d,%3d)", p.x, p.y);
gstedile 6:aebb3a0a040c 318 //lcd.foreground(RGB(255,255,0));
gstedile 6:aebb3a0a040c 319
gstedile 6:aebb3a0a040c 320 if (Intersect(PrintScreenRect, p)) {
gstedile 6:aebb3a0a040c 321 lcd.foreground(Red);
gstedile 6:aebb3a0a040c 322 lcd.puts(400-38, 20, "GET CURVE");
gstedile 8:941a76c2d300 323 //build_test_Mtrx(NAVIGATION_VMATRIX); // DEBUG Curve
gstedile 9:fe7de0e11862 324 print_VCO_curve(NAVIGATION_VMATRIX,0);
gstedile 6:aebb3a0a040c 325 //lcd.foreground(RGB(255,255,0));
gstedile 9:fe7de0e11862 326 wait(5);
gstedile 9:fe7de0e11862 327 print_VCO_curve(NAVIGATION_VMATRIX,1);
gstedile 9:fe7de0e11862 328 wait(5);
gstedile 6:aebb3a0a040c 329 break;
gstedile 6:aebb3a0a040c 330 //GetScreenCapture();
gstedile 6:aebb3a0a040c 331 }
gstedile 6:aebb3a0a040c 332
gstedile 6:aebb3a0a040c 333 /*for (int i=0; i<3; i++) {
gstedile 6:aebb3a0a040c 334 if (Intersect(RGBList[i], p)) {
gstedile 6:aebb3a0a040c 335 uint8_t mag = (255 * (p.x - RGBList[i].p1.x)) / (RGBList[i].p2.x - RGBList[i].p1.x);
gstedile 6:aebb3a0a040c 336 rgbVal[i] = mag;
gstedile 6:aebb3a0a040c 337 lcd.SetTextCursor(380, 15);
gstedile 6:aebb3a0a040c 338 lcd.foreground(Blue);
gstedile 6:aebb3a0a040c 339 //lcd.printf("(%02X,%02X,%02X)", rgbVal[0], rgbVal[1], rgbVal[2]);
gstedile 6:aebb3a0a040c 340 //rgb = RGB(rgbVal[0], rgbVal[1], rgbVal[2]);
gstedile 6:aebb3a0a040c 341 //lcd.fillrect(RGBList[3], rgb);
gstedile 6:aebb3a0a040c 342 break;
gstedile 6:aebb3a0a040c 343 }*/
gstedile 6:aebb3a0a040c 344 }
gstedile 6:aebb3a0a040c 345 lcd.foreground(RGB(255,255,0));
gstedile 6:aebb3a0a040c 346 }
gstedile 6:aebb3a0a040c 347 }
gstedile 4:9901f6da64b7 348 }
gstedile 6:aebb3a0a040c 349
gstedile 6:aebb3a0a040c 350