Para Juan
Dependencies: NAVDATA RA8875 mbed VCODATA
Diff: main.cpp
- Revision:
- 6:aebb3a0a040c
- Parent:
- 5:56d63eaa8415
- Child:
- 7:93da358c67a1
diff -r 56d63eaa8415 -r aebb3a0a040c main.cpp --- a/main.cpp Sat Apr 08 22:36:56 2017 +0000 +++ b/main.cpp Mon Apr 10 05:12:51 2017 +0000 @@ -31,6 +31,49 @@ RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name +//>>>>>>>>>>>>>>>>>> SECCION AGREGADA PROVISORIAMENTE PARA EL TOUCH PANEL <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +extern "C" void mbed_reset(); + + +#define min(a,b) ((a<b)?a:b) +#define max(a,b) ((a>b)?a:b) + +bool Intersect(rect_t rect, point_t p) +{ + if (p.x >= min(rect.p1.x, rect.p2.x) && p.x <= max(rect.p1.x, rect.p2.x) + && p.y >= min(rect.p1.y, rect.p2.y) && p.y <= max(rect.p1.y, rect.p2.y)) + return true; + else + return false; +} + +int GetScreenCapture(void) +{ + char fqfn[50]; + int i = 0; + + pc.printf("Screen Capture... "); + for (i=1; i< 100; i++) { + snprintf(fqfn, sizeof(fqfn), "/local/Screen%02d.bmp", i); + FILE * fh = fopen(fqfn, "rb"); + if (!fh) { + lcd.PrintScreen(0,0,480,272,fqfn); + pc.printf(" as /local/Screen%02d.bmp\r\n", i); + return i; + } else { + fclose(fh); // close this and try the next + } + } + return 0; +} +//>>>>>>>>>>>>>>>>>> FIN SECCION AGREGADA PROVISORIAMENTE PARA EL TOUCH PANEL <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + + + + + void trigger() { //Función para la interrupción Counter++; LCounter=Counter/2500; @@ -43,6 +86,17 @@ void print_VCO_curve(VCODATA Matrix_VCO){ int s,y,z; + + lcd.background(RGB(255,255,255)); + lcd.foreground(Blue); + lcd.SetTextCursor(0,0); // Pongo cursor en posicion + lcd.cls(); + lcd.puts(">>>>>>>>>>>>>< Proyecto SNOCC ><<<<<<<<<<<<<<\r\n"); + lcd.SetTextCursor(0,30); + lcd.puts("Consumo (L/M)\r\n"); + lcd.SetTextCursor(200,220); + lcd.puts("Velocidad(Kn)\r\n"); + lcd.foreground(Red); for (int x=0;x<100;x++){ s = Matrix_VCO.NAV_DATA[x].LAST_NAV_DATA[cons_mile_p]; y=200-2*s; // el consumo máximo es alrededor de 100 l/m. Multiplico por 2 para que ocupe mas pantalla. @@ -51,15 +105,17 @@ //lcd.printf("%d",x); lcd.printf("."); } + lcd.foreground(RGB(255,255,0)); + lcd.background(Black); } -/* Funcion build_test_Mtrx: Carga los datos del vector LAST_NAV_DATA de los objetos NAVDATA de VCODATA para testing.*/ +/* Funcion build_test_Mtrx: Carga los datos (consumo/milla) del vector LAST_NAV_DATA de los objetos NAVDATA de VCODATA para testing.*/ void build_test_Mtrx(VCODATA Test_Matrix_VCO){ NAVDATA TestNDO; for (int i=0;i<50;i++){ - TestNDO.LAST_NAV_DATA[cons_mile_p]=i; + TestNDO.LAST_NAV_DATA[cons_mile_p]=i+1; TestNDO.LAST_NAV_DATA[speed_p]=i; Test_Matrix_VCO.store_data(TestNDO); } @@ -77,6 +133,12 @@ pc.printf("\r\nRA8875 Soft Fonts - Build " __DATE__ " " __TIME__ "\r\n"); lcd.init(); + + lcd.TouchPanelCalibrate("Calibrate the touch panel"); // 4 touch + lcd.cls(); + + rect_t PrintScreenRect = { 425-65, 20, 425+65, 60}; + // ************************** //RunTestSet(lcd, pc); // If the library was compiled for test mode... @@ -84,8 +146,7 @@ lcd.foreground(RGB(255,255,0)); // Seteo del color de las letras. lcd.SelectUserFont(BPG_Arial20x20); // Seleccion de tipo y tamaño de letras //lcd.puts("BPG_Arial63x63"); - - + GPS gps(p9, p10); // Agrego para comunicacion con el GPS //Inicializo variables para el sensor de flujo @@ -160,7 +221,7 @@ lcd.printf("Posicion: Long(%d): %f, Lat: %f\r\n",i,longitude_f_Mtrx,latitude_f_Mtrx); // DEBUG lcd.printf("FlujoVCOmtrx(%d): %f Litros/Hora\r\n",i, cons_hour_p_Mtrx); // DEBUG */ - build_test_Mtrx(NAVIGATION_VMATRIX); // DEBUG Curve + //build_test_Mtrx(NAVIGATION_VMATRIX); // DEBUG Curve print_VCO_curve(NAVIGATION_VMATRIX); } else @@ -202,11 +263,54 @@ lcd.SetTextCursor(0,0); // Pongo cursor en posicion lcd.puts(">>>>>>>>>>>>>< Proyecto SNOCC ><<<<<<<<<<<<<<\r\n"); lcd.SetTextCursor(0,100); - lcd.printf("No hay datos disponibles :(\r\n"); + lcd.printf("Aun no hay datos disponibles :(\r\n"); lcd.SetTextCursor(0,180); - lcd.printf("Timestick %f km/h\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[time_f]); - lcd.printf("Flujo %f Litros/Hora\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[cons_hour_p]); - lcd.printf("Flujo %f Litros\r\n", LCounter); + lcd.printf("Timetick %f h\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[time_f]); + lcd.printf("Flujo Mtrx: %f Litros/Hora\r\n", NAVIGATION_TABLE.LAST_NAV_DATA[cons_hour_p]); + lcd.printf("Flujo Counter: %f Litros\r\n", LCounter); } + + + for (int i=0;i<100;i++) { + point_t p; + lcd.fillrect(PrintScreenRect, Green); + lcd.foreground(Blue); + lcd.background(Green); + lcd.puts(425-60, 22, "GET CURVE"); + lcd.background(Black); + //wait_us(5); + if (lcd.TouchPanelReadable(&p)) { + //lcd.foreground(Blue); + //lcd.SetTextCursor(10, 15); + //lcd.printf("(%3d,%3d)", p.x, p.y); + //lcd.foreground(RGB(255,255,0)); + + if (Intersect(PrintScreenRect, p)) { + lcd.foreground(Red); + lcd.puts(400-38, 20, "GET CURVE"); + build_test_Mtrx(NAVIGATION_VMATRIX); // DEBUG Curve + print_VCO_curve(NAVIGATION_VMATRIX); + //lcd.foreground(RGB(255,255,0)); + wait(10); + break; + //GetScreenCapture(); + } + + /*for (int i=0; i<3; i++) { + if (Intersect(RGBList[i], p)) { + uint8_t mag = (255 * (p.x - RGBList[i].p1.x)) / (RGBList[i].p2.x - RGBList[i].p1.x); + rgbVal[i] = mag; + lcd.SetTextCursor(380, 15); + lcd.foreground(Blue); + //lcd.printf("(%02X,%02X,%02X)", rgbVal[0], rgbVal[1], rgbVal[2]); + //rgb = RGB(rgbVal[0], rgbVal[1], rgbVal[2]); + //lcd.fillrect(RGBList[3], rgb); + break; + }*/ + } + lcd.foreground(RGB(255,255,0)); + } + } } -} \ No newline at end of file + +