Para Juan
Dependencies: NAVDATA RA8875 mbed VCODATA
main.cpp@7:93da358c67a1, 2017-04-13 (annotated)
- Committer:
- gstedile
- Date:
- Thu Apr 13 21:00:52 2017 +0000
- Revision:
- 7:93da358c67a1
- Parent:
- 6:aebb3a0a040c
- Child:
- 8:941a76c2d300
OBTIENE VCO
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 | 6:aebb3a0a040c | 96 | lcd.SetTextCursor(0,30); |
gstedile | 6:aebb3a0a040c | 97 | lcd.puts("Consumo (L/M)\r\n"); |
gstedile | 6:aebb3a0a040c | 98 | lcd.SetTextCursor(200,220); |
gstedile | 6:aebb3a0a040c | 99 | lcd.puts("Velocidad(Kn)\r\n"); |
gstedile | 6:aebb3a0a040c | 100 | lcd.foreground(Red); |
gstedile | 7:93da358c67a1 | 101 | |
gstedile | 5:56d63eaa8415 | 102 | for (int x=0;x<100;x++){ |
gstedile | 5:56d63eaa8415 | 103 | s = Matrix_VCO.NAV_DATA[x].LAST_NAV_DATA[cons_mile_p]; |
gstedile | 5:56d63eaa8415 | 104 | 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 | 105 | z=x*4; // para aumentar el span (eje x) |
gstedile | 5:56d63eaa8415 | 106 | lcd.SetTextCursor(z,y); |
gstedile | 5:56d63eaa8415 | 107 | //lcd.printf("%d",x); |
gstedile | 5:56d63eaa8415 | 108 | lcd.printf("."); |
gstedile | 5:56d63eaa8415 | 109 | } |
gstedile | 7:93da358c67a1 | 110 | s = Matrix_VCO.NAV_DATA[VCO].LAST_NAV_DATA[cons_mile_p];; |
gstedile | 7:93da358c67a1 | 111 | y=200-2*s; // el consumo máximo es alrededor de 100 l/m. Multiplico por 2 para que ocupe mas pantalla. |
gstedile | 7:93da358c67a1 | 112 | z=VCO*4; // para aumentar el span (eje x) |
gstedile | 7:93da358c67a1 | 113 | lcd.SetTextCursor(z,y); |
gstedile | 7:93da358c67a1 | 114 | //lcd.printf("%d",x); |
gstedile | 7:93da358c67a1 | 115 | lcd.printf("%d",VCO); |
gstedile | 7:93da358c67a1 | 116 | |
gstedile | 6:aebb3a0a040c | 117 | lcd.foreground(RGB(255,255,0)); |
gstedile | 6:aebb3a0a040c | 118 | lcd.background(Black); |
gstedile | 5:56d63eaa8415 | 119 | } |
gstedile | 5:56d63eaa8415 | 120 | |
gstedile | 5:56d63eaa8415 | 121 | |
gstedile | 6:aebb3a0a040c | 122 | /* 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 | 123 | |
gstedile | 5:56d63eaa8415 | 124 | void build_test_Mtrx(VCODATA Test_Matrix_VCO){ |
gstedile | 5:56d63eaa8415 | 125 | NAVDATA TestNDO; |
gstedile | 7:93da358c67a1 | 126 | for (int i=0;i<30;i++){ |
gstedile | 6:aebb3a0a040c | 127 | TestNDO.LAST_NAV_DATA[cons_mile_p]=i+1; |
gstedile | 5:56d63eaa8415 | 128 | TestNDO.LAST_NAV_DATA[speed_p]=i; |
gstedile | 5:56d63eaa8415 | 129 | Test_Matrix_VCO.store_data(TestNDO); |
gstedile | 5:56d63eaa8415 | 130 | } |
gstedile | 7:93da358c67a1 | 131 | for (int i=30,x=30;i>1;i--,x++){ |
gstedile | 5:56d63eaa8415 | 132 | TestNDO.LAST_NAV_DATA[cons_mile_p]=i; |
gstedile | 5:56d63eaa8415 | 133 | TestNDO.LAST_NAV_DATA[speed_p]=x; |
gstedile | 5:56d63eaa8415 | 134 | Test_Matrix_VCO.store_data(TestNDO); |
gstedile | 5:56d63eaa8415 | 135 | } |
gstedile | 7:93da358c67a1 | 136 | for (int i=1,x=59;i<40;i++,x++){ |
gstedile | 7:93da358c67a1 | 137 | TestNDO.LAST_NAV_DATA[cons_mile_p]=i+1; |
gstedile | 7:93da358c67a1 | 138 | TestNDO.LAST_NAV_DATA[speed_p]=x; |
gstedile | 7:93da358c67a1 | 139 | Test_Matrix_VCO.store_data(TestNDO); |
gstedile | 7:93da358c67a1 | 140 | } |
gstedile | 5:56d63eaa8415 | 141 | } |
gstedile | 5:56d63eaa8415 | 142 | |
gstedile | 0:d92271b032c7 | 143 | |
gstedile | 0:d92271b032c7 | 144 | int main() |
gstedile | 0:d92271b032c7 | 145 | { |
gstedile | 0:d92271b032c7 | 146 | pc.baud(460800); // I like a snappy terminal, so crank it up! |
gstedile | 0:d92271b032c7 | 147 | pc.printf("\r\nRA8875 Soft Fonts - Build " __DATE__ " " __TIME__ "\r\n"); |
gstedile | 0:d92271b032c7 | 148 | |
gstedile | 0:d92271b032c7 | 149 | lcd.init(); |
gstedile | 6:aebb3a0a040c | 150 | |
gstedile | 6:aebb3a0a040c | 151 | lcd.TouchPanelCalibrate("Calibrate the touch panel"); // 4 touch |
gstedile | 6:aebb3a0a040c | 152 | lcd.cls(); |
gstedile | 6:aebb3a0a040c | 153 | |
gstedile | 6:aebb3a0a040c | 154 | rect_t PrintScreenRect = { 425-65, 20, 425+65, 60}; |
gstedile | 6:aebb3a0a040c | 155 | |
gstedile | 4:9901f6da64b7 | 156 | |
gstedile | 4:9901f6da64b7 | 157 | // ************************** |
gstedile | 0:d92271b032c7 | 158 | //RunTestSet(lcd, pc); // If the library was compiled for test mode... |
gstedile | 0:d92271b032c7 | 159 | |
gstedile | 0:d92271b032c7 | 160 | lcd.foreground(RGB(255,255,0)); // Seteo del color de las letras. |
gstedile | 0:d92271b032c7 | 161 | lcd.SelectUserFont(BPG_Arial20x20); // Seleccion de tipo y tamaño de letras |
gstedile | 0:d92271b032c7 | 162 | //lcd.puts("BPG_Arial63x63"); |
gstedile | 6:aebb3a0a040c | 163 | |
gstedile | 0:d92271b032c7 | 164 | GPS gps(p9, p10); // Agrego para comunicacion con el GPS |
gstedile | 0:d92271b032c7 | 165 | |
gstedile | 0:d92271b032c7 | 166 | //Inicializo variables para el sensor de flujo |
gstedile | 0:d92271b032c7 | 167 | //---------------------------------------------------- |
gstedile | 0:d92271b032c7 | 168 | DigitalOut myled(LED1); |
gstedile | 0:d92271b032c7 | 169 | DigitalOut myled2(LED2); |
gstedile | 0:d92271b032c7 | 170 | DigitalOut myled3(LED3); |
gstedile | 0:d92271b032c7 | 171 | DigitalOut myled4(LED4); |
gstedile | 0:d92271b032c7 | 172 | |
gstedile | 0:d92271b032c7 | 173 | |
gstedile | 0:d92271b032c7 | 174 | //DebounceIn pb(p8); |
gstedile | 0:d92271b032c7 | 175 | /*DigitalIn pb(p11); |
gstedile | 0:d92271b032c7 | 176 | int count=0; //Comento esto porque voy a usar interrupciones |
gstedile | 0:d92271b032c7 | 177 | int old_pb=0; |
gstedile | 0:d92271b032c7 | 178 | int new_pb; |
gstedile | 0:d92271b032c7 | 179 | // Use internal pullup for pushbutton |
gstedile | 0:d92271b032c7 | 180 | pb.mode(PullUp); |
gstedile | 0:d92271b032c7 | 181 | //pb.mode(PullNone); |
gstedile | 0:d92271b032c7 | 182 | // Delay for initial pullup to take effect |
gstedile | 0:d92271b032c7 | 183 | wait(.001);*/ |
gstedile | 0:d92271b032c7 | 184 | |
gstedile | 4:9901f6da64b7 | 185 | //---------------------------------------------------- |
gstedile | 4:9901f6da64b7 | 186 | // Sensor de flujo: |
gstedile | 0:d92271b032c7 | 187 | //----------------------------------------------------- |
gstedile | 0:d92271b032c7 | 188 | InterruptIn pulse_sensor(p11); // Defino pulse_sensor como una entrada de interrupción en p11. |
gstedile | 0:d92271b032c7 | 189 | pulse_sensor.mode(PullUp); // PullUp para esa entrada. |
gstedile | 0:d92271b032c7 | 190 | //DigitalOut led(LED1); |
gstedile | 0:d92271b032c7 | 191 | pulse_sensor.rise(&trigger); // Dispara interrupción con flanco ascendente. (Podría tambien ser desecendente--> fall) |
gstedile | 0:d92271b032c7 | 192 | |
gstedile | 4:9901f6da64b7 | 193 | |
gstedile | 4:9901f6da64b7 | 194 | |
gstedile | 4:9901f6da64b7 | 195 | |
gstedile | 4:9901f6da64b7 | 196 | while(1) { |
gstedile | 4:9901f6da64b7 | 197 | |
gstedile | 5:56d63eaa8415 | 198 | lcd.SetTextCursor(0,0); // Pongo cursor en posicion |
gstedile | 5:56d63eaa8415 | 199 | lcd.puts(">>>>>>>>>>>>>< Proyecto SNOCC ><<<<<<<<<<<<<<\r\n"); |
gstedile | 4:9901f6da64b7 | 200 | |
gstedile | 0:d92271b032c7 | 201 | |
gstedile | 0:d92271b032c7 | 202 | //----------------------------------------------------- |
gstedile | 0:d92271b032c7 | 203 | |
gstedile | 3:0c9ee19fb976 | 204 | //lcd.SetTextCursor(0,20); |
gstedile | 0:d92271b032c7 | 205 | //lcd.printf("M0: %s \r\n\r\n", gps.msg); //Imprimo el mensaje crudo proveniente de la uart |
gstedile | 0:d92271b032c7 | 206 | //lcd.printf("M1: %s \r\n", gps.mensaje1); |
gstedile | 0:d92271b032c7 | 207 | //lcd.printf("M2: %s \r\n", gps.mensaje2); |
gstedile | 0:d92271b032c7 | 208 | //lcd.printf("M3: %s \r\n", gps.mensaje3); |
gstedile | 0:d92271b032c7 | 209 | //lcd.printf("M4: %s \r\n", gps.mensaje4); |
gstedile | 0:d92271b032c7 | 210 | //lcd.printf("Posicion actual_0: %f, %f \r\n", gps.longitude, gps.latitude); |
gstedile | 0:d92271b032c7 | 211 | //lcd.printf("Contador = %d", Counter); |
gstedile | 0:d92271b032c7 | 212 | |
gstedile | 0:d92271b032c7 | 213 | if(gps.sample()) { // Si es exitosa la obtencion de datos del gps. |
gstedile | 3:0c9ee19fb976 | 214 | lcd.cls(); |
gstedile | 5:56d63eaa8415 | 215 | lcd.SetTextCursor(0,0); // Pongo cursor en posicion |
gstedile | 5:56d63eaa8415 | 216 | lcd.puts(">>>>>>>>>>>>>< Proyecto SNOCC ><<<<<<<<<<<<<<\r\n"); |
gstedile | 3:0c9ee19fb976 | 217 | |
gstedile | 4:9901f6da64b7 | 218 | if (NAVIGATION_TABLE.rotate_data(gps.longitude, gps.latitude, gps.time, Counter)){ |
gstedile | 4:9901f6da64b7 | 219 | NAVIGATION_VMATRIX.store_data(NAVIGATION_TABLE);// Luego de rotar los datos en la tabla de navegacion, la guarda en la matriz, |
gstedile | 4:9901f6da64b7 | 220 | // en el lugar correspondiente a la velocidad del preiodo (por ahora reemplaza...ver otras opciones) |
gstedile | 5:56d63eaa8415 | 221 | |
gstedile | 5:56d63eaa8415 | 222 | lcd.puts("Rotacion exitosa!-->"); |
gstedile | 5:56d63eaa8415 | 223 | int i=int(NAVIGATION_TABLE.LAST_NAV_DATA[speed_p]); |
gstedile | 4:9901f6da64b7 | 224 | float timetick_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[time_f]; // DEBUG |
gstedile | 4:9901f6da64b7 | 225 | float distance_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[distance_p]; // DEBUG |
gstedile | 4:9901f6da64b7 | 226 | float speed_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[speed_p]; // DEBUG |
gstedile | 4:9901f6da64b7 | 227 | float longitude_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[longitude_f]; // DEBUG |
gstedile | 4:9901f6da64b7 | 228 | float latitude_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[latitude_f]; // DEBUG |
gstedile | 4:9901f6da64b7 | 229 | float cons_hour_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[cons_hour_p]; |
gstedile | 5:56d63eaa8415 | 230 | //lcd.printf("Algunos datos guardados en la Matriz: \r\n"); // DEBUG |
gstedile | 5:56d63eaa8415 | 231 | lcd.printf("INDICE_Mtrx: %d\r\n",i); // DEBUG |
gstedile | 5:56d63eaa8415 | 232 | /*lcd.printf("Speed_f_Mtrx(%d): %f kn.\r\n",i, speed_p_Mtrx); // DEBUG |
gstedile | 5:56d63eaa8415 | 233 | lcd.printf("Time_f_Mtrx(%d): %f Hours.\r\n",i, timetick_f_Mtrx); // DEBUG |
gstedile | 5:56d63eaa8415 | 234 | lcd.printf("Distance_p_Mtrx(%d): %f miles.\r\n",i,distance_p_Mtrx); // DEBUG |
gstedile | 5:56d63eaa8415 | 235 | lcd.printf("Posicion: Long(%d): %f, Lat: %f\r\n",i,longitude_f_Mtrx,latitude_f_Mtrx); // DEBUG |
gstedile | 5:56d63eaa8415 | 236 | lcd.printf("FlujoVCOmtrx(%d): %f Litros/Hora\r\n",i, cons_hour_p_Mtrx); // DEBUG |
gstedile | 5:56d63eaa8415 | 237 | */ |
gstedile | 6:aebb3a0a040c | 238 | //build_test_Mtrx(NAVIGATION_VMATRIX); // DEBUG Curve |
gstedile | 5:56d63eaa8415 | 239 | print_VCO_curve(NAVIGATION_VMATRIX); |
gstedile | 4:9901f6da64b7 | 240 | } |
gstedile | 3:0c9ee19fb976 | 241 | else |
gstedile | 4:9901f6da64b7 | 242 | { |
gstedile | 3:0c9ee19fb976 | 243 | lcd.puts("Periodo no valido!\r\n"); |
gstedile | 4:9901f6da64b7 | 244 | int i=int(NAVIGATION_TABLE.LAST_NAV_DATA[speed_p]); |
gstedile | 4:9901f6da64b7 | 245 | float timetick_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[time_f]; // DEBUG |
gstedile | 4:9901f6da64b7 | 246 | float distance_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[distance_p]; // DEBUG |
gstedile | 4:9901f6da64b7 | 247 | float speed_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[speed_p]; // DEBUG |
gstedile | 4:9901f6da64b7 | 248 | float longitude_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[longitude_f]; // DEBUG |
gstedile | 4:9901f6da64b7 | 249 | float latitude_f_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[latitude_f]; // DEBUG |
gstedile | 4:9901f6da64b7 | 250 | float cons_hour_p_Mtrx = NAVIGATION_VMATRIX.NAV_DATA[i].LAST_NAV_DATA[cons_hour_p]; // DEBUG |
gstedile | 4:9901f6da64b7 | 251 | lcd.printf("Algunos datos guardados en la Matriz: \r\n"); // DEBUG |
gstedile | 5:56d63eaa8415 | 252 | lcd.printf("INDICE_Mtrx: %d (Parte entera de speed)\r\n",i); // DEBUG |
gstedile | 5:56d63eaa8415 | 253 | lcd.printf("Speed_f_Mtrx(%d): %f kn.\r\n",i, speed_p_Mtrx); // DEBUG |
gstedile | 5:56d63eaa8415 | 254 | lcd.printf("Time_f_Mtrx(%d): %f Hours.\r\n",i, timetick_f_Mtrx); // DEBUG |
gstedile | 5:56d63eaa8415 | 255 | lcd.printf("Distance_p_Mtrx(%d): %f miles.\r\n",i,distance_p_Mtrx); // DEBUG |
gstedile | 5:56d63eaa8415 | 256 | lcd.printf("Posicion: Long(%d): %f, Lat: %f\r\n",i,longitude_f_Mtrx,latitude_f_Mtrx); // DEBUG |
gstedile | 5:56d63eaa8415 | 257 | lcd.printf("FlujoVCOmtrx(%d): %f Litros/Hora\r\n",i, cons_hour_p_Mtrx); // DEBUG |
gstedile | 4:9901f6da64b7 | 258 | } |
gstedile | 4:9901f6da64b7 | 259 | /* lcd.SetTextCursor(0,80); |
gstedile | 3:0c9ee19fb976 | 260 | //lcd.printf("Posicion: %f, %f\r\n", gps.longitude, gps.latitude); |
gstedile | 4:9901f6da64b7 | 261 | lcd.printf("Posicion: %f, %f\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[longitude_f], NAVIGATION_TABLE.LAST_NAV_DATA[latitude_f]); // $ |
gstedile | 3:0c9ee19fb976 | 262 | //lcd.printf("Velocidad %f km/h", gps.speed); |
gstedile | 3:0c9ee19fb976 | 263 | lcd.printf("Distancia_p %f km\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[distance_p]); |
gstedile | 3:0c9ee19fb976 | 264 | lcd.printf("Velocidad %f km/h\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[speed_p]); |
gstedile | 3:0c9ee19fb976 | 265 | lcd.printf("Timetick_i %f h\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[time_i]); |
gstedile | 3:0c9ee19fb976 | 266 | lcd.printf("Timetick_f %f h\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[time_f]); |
gstedile | 3:0c9ee19fb976 | 267 | lcd.printf("Timetick_gps %f NMEA\r\n", gps.time); |
gstedile | 4:9901f6da64b7 | 268 | // lcd.printf("Consumo %f l/km", getConsumo(Count; gps.speed); */ |
gstedile | 5:56d63eaa8415 | 269 | //lcd.SetTextCursor(0,220); |
gstedile | 4:9901f6da64b7 | 270 | //lcd.printf("Flujo %f Litros/Hora\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[cons_hour_p]); |
gstedile | 4:9901f6da64b7 | 271 | //lcd.printf("FlujoVCOmtrx %f Litros/Hora\r\n", cons_hour_p_Mtrx); |
gstedile | 5:56d63eaa8415 | 272 | //lcd.printf("Flujo acumulado (contador):%f Litros\r\n", LCounter); |
gstedile | 0:d92271b032c7 | 273 | |
gstedile | 4:9901f6da64b7 | 274 | } |
gstedile | 4:9901f6da64b7 | 275 | else { |
gstedile | 0:d92271b032c7 | 276 | lcd.cls(); |
gstedile | 5:56d63eaa8415 | 277 | lcd.SetTextCursor(0,0); // Pongo cursor en posicion |
gstedile | 5:56d63eaa8415 | 278 | lcd.puts(">>>>>>>>>>>>>< Proyecto SNOCC ><<<<<<<<<<<<<<\r\n"); |
gstedile | 0:d92271b032c7 | 279 | lcd.SetTextCursor(0,100); |
gstedile | 6:aebb3a0a040c | 280 | lcd.printf("Aun no hay datos disponibles :(\r\n"); |
gstedile | 3:0c9ee19fb976 | 281 | lcd.SetTextCursor(0,180); |
gstedile | 6:aebb3a0a040c | 282 | lcd.printf("Timetick %f h\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[time_f]); |
gstedile | 6:aebb3a0a040c | 283 | lcd.printf("Flujo Mtrx: %f Litros/Hora\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[cons_hour_p]); |
gstedile | 6:aebb3a0a040c | 284 | lcd.printf("Flujo Counter: %f Litros\r\n", LCounter); |
gstedile | 0:d92271b032c7 | 285 | } |
gstedile | 6:aebb3a0a040c | 286 | |
gstedile | 6:aebb3a0a040c | 287 | |
gstedile | 6:aebb3a0a040c | 288 | for (int i=0;i<100;i++) { |
gstedile | 6:aebb3a0a040c | 289 | point_t p; |
gstedile | 6:aebb3a0a040c | 290 | lcd.fillrect(PrintScreenRect, Green); |
gstedile | 6:aebb3a0a040c | 291 | lcd.foreground(Blue); |
gstedile | 6:aebb3a0a040c | 292 | lcd.background(Green); |
gstedile | 6:aebb3a0a040c | 293 | lcd.puts(425-60, 22, "GET CURVE"); |
gstedile | 6:aebb3a0a040c | 294 | lcd.background(Black); |
gstedile | 6:aebb3a0a040c | 295 | //wait_us(5); |
gstedile | 6:aebb3a0a040c | 296 | if (lcd.TouchPanelReadable(&p)) { |
gstedile | 6:aebb3a0a040c | 297 | //lcd.foreground(Blue); |
gstedile | 6:aebb3a0a040c | 298 | //lcd.SetTextCursor(10, 15); |
gstedile | 6:aebb3a0a040c | 299 | //lcd.printf("(%3d,%3d)", p.x, p.y); |
gstedile | 6:aebb3a0a040c | 300 | //lcd.foreground(RGB(255,255,0)); |
gstedile | 6:aebb3a0a040c | 301 | |
gstedile | 6:aebb3a0a040c | 302 | if (Intersect(PrintScreenRect, p)) { |
gstedile | 6:aebb3a0a040c | 303 | lcd.foreground(Red); |
gstedile | 6:aebb3a0a040c | 304 | lcd.puts(400-38, 20, "GET CURVE"); |
gstedile | 6:aebb3a0a040c | 305 | build_test_Mtrx(NAVIGATION_VMATRIX); // DEBUG Curve |
gstedile | 6:aebb3a0a040c | 306 | print_VCO_curve(NAVIGATION_VMATRIX); |
gstedile | 6:aebb3a0a040c | 307 | //lcd.foreground(RGB(255,255,0)); |
gstedile | 6:aebb3a0a040c | 308 | wait(10); |
gstedile | 6:aebb3a0a040c | 309 | break; |
gstedile | 6:aebb3a0a040c | 310 | //GetScreenCapture(); |
gstedile | 6:aebb3a0a040c | 311 | } |
gstedile | 6:aebb3a0a040c | 312 | |
gstedile | 6:aebb3a0a040c | 313 | /*for (int i=0; i<3; i++) { |
gstedile | 6:aebb3a0a040c | 314 | if (Intersect(RGBList[i], p)) { |
gstedile | 6:aebb3a0a040c | 315 | uint8_t mag = (255 * (p.x - RGBList[i].p1.x)) / (RGBList[i].p2.x - RGBList[i].p1.x); |
gstedile | 6:aebb3a0a040c | 316 | rgbVal[i] = mag; |
gstedile | 6:aebb3a0a040c | 317 | lcd.SetTextCursor(380, 15); |
gstedile | 6:aebb3a0a040c | 318 | lcd.foreground(Blue); |
gstedile | 6:aebb3a0a040c | 319 | //lcd.printf("(%02X,%02X,%02X)", rgbVal[0], rgbVal[1], rgbVal[2]); |
gstedile | 6:aebb3a0a040c | 320 | //rgb = RGB(rgbVal[0], rgbVal[1], rgbVal[2]); |
gstedile | 6:aebb3a0a040c | 321 | //lcd.fillrect(RGBList[3], rgb); |
gstedile | 6:aebb3a0a040c | 322 | break; |
gstedile | 6:aebb3a0a040c | 323 | }*/ |
gstedile | 6:aebb3a0a040c | 324 | } |
gstedile | 6:aebb3a0a040c | 325 | lcd.foreground(RGB(255,255,0)); |
gstedile | 6:aebb3a0a040c | 326 | } |
gstedile | 6:aebb3a0a040c | 327 | } |
gstedile | 4:9901f6da64b7 | 328 | } |
gstedile | 6:aebb3a0a040c | 329 | |
gstedile | 6:aebb3a0a040c | 330 |