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