Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Revision:
164:46ed06263b0e
Parent:
163:3b6fab958773
Child:
165:4daa921730dd
--- a/displayModes.cpp	Fri Nov 22 04:21:54 2013 +0000
+++ b/displayModes.cpp	Thu Nov 28 03:23:30 2013 +0000
@@ -45,7 +45,7 @@
             // worse-case DTE
             dte=convertDistance(minTripEff*useable_kWh); //LM - add metric conversion
             tt.foreground(Green);
-            tt.locate(20,80);            
+            tt.locate(20,90);            
             if(dte>=9.5){
                 printf("%2.0f \n",dte);
             }else{
@@ -77,34 +77,35 @@
             // No Climate Control DTE
             tt.set_font((unsigned char*) Arial24x23);
             tt.foreground(Green);
-            dte=convertDistance(mpkWh_noCC*useable_kWh); //LM - add metric conversion
-            if(dte>199){
-                dte=199;
+            if(CCon) {
+                dte=convertDistance(mpkWh_noCC*useable_kWh); //LM - add metric conversion
+                if(dte>199){
+                    dte=199;
+                }
+                // " "=13, "."=5, #=17
+                if(dte>=99.5){
+                    tt.locate(120,134);
+                    printf(" %3.0f\n",dte); 
+                }else if(dte>=9.5){
+                    tt.locate(111,134);
+                    printf("   %2.0f\n",dte);
+                }else{
+                    tt.locate(111,134);
+                    printf("   %2.1f\n",dte);
+                }
             }
-            // " "=13, "."=5, #=17
-            if(dte>=99.5){
-                tt.locate(120,134);
-                printf(" %3.0f\n",dte); 
-            }else if(dte>=9.5){
-                tt.locate(111,134);
-                printf("   %2.0f\n",dte);
-            }else{
-                tt.locate(111,134);
-                printf("   %2.1f\n",dte);
-            }
-
             // best-case DTE
             tt.set_font((unsigned char*) Arial28x28);
             dte=convertDistance(maxTripEff*useable_kWh); //LM - add metric conversion
             tt.foreground(Orange);
             if(dte>=99.5){
-                tt.locate(255,80);            
+                tt.locate(255,90);            
                 printf("%3.0f \n",dte);          
             }else if(dte>=9.5){
-                tt.locate(270,80);            
+                tt.locate(270,90);            
                 printf("%2.0f \n",dte);
             }else{
-                tt.locate(265,80);            
+                tt.locate(265,90);            
                 printf("%2.1f \n",dte);
             }
             lgids=gids;
@@ -127,6 +128,12 @@
                 printf(" %4.2fkW\n",total_kW);
             }
             lkW=total_kW;
+            if(CCon){
+                tt.set_font((unsigned char*) Arial12x12);
+                tt.locate(232,70);
+                printf("  %3.2fkW\n",CCkW);
+                tt.set_font((unsigned char*) Arial28x28);
+            }
         }
         if(force||SOC_x10!=lSOC){
             tt.locate(215,10);
@@ -1192,7 +1199,7 @@
         //x=50+38*6;
         //tt.line(x,60,x,220,DarkGrey);     
         tt.set_font((unsigned char*) SCProSB31x55);
-        tt.foreground(Green);
+        tt.foreground(Yellow);
         if (showMiles){
             float miles = mpkWh[dtePeriod]*((float)(gids-5)*.075);
             miles = convertDistance(miles); // LM - Metric support
@@ -1207,28 +1214,32 @@
                 tt.locate(151,1);
                 printf("    %2.1f\n",miles);
             }
-            tt.foreground(Cyan);
-            tt.set_font((unsigned char*) Arial24x23);
-            miles = mpkWh_noCC*((float)(gids-5)*.075);
-            miles = convertDistance(miles); // LM - Metric support
-            // Right justify
-            if (miles>99.9){ //space=13; num=17; . = 5
-                tt.locate(191,52);
-                printf("%4.1f\n",miles);
-            } else if (miles>9.9){
-                tt.locate(182,52);
-                printf("  %3.1f\n",miles);
-            } else {
-                tt.locate(173,52);
-                printf("    %2.1f\n",miles);
+            if(CCon) {
+                tt.foreground(Green);
+                tt.set_font((unsigned char*) Arial24x23);
+                miles = mpkWh_noCC*((float)(gids-5)*.075);
+                miles = convertDistance(miles); // LM - Metric support
+                // Right justify
+                if (miles>99.9){ //space=13; num=17; . = 5
+                    tt.locate(191,52);
+                    printf("%4.1f\n",miles);
+                } else if (miles>9.9){
+                    tt.locate(182,52);
+                    printf("  %3.1f\n",miles);
+                } else {
+                    tt.locate(173,52);
+                    printf("    %2.1f\n",miles);
+                }
             }
         } else {
             tt.locate(200,1);
             printf("%3.1f \n",mpkWh[dtePeriod]);
-            tt.foreground(Cyan);
-            tt.set_font((unsigned char*) Arial24x23);
-            tt.locate(240,52);
-            printf("%3.1f \n",mpkWh_noCC);
+            if(CCon) {
+                tt.foreground(Green);
+                tt.set_font((unsigned char*) Arial24x23);
+                tt.locate(240,52);
+                printf("%3.1f \n",mpkWh_noCC);
+            }
         }
         lx=50;
         ly=mpkWh[0]*40;
@@ -1307,9 +1318,9 @@
         if (r>160) r=160;
         if (r>t) t=r;  //Should never happen
         if(lr!=r||lt!=t){
-            tt.fillrect(264,239-160,310,239-t,Navy);
-            tt.fillrect(264,239-t,310,239-r,Red);
-            tt.fillrect(264,239-r,310,239,Green);
+            if (t<160) tt.fillrect(264,239-160,310,238-t,Navy);
+            if (r<t) tt.fillrect(264,239-t,310,238-r,Red);
+            if (0<r) tt.fillrect(264,239-r,310,238,Green);
         }
         lt=t;
         lr=r;
@@ -1375,7 +1386,7 @@
 
 void updateDisplay(char display){
     bool changed,showButtons;
-    changed = dMode[display]!=lastDMode[display];
+    changed = (dMode[display]!=lastDMode[display]);
     showButtons = (display==whichTouched)&&(sMode==1);
     tt.set_display(display);
     switch (dMode[display]) {