test fork
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Diff: displayModes.cpp
- Revision:
- 150:ef46ce63345c
- Parent:
- 149:e9739523109f
- Child:
- 151:3047ebb3c9a8
--- a/displayModes.cpp Wed Sep 25 03:33:18 2013 +0000 +++ b/displayModes.cpp Fri Sep 27 04:43:41 2013 +0000 @@ -7,7 +7,7 @@ void mainDisplay (bool force, bool showButtons){ unsigned short gids, SOC_x10, packV_x2, tireP; float useable_kWh,dte; - //unsigned char aTemp; + unsigned char aTemp; static unsigned short lgids=0, lSOC=0, lpackV_x2=0, ltireP=0; static unsigned char laTemp=0; static float lmaxTemp=0, lkW=0, laccV=0, lmpkWh=0; @@ -20,7 +20,12 @@ 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[0x54c]]; //Get ambient + aTemp = msg.data[6]-56; + //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]; @@ -41,7 +46,7 @@ printf("%4.1f kWh \n",useable_kWh); // Display DTE - dte=convertDistance(minTripEff*nomDrag/airDrag(ambient_F)*useable_kWh); + dte=convertDistance(minTripEff*useable_kWh); tt.foreground(Green); tt.locate(20,80); if(dte>=9.5){ @@ -52,8 +57,7 @@ tt.set_font((unsigned char*) SCProSB31x55); tt.foreground(Yellow); - //Totest:convert from 25C to current ambient temperature - dte=convertDistance(mpkWh[dtePeriod]); + dte=convertDistance(mpkWh[dtePeriod]*useable_kWh); if(dte>199){ dte=199; } @@ -72,7 +76,7 @@ tt.locate(195,106); printf("%s\n",distanceUnit()); //LM - add metric conversion - dte=convertDistance(maxTripEff*nomDrag/airDrag(ambient_F)*useable_kWh); + dte=convertDistance(maxTripEff*useable_kWh); tt.foreground(Orange); if(dte>=99.5){ tt.locate(255,80); @@ -117,11 +121,11 @@ lpackV_x2=packV_x2; ltireP=0;//Force tire pressure redraw, too } - if(force||ambient_F!=laTemp){ + if(force||aTemp!=laTemp){ tt.foreground(Cyan); tt.locate(20,146); - printf("%2.0f%s\n",convertF(ambient_F),temperatureUnit()); - laTemp=ambient_F; + printf("%2.0f%s\n",convertF(aTemp),temperatureUnit()); + laTemp=aTemp; } if(force||maxTemp!=lmaxTemp){ tt.foreground(Cyan); @@ -1135,7 +1139,6 @@ tt.set_font((unsigned char*) SCProSB31x55); tt.foreground(Green); if (showMiles){ - //Totest:convert from 25C to current ambient temperature float miles = mpkWh[dtePeriod]*((float)(gids-5)*.075); miles = convertDistance(miles); // LM - Metric support // Right justify @@ -1152,11 +1155,9 @@ tt.foreground(Cyan); tt.set_font((unsigned char*) Arial24x23); tt.locate(198,70); - //Totest:convert from 25C to current ambient temperature printf("%3.1f \n",mpkWh[dtePeriod]); } else { tt.locate(200,10); - //Totest:convert from 25C to current ambient temperature printf("%3.1f \n",mpkWh[dtePeriod]); tt.foreground(Cyan); tt.set_font((unsigned char*) Arial24x23); @@ -1254,7 +1255,7 @@ } } -void debugDisplay (bool force, bool showButtons){ +void testDisplay (bool force, bool showButtons){ static unsigned short maxPS=0; unsigned char i, uData[8]; CANMessage msg; @@ -1271,8 +1272,7 @@ } if(pointerSep>maxPS){maxPS=pointerSep;} tt.locate(10,10); - //printf("%3d sep %3d max\n",pointerSep,maxPS); - printf("%f %4.3f \n", ambient_F, airDrag(ambient_F)); + printf("%3d sep %3d max\n",pointerSep,maxPS); tt.locate(10,40); printf("%4.2fV %4.2fV \n",accV,accV2); for (i=0; i<4; i++){ @@ -1335,8 +1335,8 @@ case healthScreen: healthDisplay(changed,showButtons); break; - case debugScreen: - debugDisplay(changed,showButtons); + case testScreen: + testDisplay(changed,showButtons); break; default: if (changed){ @@ -1409,6 +1409,9 @@ case healthScreen: sprintf(sTemp2,"Health"); break; + case testScreen: + sprintf(sTemp2," Test"); + break; case indexScreen: // gg - index sprintf(sTemp2," Index"); break; @@ -1498,7 +1501,7 @@ float convertC(float input) { if (!metric) { - //convert C to F! + //convert! float output = input *1.8f; output += 32.0f; return output; @@ -1509,7 +1512,7 @@ float convertF(float input) { if (metric) { - //convert F to C! + //convert! float output = input -32.0f; output /= 1.8f; return output; @@ -1535,4 +1538,3 @@ return "C"; return "F"; } -