Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Revision:
175:0357b4159b40
Parent:
174:cd27e80f197d
Child:
177:6fda79c2fda1
--- 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] ;