Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Revision:
163:3b6fab958773
Parent:
162:c6545fc0164a
Child:
164:46ed06263b0e
--- a/displayModes.cpp	Thu Nov 21 23:08:00 2013 +0000
+++ b/displayModes.cpp	Fri Nov 22 04:21:54 2013 +0000
@@ -42,47 +42,70 @@
             printf("%4.1f kWh \n",useable_kWh);
 
             // Display DTE
-            dte=convertDistance(minTripEff*useable_kWh);
+            // worse-case DTE
+            dte=convertDistance(minTripEff*useable_kWh); //LM - add metric conversion
             tt.foreground(Green);
             tt.locate(20,80);            
             if(dte>=9.5){
-                printf("%2.0f \n",dte); //LM - add metric conversion
+                printf("%2.0f \n",dte);
             }else{
-                printf("%2.1f \n",dte); //LM - add metric conversion
+                printf("%2.1f \n",dte);
             }
 
+            // 10-minute DTE
             tt.set_font((unsigned char*) SCProSB31x55);
             tt.foreground(Yellow);
-            dte=convertDistance(mpkWh[dtePeriod]*useable_kWh);
+            dte=convertDistance(mpkWh[dtePeriod]*useable_kWh); //LM - add metric conversion
             if(dte>199){
                 dte=199;
             }
             // " "=0x10, "."=0x15, #=0x1D
             if(dte>=99.5){
                 tt.locate(80,85);
-                printf(" %3.0f\n",dte); //LM - add metric conversion
+                printf(" %3.0f\n",dte); 
             }else if(dte>=9.5){
                 tt.locate(94,85);
-                printf("  %2.0f\n",dte); //LM - add metric conversion
+                printf("  %2.0f\n",dte);
             }else{
                 tt.locate(89,85);
-                printf(" %2.1f\n",dte); //LM - add metric conversion
+                printf(" %2.1f\n",dte);
             }
             tt.set_font((unsigned char*) Arial28x28);
             tt.locate(195,106);
-            printf("%s\n",distanceUnit()); //LM - add metric conversion
+            printf("%s\n",distanceUnit());
 
-            dte=convertDistance(maxTripEff*useable_kWh);
+            // 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;
+            }
+            // " "=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);            
-                printf("%3.0f \n",dte); //LM - add metric conversion            
+                printf("%3.0f \n",dte);          
             }else if(dte>=9.5){
                 tt.locate(270,80);            
-                printf("%2.0f \n",dte); //LM - add metric conversion
+                printf("%2.0f \n",dte);
             }else{
                 tt.locate(265,80);            
-                printf("%2.1f \n",dte); //LM - add metric conversion
+                printf("%2.1f \n",dte);
             }
             lgids=gids;
             lmpkWh=mpkWh[dtePeriod];
@@ -1175,13 +1198,13 @@
             miles = convertDistance(miles); // LM - Metric support
             // Right justify
             if (miles>99.9){ //space=18; num=31; . = 23
-                tt.locate(161,8);
+                tt.locate(161,1);
                 printf("%4.1f\n",miles);
             } else if (miles>9.9){
-                tt.locate(156,8);
+                tt.locate(156,1);
                 printf("  %3.1f\n",miles);
             } else {
-                tt.locate(151,8);
+                tt.locate(151,1);
                 printf("    %2.1f\n",miles);
             }
             tt.foreground(Cyan);
@@ -1190,21 +1213,21 @@
             miles = convertDistance(miles); // LM - Metric support
             // Right justify
             if (miles>99.9){ //space=13; num=17; . = 5
-                tt.locate(191,60);
+                tt.locate(191,52);
                 printf("%4.1f\n",miles);
             } else if (miles>9.9){
-                tt.locate(182,60);
+                tt.locate(182,52);
                 printf("  %3.1f\n",miles);
             } else {
-                tt.locate(173,60);
+                tt.locate(173,52);
                 printf("    %2.1f\n",miles);
             }
         } else {
-            tt.locate(200,10);
+            tt.locate(200,1);
             printf("%3.1f \n",mpkWh[dtePeriod]);
             tt.foreground(Cyan);
             tt.set_font((unsigned char*) Arial24x23);
-            tt.locate(240,60);
+            tt.locate(240,52);
             printf("%3.1f \n",mpkWh_noCC);
         }
         lx=50;
@@ -1270,29 +1293,21 @@
     }
 
     if (targetBraking<2045){
-        //if ((targetBraking>50)&&(regenBraking>50)){
-        //    temp = targetBraking;
-        //    temp *= 1000;
-        //    temp /= regenBraking;
-        //    if (temp<tardivreg_x1000) tardivreg_x1000=temp;
-        //}
         if (targetBraking>maxTarget) maxTarget=targetBraking;
-        //if (regenBraking>maxRegen) maxRegen=regenBraking;
-    
         temp = targetBraking;
-        temp *=200;
+        temp *=167;
         temp /= maxTarget;
         t = (char) temp;
-        if (t>175) t=175;
+        if (t>160) t=160;
         temp = regenBraking;
         temp *= tardivreg_x1000;
         temp /= maxTarget;
-        temp /= 5; // 1000/200=5
+        temp /= 6; // 1000/167=6
         r = (char) temp;
-        if (r>175) r=175;
+        if (r>160) r=160;
         if (r>t) t=r;  //Should never happen
         if(lr!=r||lt!=t){
-            tt.fillrect(264,64,310,239-t,Navy);
+            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);
         }