Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary by
Diff: displayModes.cpp
- Branch:
- Metric
- Revision:
- 108:29b5a760adc2
- Parent:
- 107:e9be732c1ad4
- Child:
- 111:d1559bb25c43
--- a/displayModes.cpp Sat Jun 29 02:44:02 2013 +0000 +++ b/displayModes.cpp Sun Jun 30 14:45:01 2013 +0000 @@ -80,22 +80,24 @@ if(force||lmiles!=miles_trip[0]){ //only update if changed tt.foreground(Navy); tt.set_font((unsigned char*) Arial28x28); - tt.locate(1,10); + tt.locate(6,210); printf("kWh : %s : Eff\n",distanceUnit()); for(int i=0; i<3; i++){ - tt.locate(1,60+i*40); - printf("%3.2f : %3.1f : %2.1f\n",kWh_trip[i],convertDistance(miles_trip[i]),convertDistance(miles_trip[i])/kWh_trip[i]); + tt.locate(6,20+i*60); + printf("%3.2f : %3.1f : %2.1f \n",kWh_trip[i],convertDistance(miles_trip[i]),convertDistance(miles_trip[i])/kWh_trip[i]); } tt.set_font((unsigned char*) Arial12x12); - showButton(3,1," Reset","",4,4); - showButton(3,2," Reset","",4,4); + tt.background(DarkCyan); + tt.foreground(Yellow); + showButton(3,1," Reset"," A",4,4); + showButton(3,2," Reset"," B",4,4); } } void mainDisplay (bool force, bool showButtons){ unsigned short gids, SOC, packV; static unsigned short lgids=0, lSOC=0, lSOH=0, lpackV=0, maxPS=0; - static signed short lbattTemp_x10=0; + static float lmaxTemp=0; static float lkW=0, laccV=0, lmpkWh=0; static unsigned long lAh=0; CANMessage msg; @@ -141,13 +143,10 @@ printf("%4.1fV \n",(float)packV/2); lpackV=packV; } - //if(force||battTemp_x4!=lbattTemp_x4){ - if(force||battTemp_x10!=lbattTemp_x10){ + if(force||maxTemp!=lmaxTemp){ tt.locate(200,170); - //printf("%4.1f%s\n",convertTemperature((float)battTemp_x4*0.25f),temperatureUnit()); - printf("%4.1f%s\n",convertTemperature((float)battTemp_x10*0.1f),temperatureUnit()); - //lbattTemp_x4=battTemp_x4; - lbattTemp_x10=battTemp_x10; + printf("%4.1f%s\n",convertTemperature(maxTemp),temperatureUnit()); + lmaxTemp=maxTemp; } if(force||accV!=laccV){ tt.locate(20,200); @@ -212,7 +211,7 @@ lkW=kW[0]; } } - if(logEn){ + if(led4){ tt.fillcircle(310,10,6,Red); }else{ tt.fillcircle(310,10,6,Navy); @@ -313,6 +312,10 @@ msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5); targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5); + msg = lastMsg[indexLastMsg[0x176]]; //Get Drive Mode + if (msg.data[3]==0xAA) { // In Park or Neutral + regenBraking = 0; // No regen when in Neutral + } if (targetBraking<2045){ if ((targetBraking>50)&&(regenBraking>50)){ @@ -394,8 +397,6 @@ printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %2.0f%s %2.0f%s %2.0f%s %2.0f%s\n\n", max,min,avg,jv, convertTemperature(battData[BatDataBaseG4*7+5]),sTemperatureUnit,convertTemperature(battData[BatDataBaseG4*7+8]),sTemperatureUnit, convertTemperature(battData[BatDataBaseG4*7+11]),sTemperatureUnit,convertTemperature(battData[BatDataBaseG4*7+14]),sTemperatureUnit); - //printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n", - // max,min,avg,jv, battData[BatDataBaseG4*7+5],battData[BatDataBaseG4*7+8],battData[BatDataBaseG4*7+11],battData[BatDataBaseG4*7+14]); tt.rect(8+0*41,16,40+0*41,28,Green); tt.rect(8+1*41,16,40+1*41,28,Yellow); //tt.rect(8+2*41,16,40+2*41,28,White); @@ -465,6 +466,7 @@ showButton(0,2," GoTo","Playback",4,4); showButton(1,2," GoTo","Set Time",4,4); showButton(2,2," GoTo"," Log",4,4); + showButton(3,2," GoTo"," Trip",4,4); showCP=false; } @@ -551,8 +553,12 @@ // values, for now // BatDataBaseG4 * 7 = 280 tt.locate( 0, yWinMax+40 ); - printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n", - max,min,avg,jv, battData[BatDataBaseG4*7+5],battData[BatDataBaseG4*7+8], battData[BatDataBaseG4*7+11],battData[BatDataBaseG4*7+14]); + char* sTemperatureUnit = temperatureUnit(); + printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %2.0f%s %2.0f%s %2.0f%s %2.0f%s\n\n", + max,min,avg,jv, convertTemperature(battData[BatDataBaseG4*7+5]),sTemperatureUnit,convertTemperature(battData[BatDataBaseG4*7+8]),sTemperatureUnit, + convertTemperature(battData[BatDataBaseG4*7+11]),sTemperatureUnit,convertTemperature(battData[BatDataBaseG4*7+14]),sTemperatureUnit); + //printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n", + // max,min,avg,jv, battData[BatDataBaseG4*7+5],battData[BatDataBaseG4*7+8], battData[BatDataBaseG4*7+11],battData[BatDataBaseG4*7+14]); // label the X axis (approximate) tt.locate( 2, yWinMax+5); printf("%04d", min ); @@ -674,8 +680,12 @@ // the values, for now // BatDataBaseG4 * 7 = 280 tt.locate( 0, yWinMax+40 ); - printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n", - max,min,avg,jv, battData[BatDataBaseG2*7+BatDataBaseG4*7+5],battData[BatDataBaseG2*7+BatDataBaseG4*7+8], battData[BatDataBaseG2*7+BatDataBaseG4*7+11],battData[BatDataBaseG2*7+BatDataBaseG4*7+14]); + char* sTemperatureUnit = temperatureUnit(); + printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %2.0f%s %2.0f%s %2.0f%s %2.0f%s\n\n", + max,min,avg,jv, convertTemperature(battData[BatDataBaseG4*7+5]),sTemperatureUnit,convertTemperature(battData[BatDataBaseG4*7+8]),sTemperatureUnit, + convertTemperature(battData[BatDataBaseG4*7+11]),sTemperatureUnit,convertTemperature(battData[BatDataBaseG4*7+14]),sTemperatureUnit); + //printf(" MAX MIN AVG CVLI T1 T2 T3 T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n", + // max,min,avg,jv, battData[BatDataBaseG2*7+BatDataBaseG4*7+5],battData[BatDataBaseG2*7+BatDataBaseG4*7+8], battData[BatDataBaseG2*7+BatDataBaseG4*7+11],battData[BatDataBaseG2*7+BatDataBaseG4*7+14]); //--------------- // show the bars @@ -736,7 +746,7 @@ showButton(3,0," Use",sTemp1,4,4); //------- second row ----- - if (logEn) { + if (logEn&&usbEn) { sprintf(sTemp1,"Disable"); } else { sprintf(sTemp1,"Enable"); @@ -1016,6 +1026,10 @@ msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5); targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5); + msg = lastMsg[indexLastMsg[0x176]]; //Get Drive Mode + if (msg.data[3]==0xAA) { // In Park or Neutral + regenBraking = 0; // No regen when in Neutral + } if (targetBraking<2045){ if ((targetBraking>50)&&(regenBraking>50)){ @@ -1298,6 +1312,10 @@ msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5); targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5); + msg = lastMsg[indexLastMsg[0x176]]; //Get Drive Mode + if (msg.data[3]==0xAA) { // In Park or Neutral + regenBraking = 0; // No regen when in Neutral + } msg = lastMsg[indexLastMsg[0x176]]; //Get rpms - not sure what this is but scales to mph with .0725 rpm = ((short)msg.data[0]<<8)+msg.data[1]; speed =rpm>0?rpm>>3:-rpm>>3; //Take absolute to get speed; div8