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 175:0357b4159b40, committed 2014-02-07
- Comitter:
- TickTock
- Date:
- Fri Feb 07 01:59:53 2014 +0000
- Parent:
- 174:cd27e80f197d
- Child:
- 176:9c19f9856c76
- Commit message:
- // Added to the temperature lookup table; // Fixed div0 boundary condition bug in CP histogram; // Splash trip meter on second screen when turned off if showHealth is enabled;
Changed in this revision
--- a/displayModes.cpp Sun Jan 05 05:02:41 2014 +0000 +++ b/displayModes.cpp Fri Feb 07 01:59:53 2014 +0000 @@ -422,40 +422,40 @@ if(force||gids!=lgids){ tt.locate(10,10); if((gids+5)<startGids){ // Wh/gid, too, if trip long enough - printf("%4d gids (%0.0f)\n",gids,1000*(kWh_trip[0]+CCkWh_trip[0])/(startGids-gids)); + printf("%d gids (%0.0f)\n",gids,1000*(kWh_trip[0]+CCkWh_trip[0])/(startGids-gids)); }else{ - printf("%4d gids \n",gids); + printf("%d gids \n",gids); } lgids=gids; } if(force||SOC_x10!=lSOC){ tt.locate(10,40); - printf(" %4.1f%s \n",(float)SOC_x10/10,"% SOC"); + printf("%4.1f%s SOC \n",(float)SOC_x10/10,"%"); lSOC=SOC_x10; } if(force||SOH2_x100!=lSOH){ tt.locate(10,70); - printf(" %d%s,%3.1f%s \n",SOH_x2/2,"% SOH ",(float)SOH2_x100/100," Hx"); + printf("%d%s SOH, %3.1f Hx \n",SOH_x2/2,"%",(float)SOH2_x100/100); lSOH=SOH2_x100; } if(force||Ah_x10000!=lAh){ tt.locate(10,100); - printf(" %4.2f Ah cap \n",(float)Ah_x10000/10000); + printf("%4.2f Ah cap \n",(float)Ah_x10000/10000); lAh=Ah_x10000; } if(force||maxTemp!=lmaxTemp){ tt.locate(10,130); - printf(" %4.1f %s (max) \n",convertC(maxTemp),temperatureUnit()); + printf("%4.1f %s (max) \n",convertC(maxTemp),temperatureUnit()); lmaxTemp=maxTemp; } if(force||unloadedV_x2!=lunlV){ tt.locate(10,160); - printf(" %4.1f V \n",unloadedV_x2/2); + printf("%4.1f V \n",unloadedV_x2/2); lunlV=unloadedV_x2; } if(force||Resr!=lresr){ tt.locate(10,190); - printf(" %3.0f mOhms \n",Resr*1000); + printf("%3.0f mOhms \n",Resr*1000); lresr=Resr; } } @@ -875,8 +875,8 @@ // binning short nBin[301] ; // bins to count Min values in nBin[0], etc. int height; - int iBinIndxMax = 300 ; int iBinValMax = max - min ; // zero to N + int iBinIndxMax = (xWinMax-xWinMin)/2; // Maximum number of bars if( iBinValMax > iBinIndxMax ) iBinValMax = iBinIndxMax ; // clean the bins @@ -909,8 +909,8 @@ tt.locate( xWinMin-12, yWinMax+6 ); printf("%04d\n", min); tt.locate( xWinMax-18, yWinMax+6 ); printf("%04d\n", max); // draw the Histogram Frame, 2 pixels wide - tt.rect( xWinMin-1,yWinMin-1, xWinMax+1,yWinMax+1,Red); - tt.rect( xWinMin-2,yWinMin-2, xWinMax+2,yWinMax+2,Green); + tt.rect( xWinMin-1,yWinMin-1, xWinMax+0,yWinMax+0,Red); + tt.rect( xWinMin-2,yWinMin-2, xWinMax+1,yWinMax+1,Green); 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", @@ -919,11 +919,12 @@ //--------------- // show the bars - int nBarWidth = (xWinMax-xWinMin-2)/iBinValMax-1; //3 + int nBarWidth = (xWinMax-xWinMin)/(iBinValMax+1)-1; + if (nBarWidth < 1) nBarWidth = 1; int nBarSpace = 1 ; - int xPos = (xWinMin + xWinMax) / 2 ; - xPos -= (avg-min) * (nBarWidth + nBarSpace) ; + int xPos = (xWinMin + xWinMax)/2; + xPos -= ((iBinValMax+1)*(nBarWidth+nBarSpace))/2 ; for( int i=0; i<=iBinValMax; i++) { height = 4 * nBin[i] ;
--- a/main.cpp Sun Jan 05 05:02:41 2014 +0000 +++ b/main.cpp Fri Feb 07 01:59:53 2014 +0000 @@ -11,8 +11,10 @@ // * Add climate control impact to main max/min dte and new trip display // * Be more efficient with write buffer (use msgLen instead of always storing 8 bytes) -// rev174 -// Calibrated brake monitor. brkMonRate 378947 --> 1 chirp per 4Wh +// rev175 +// Added to the temperature lookup table +// Fixed div0 boundary condition bug in CP histogram +// Splash trip meter on second screen when turned off if showHealth is enabled #include "mbed.h" #include "CAN.h" @@ -23,7 +25,7 @@ #include "displayModes.h" #include "TOUCH_TFTx2.h" -char revStr[7] = "174"; +char revStr[7] = "175"; unsigned long maxTarget = 1000; FATFS USBdrive; LocalFileSystem local("local"); @@ -168,7 +170,7 @@ bool shunt[96]={0}; bool charging=false; bool showHealth=false; -unsigned char saveDmode=99; +unsigned char saveDmode[2] = {99, 99}; bool moving=false; unsigned short chirpInt; unsigned short uMsgId[8] = {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; // messages to display on debug screen msgId:byte @@ -823,10 +825,12 @@ if (laccOn&&!accOn){ // Car turned off lHeaterOn=false; if (showHealth&&!playbackOpen){ - if (saveDmode==99){ - saveDmode=dMode[0]; + if (saveDmode[0]==99){ + saveDmode[0]=dMode[0]; + saveDmode[1]=dMode[1]; } dMode[0]=healthScreen; + dMode[1]=tripScreen; secsNoTouch=2;// Keep display on a few seconds sMode=0; userIdle=false; @@ -872,8 +876,8 @@ wait5secs=5; getGids=true; if (showHealth&&!playbackOpen){ - if (saveDmode==99){ - saveDmode=dMode[0]; + if (saveDmode[0]==99){ + saveDmode[0]=dMode[0]; } dMode[0]=healthScreen; } @@ -882,9 +886,13 @@ laccOn=accOn; if(!accOn&&userIdle&&!playbackEn){ // Car off and no user activity - turn off screen dled = 0; - if (saveDmode<99){ - dMode[0]=saveDmode; - saveDmode=99; + if (saveDmode[0]<99){ + dMode[0]=saveDmode[0]; + saveDmode[0]=99; + } + if (saveDmode[1]<99){ + dMode[1]=saveDmode[1]; + saveDmode[1]=99; } }else if(!headlights){ dled = ledHi; @@ -910,9 +918,9 @@ } } //remove health screen once moving - if(moving&&(saveDmode<99)&&(wait5secs==0)){ - dMode[0]=saveDmode; - saveDmode=99; + if(moving&&(saveDmode[0]<99)&&(wait5secs==0)){ + dMode[0]=saveDmode[0]; + saveDmode[0]=99; } //compute historic efficiency
--- a/utility.cpp Sun Jan 05 05:02:41 2014 +0000 +++ b/utility.cpp Fri Feb 07 01:59:53 2014 +0000 @@ -283,8 +283,8 @@ j=battData[(BatDataBaseG4*7)+12]*0x100+battData[(BatDataBaseG4*7)+13]; if(j<k)k=j; //interpolate from lookup table - unsigned short temp_adc[8] = {1000,589,487,401,365,340,309,000}; - float temp_C[8] = { -27, 13, 23, 32, 36, 39, 43, 76}; + unsigned short temp_adc[10] = {1000,720,690,589,487,401,365,340,309,000}; + float temp_C[10] = { -27, 0, 3, 13, 23, 32, 36, 39, 43, 76}; char ii=0; while(k<=temp_adc[++ii]) { } // Find section in table maxTemp=(float)(k-temp_adc[ii]);