Dual CANbus monitor and instrumentation cluster supporting ILI9341 display controller
Dependencies: SPI_TFTx2_ILI9341 TOUCH_TFTx2_ILI9341 TFT_fonts mbed
Fork of CANary by
Revision 167:58d4edf403d4, committed 2013-12-03
- Comitter:
- TickTock
- Date:
- Tue Dec 03 20:45:05 2013 +0000
- Parent:
- 166:ec3951ba9701
- Child:
- 168:9227024c4e3a
- Commit message:
- // Added climate control impact to best case and worst case DTE (bug fix);
Changed in this revision
--- a/displayModes.cpp Tue Dec 03 13:54:07 2013 +0000 +++ b/displayModes.cpp Tue Dec 03 20:45:05 2013 +0000 @@ -37,7 +37,7 @@ if (useable_kWh<0){ useable_kWh=0; } - if (useable_kWh<10){ + if (useable_kWh<9.95){ tt.locate(166,4); printf(" %3.1fkWh\n",useable_kWh); } else { @@ -77,8 +77,10 @@ } if(force||gids!=lgids||mpkWh[dtePeriod]!=lmpkWh){ // Display DTE - // worse-case DTE - dte=convertDistance(minTripEff*useable_kWh); //LM - add metric conversion + // worst-case DTE + // Compute DTE based on worst saved trip efficiency (without climate control) and adding the impact + // of the current climate control power relative to the last 10 minutes of driving + dte=convertDistance((minTripEff-mpkWh_noCC+mpkWh[dtePeriod])*useable_kWh); //LM - add metric conversion tt.foreground(Green); tt.locate(10,84); if(dte>=9.5){ @@ -130,10 +132,13 @@ tt.locate(111,134); printf(" %2.1f\n",dte); }*/ + lmaxTemp=0; //force battery termperature refresh (sometimes overlaps) } // best-case DTE tt.set_font((unsigned char*) Arial28x28); - dte=convertDistance(maxTripEff*useable_kWh); //LM - add metric conversion + // Compute DTE based on best saved trip efficiency (without climate control) and adding the impact + // of the current climate control power relative to the last 10 minutes of driving + dte=convertDistance((maxTripEff-mpkWh_noCC+mpkWh[dtePeriod])*useable_kWh); //LM - add metric conversion tt.foreground(Orange); if(dte>=99.5){ tt.locate(255,84);
--- a/displayModes.h Tue Dec 03 13:54:07 2013 +0000 +++ b/displayModes.h Tue Dec 03 20:45:05 2013 +0000 @@ -36,6 +36,7 @@ extern float playbackInt; extern float miles_trip[3]; extern float kWh_trip[3]; +extern float CCkWh_trip[3]; extern float kW[39]; extern float mpkWh[39]; extern float mpkWh_noCC; @@ -61,9 +62,8 @@ extern float unloadedV_x2,Resr,curRmax,curRmin,redRmax,redRmin,incRmax,incRmin; extern signed short Imax, Imin; extern bool showHealth; -extern float maxTripEff, minTripEff; +extern float maxTripEff, minTripEff, maxTripMiles, minTripMiles, maxTripkWh, minTripkWh, maxTripCCkWh, minTripCCkWh; extern bool brakeMon, regenMon, heaterMon; -extern float curEff; extern unsigned short uMsgId[8]; extern bool accOn; extern bool autoSync;
--- a/main.cpp Tue Dec 03 13:54:07 2013 +0000 +++ b/main.cpp Tue Dec 03 20:45:05 2013 +0000 @@ -8,10 +8,10 @@ // * Change pack volt color when CVLI fails // * Add tire pressure cal (40psi for me = FR 38, RR 38.2, FL 37.8, RL 38 - maybe 2psi error on my tire gauge?) // * Add on screen messages for heater on, etc, and use refresh feature above to clear in x seconds +// * Add climate control impact to main max/min dte and new trip display -// rev166 -// Re-formatted main and dte displays -// Fixed flicker on CC DTE +// rev167 +// Added climate control impact to best case and worst case DTE (bug fix) #include "mbed.h" #include "CAN.h" @@ -21,7 +21,7 @@ #include "utility.h" #include "displayModes.h" #include "TOUCH_TFTx2.h" -char revStr[7] = "166"; // gg - revision string, max 6 characters +char revStr[7] = "167"; // gg - revision string, max 6 characters FATFS USBdrive; LocalFileSystem local("local"); @@ -128,11 +128,18 @@ signed long motorRPM_x2; unsigned char skin = ttSkin ; unsigned char dtePeriod = 14; //ten minute averaging interval +float CCkWh_trip[3]={0}; float kWh_trip[3]={0}; float miles_trip[3]={0}; float curEff = 0; float maxTripEff = 0; float minTripEff = 5; +float maxTripMiles = 0; +float maxTripkWh = 1; +float maxTripCCkWh = 0; +float minTripMiles = 5; +float minTripkWh = 1; +float minTripCCkWh = 0; float mph[39]={0}; float kW[39]={0}; float mpkWh[39]={0}; @@ -228,6 +235,15 @@ if(!feof(hfile)){ fscanf(hfile,"%f\r\n",&Resr); } + if(!feof(hfile)){ + fscanf(hfile,"%f %f\r\n",&maxTripMiles,&minTripMiles); + } + if(!feof(hfile)){ + fscanf(hfile,"%f %f\r\n",&maxTripkWh,&minTripkWh); + } + if(!feof(hfile)){ + fscanf(hfile,"%f %f\r\n",&maxTripCCkWh,&minTripCCkWh); + } fclose(hfile); printMsg("History Loaded.\n"); // History loaded } else { // create initial file @@ -677,6 +693,7 @@ } else if (dMode[whichTouched]==tripScreen) { miles_trip[2]=0; kWh_trip[2]=0; + CCkWh_trip[2]=0; sMode=0; lastDMode[whichTouched]=99;//repaint to clear highlight } else if (dMode[whichTouched]==indexScreen) { @@ -757,11 +774,6 @@ lastDMode[0]=99;//force refresh lastDMode[1]=99;//force refresh } - if (miles_trip[0]>0.25) { - curEff = miles_trip[0]/kWh_trip[0]; - } else { - curEff = 0; - } headlights = (lastMsg[indexLastMsg[0x358]].data[1]&0x80)?true:false; // headlight/turn signal indicator if(heaterOn){ lHeaterOn=true; // Only indicate heater once per power cycle @@ -792,11 +804,18 @@ } // Keep track of max and min trip efficiency if (miles_trip[0]>5){ // Ignore short trips + curEff = miles_trip[0]/kWh_trip[0]; if (maxTripEff<curEff) { maxTripEff=curEff; + maxTripMiles=miles_trip[0]; + maxTripkWh=kWh_trip[0]; + maxTripCCkWh=CCkWh_trip[0]; } if (minTripEff>curEff) { minTripEff=curEff; + minTripMiles=miles_trip[0]; + minTripkWh=kWh_trip[0]; + minTripCCkWh=CCkWh_trip[0]; } } if (repeatPoll) { // Log on shutdown if autopoll enabled @@ -810,6 +829,9 @@ } fprintf(hfile,"%f %f\r\n",maxTripEff,minTripEff); // Save max and min fprintf(hfile,"%f \r\n",Resr); // Save series resistance + fprintf(hfile,"%f %f\r\n",maxTripMiles,minTripMiles); // Save max and min + fprintf(hfile,"%f %f\r\n",maxTripkWh,minTripkWh); // Save max and min + fprintf(hfile,"%f %f\r\n",maxTripCCkWh,minTripCCkWh); // Save max and min fclose(hfile); } } @@ -817,6 +839,7 @@ lHeaterOn=false; miles_trip[0]=0; kWh_trip[0]=0; + CCkWh_trip[0]=0; wait5secs=5; if (showHealth){ if (saveDmode==99){ @@ -909,9 +932,13 @@ kWh_trip[0]+=kW[0]/3600; kWh_trip[1]+=kW[0]/3600; kWh_trip[2]+=kW[0]/3600; + CCkWh_trip[0]+=CCkW/3600; + CCkWh_trip[1]+=CCkW/3600; + CCkWh_trip[2]+=CCkW/3600; } else { // charging so reset per charge trip meter miles_trip[1]=0; kWh_trip[1]=0; + CCkWh_trip[1]=0; } motorRPM_x2=0;
--- a/utility.h Tue Dec 03 13:54:07 2013 +0000 +++ b/utility.h Tue Dec 03 20:45:05 2013 +0000 @@ -69,8 +69,9 @@ extern bool accOn; extern float accV2; extern bool showHealth; -extern float kWh_trip[0]; -extern float miles_trip[0]; +extern float kWh_trip[3]; +extern float CCkWh_trip[3]; +extern float miles_trip[3]; extern PwmOut dled; // for test extern PwmOut spkr; extern bool brakeMon, regenMon, heaterMon;