Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary by
Diff: displayModes.cpp
- Revision:
- 138:a2f5af85ed0d
- Parent:
- 137:70853cf5a30f
- Child:
- 139:ac227b203ef2
--- a/displayModes.cpp Sun Jul 28 05:32:17 2013 +0000 +++ b/displayModes.cpp Fri Aug 02 05:13:26 2013 +0000 @@ -7,9 +7,10 @@ void mainDisplay (bool force, bool showButtons){ unsigned short gids, SOC_x10, packV_x2, tireP; float useable_kWh,dte; + //unsigned char aTemp,c1Temp,c2Temp; 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 char laTemp=0,lc1Temp=0,lc2Temp=0; + static float lmaxTemp=0, lkW=0, laccV=0, lmpkWh=0; CANMessage msg; @@ -19,6 +20,10 @@ SOC_x10 = (msg.data[0]<<2)+(msg.data[1]>>6); msg = lastMsg[indexLastMsg[0x1db]]; //Get pack volts packV_x2 = (msg.data[2]<<2)+(msg.data[3]>>6); + //msg = lastMsg[indexLastMsg[0x79a]]; //Get ambient and cabin temperature + //aTemp = msg.data[5]-41; // Need to add convertsion to C if metric + //c1Temp = msg.data[4]-41; + //c2Temp = msg.data[6]-41; msg = lastMsg[indexLastMsg[0x385]]; //Get tire pressure tireP = msg.data[2]+msg.data[3]+msg.data[4]+msg.data[5]; @@ -46,7 +51,7 @@ // Display DTE dte=convertDistance(minTripEff*useable_kWh); tt.foreground(Green); - tt.locate(30,80); + tt.locate(20,80); if(dte>=10){ printf("%2.0f \n",dte); //LM - add metric conversion }else{ @@ -61,25 +66,29 @@ } // " "=0x10, "."=0x15, #=0x1D if(dte>=100){ - tt.locate(75,85); - printf(" %2.0f\n",dte); //LM - add metric conversion + tt.locate(80,85); + printf(" %3.0f\n",dte); //LM - add metric conversion }else if(dte>=10){ - tt.locate(89,85); + tt.locate(94,85); printf(" %2.0f\n",dte); //LM - add metric conversion }else{ - tt.locate(84,85); + tt.locate(89,85); printf(" %2.1f\n",dte); //LM - add metric conversion } tt.set_font((unsigned char*) Arial28x28); - tt.locate(190,106); + tt.locate(195,106); printf("%s\n",distanceUnit()); //LM - add metric conversion dte=convertDistance(maxTripEff*useable_kWh); tt.foreground(Orange); - tt.locate(260,80); - if(dte>=10){ + if(dte>=100){ + tt.locate(255,80); + printf("%3.0f \n",dte); //LM - add metric conversion + }else if(dte>=10){ + tt.locate(270,80); printf("%2.0f \n",dte); //LM - add metric conversion }else{ + tt.locate(265,80); printf("%2.1f \n",dte); //LM - add metric conversion } lgids=gids; @@ -115,13 +124,20 @@ lpackV_x2=packV_x2; ltireP=0;//Force tire pressure redraw, too } + /*if(force||aTemp!=laTemp){ + tt.foreground(Cyan); + tt.locate(10,146); + printf("%d %d %d\n",aTemp,c1Temp,c2Temp); + laTemp=aTemp; + lc1Temp=c1Temp; + lc2Temp=c2Temp; + }*/ if(force||maxTemp!=lmaxTemp){ tt.foreground(Cyan); + tt.locate(210,146); if (convertTemperature(maxTemp)<100){ - tt.locate(210,146); printf(" %3.1f%s\n",convertTemperature(maxTemp),temperatureUnit()); }else{ - tt.locate(210,146); printf("%4.1f%s\n",convertTemperature(maxTemp),temperatureUnit()); } lmaxTemp=maxTemp; @@ -723,20 +739,20 @@ nBar[i] *= nBarScale ; // scale, as needed } + // label the X axis (approximate) + //tt.locate( 2, yWinMin-14 ); printf("%04d = %04d from %1.4f", max, int( height / nBarScale ) + min, nBarScale ); + tt.locate( 2, yWinMin-14 ); printf("%04d = (%d) mv range.\n", max , max - min ); + tt.locate( 2, yWinMax+5); printf("%04d\n", min ); // values, for now // BatDataBaseG4 * 7 = 280 tt.locate( 0, yWinMax+40 ); 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", + 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", 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 ); - //tt.locate( 2, yWinMin-14 ); printf("%04d = %04d from %1.4f", max, int( height / nBarScale ) + min, nBarScale ); - tt.locate( 2, yWinMin-14 ); printf("%04d = (%d) mv range.", max , max - min ); //--------------- // show the bars