test fork
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Diff: displayModes.cpp
- Revision:
- 131:0d926c080a65
- Parent:
- 130:1a9d2a6d99ce
- Child:
- 132:08748a67280a
diff -r 1a9d2a6d99ce -r 0d926c080a65 displayModes.cpp --- a/displayModes.cpp Mon Jul 22 00:02:51 2013 +0000 +++ b/displayModes.cpp Wed Jul 24 11:20:08 2013 +0000 @@ -6,10 +6,10 @@ void mainDisplay (bool force, bool showButtons){ unsigned short gids, SOC_x10, packV_x2, tireP; - static unsigned short lgids=0, lSOC=0, lSOH=0, lpackV_x2=0, ltireP=0, maxPS=0; + static unsigned short lgids=0, lSOC=0, lpackV_x2=0, ltireP=0, maxPS=0; static float lmaxTemp=0; static float lkW=0, laccV=0, lmpkWh=0; - static unsigned long lAh=0; + CANMessage msg; msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids @@ -38,51 +38,30 @@ printf("%4.1f kWh \n",(float)(gids-5)*0.075); tt.set_font((unsigned char*) SCProSB31x55); tt.foreground(Green); - tt.locate(60,96); + tt.locate(60,80); printf("%4.1f %s \n",convertDistance(mpkWh[dtePeriod]*((float)(gids-5)*.075)),distanceUnit()); //LM - add metric conversion lgids=gids; lmpkWh=mpkWh[dtePeriod]; tt.foreground(Yellow); tt.set_font((unsigned char*) Arial28x28); } - if(force||tireP!=ltireP){ - tt.foreground(LightGrey); - if(msg.data[6]&0x80){ - tt.locate(40,150); - printf("%3.1f\n",(float)msg.data[2]/4); - } - if(msg.data[6]&0x40){ - tt.locate(114,150); - printf("%3.1f\n",(float)msg.data[3]/4); - } - if(msg.data[6]&0x20){ - tt.locate(40,178); - printf("%3.1f\n",(float)msg.data[4]/4); - } - if(msg.data[6]&0x10){ - tt.locate(114,178); - printf("%3.1f\n",(float)msg.data[5]/4); - } - tt.foreground(Yellow); - ltireP=tireP; - } if(force||SOC_x10!=lSOC){ tt.locate(200,10); printf("%4.1f%s\n",(float)SOC_x10/10,"% "); lSOC=SOC_x10; } if(force||packV_x2!=lpackV_x2){ - tt.locate(200,206); + tt.locate(200,176); printf("%4.1fV \n",(float)packV_x2/2); lpackV_x2=packV_x2; } if(force||maxTemp!=lmaxTemp){ - tt.locate(200,176); + tt.locate(200,146); printf("%4.1f%s\n",convertTemperature(maxTemp),temperatureUnit()); lmaxTemp=maxTemp; } if(force||accV!=laccV){ - tt.locate(20,206); + tt.locate(20,176); printf("%3.1fV \n",accV); laccV=accV; } @@ -102,16 +81,26 @@ } lkW=kW[0]; } - tt.foreground(LightGrey); - if(force||Ah_x10000!=lAh){ - tt.locate(10,70); - printf("% 4.2fAh \n",(float)Ah_x10000/10000); - lAh=Ah_x10000; - } - if(force||SOH_x100!=lSOH){ - tt.locate(206,70); - printf("%4.1f%s\n",(float)SOH_x100/100,"% "); - lSOH=SOH_x100; + if(force||tireP!=ltireP){ + tt.foreground(LightGrey); + if(msg.data[6]&0x80){ + tt.locate(10,206); + printf("%3.1f\n",(float)msg.data[2]/4); + } + if(msg.data[6]&0x40){ + tt.locate(90,206); + printf("%3.1f\n",(float)msg.data[3]/4); + } + if(msg.data[6]&0x20){ + tt.locate(170,206); + printf("%3.1f\n",(float)msg.data[4]/4); + } + if(msg.data[6]&0x10){ + tt.locate(250,206); + printf("%3.1f\n",(float)msg.data[5]/4); + } + tt.foreground(Yellow); + ltireP=tireP; } }else {//if(skin==ggSkin){ if(force||gids!=lgids){ @@ -254,7 +243,7 @@ } void healthDisplay (bool force, bool showButtons){ - unsigned short gids, SOC_x10; + unsigned short gids, SOC_x10, SOH_x2; static unsigned short lgids=0, lSOC=0, lSOH=0; static float lmaxTemp=0, lresr=0, lunlV=0; static unsigned long lAh=0; @@ -264,6 +253,8 @@ gids = (msg.data[0]<<2)+(msg.data[1]>>6); msg = lastMsg[indexLastMsg[0x55b]]; //Get SOC SOC_x10 = (msg.data[0]<<2)+(msg.data[1]>>6); + msg = lastMsg[indexLastMsg[0x5b3]]; //Get SOH + SOH_x2 = msg.data[1]; tt.background(Blue); tt.foreground(Yellow); @@ -301,7 +292,7 @@ } if(force||SOH_x100!=lSOH){ tt.locate(10,70); - printf(" %4.1f%s \n",(float)SOH_x100/100,"% SOH"); + printf(" %4.1f,%4.1f %s \n",(float)SOH_x2/2,(float)SOH_x100/100,"% SOH"); lSOH=SOH_x100; } if(force||Ah_x10000!=lAh){ @@ -572,7 +563,7 @@ showButton(3,1," GoTo"," Config",4,4); // bottom (not Nav) row showButton(0,2," GoTo","Playback",4,4); - showButton(1,2," GoTo","Set Time",4,4); + //showButton(1,2," GoTo","Set Time",4,4); showButton(2,2," GoTo"," Log",4,4); showButton(3,2," GoTo"," Trip",4,4); @@ -844,7 +835,7 @@ //-------- top row -------- showButton(0,0,"Calibrate"," Touch",4,4); // gg - 4x4 showButton(1,0," Reset","",4,4); - showButton(2,0," Save"," Config",4,4); + showButton(2,0," Save"," Config",4,4); // a button to step to the next skin unsigned int nextSkin = skin + 1 ; @@ -854,7 +845,7 @@ else if( nextSkin == ggSkin ) sprintf(sTemp1,"Skin GG"); else sprintf(sTemp1,"Skin %d",nextSkin); - showButton(3,0," Use",sTemp1,4,4); + showButton(3,0," Use",sTemp1,4,4); //------- second row ----- if (logEn&&usbEn) { @@ -881,9 +872,9 @@ // add Enable/Disable Debug - debugMode if (debugMode) { - sprintf(sTemp1,"Disable"); + sprintf(sTemp1," Disable"); } else { - sprintf(sTemp1,"Enable"); + sprintf(sTemp1," Enable"); } showButton(3,1,sTemp1," Debug",4,4); @@ -892,6 +883,13 @@ else showButton(0,2,"Metric","",4,4); + showButton(1,2," Set"," Time",4,4); + if (showHealth) { + sprintf(sTemp1," Hide"); + } else { + sprintf(sTemp1," Show"); + } + showButton(2,2,sTemp1," Health",4,4); showButton(3,2,"Update","Firmware",4,4); } @@ -959,9 +957,6 @@ case 5: sprintf(sTemp1,"Second"); break; - case 6: - sprintf(sTemp1,"Select"); - break; default: break; } @@ -1027,8 +1022,8 @@ tt.set_font((unsigned char*) Arial24x23); //for(i=0;i<10;i++){ //y=200-i*20; - for(i=3;i<8;i++){ - y=200-(i-3)*40; + for(i=2;i<7;i++){ + y=200-(i-2)*40; tt.locate(0,y-8); if (showMiles){ printf("%3.0f\n",convertDistance(i*((float)(gids-5)*.075))); // LM - Added metric support @@ -1041,8 +1036,8 @@ lgids=gids; } if(tock||force){ - for(i=3;i<8;i++){ - y=200-(i-3)*40; + for(i=2;i<7;i++){ + y=200-(i-2)*40; tt.line(40,y,158,y,DarkGrey); } @@ -1091,11 +1086,11 @@ radius=2; color=Green; } - if(ly<100){ + if(ly<60){ ly=220; color=Red; - }else if(ly<320) { - ly=320-ly; + }else if(ly<280) { + ly=280-ly; }else{ ly=0; } @@ -1112,11 +1107,11 @@ radius=2; color=Green; } - if(y<100){ + if(y<60){ y=220; color=Red; - }else if(y<320) { - y=320-y; + }else if(y<280) { + y=280-y; }else{ y=0; }