Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Revision:
149:e9739523109f
Parent:
148:6e3b9135fad2
Child:
150:ef46ce63345c
--- a/displayModes.cpp	Thu Sep 12 14:42:22 2013 +0000
+++ b/displayModes.cpp	Wed Sep 25 03:33:18 2013 +0000
@@ -7,7 +7,7 @@
 void mainDisplay (bool force, bool showButtons){
     unsigned short gids, SOC_x10, packV_x2, tireP;
     float useable_kWh,dte;
-    unsigned char aTemp;
+    //unsigned char aTemp;
     static unsigned short lgids=0, lSOC=0, lpackV_x2=0, ltireP=0;
     static unsigned char laTemp=0;
     static float lmaxTemp=0, lkW=0, laccV=0, lmpkWh=0;
@@ -20,12 +20,7 @@
     SOC_x10 = (msg.data[0]<<2)+(msg.data[1]>>6);
     msg = lastMsg[indexLastMsg[0x1db]]; //Get pack volts
     packV_x2 = (msg.data[2]<<2)+(msg.data[3]>>6);
-    msg = lastMsg[indexLastMsg[0x54c]]; //Get ambient
-    aTemp = msg.data[6]-56;
-    //msg = lastMsg[indexLastMsg[0x79a]]; //Get ambient and cabin temperature
-    //aTemp = msg.data[5]-41; // Need to add convertsion to C if metric
-    //c1Temp = msg.data[4]-41;
-    //c2Temp = msg.data[6]-41;
+
     msg = lastMsg[indexLastMsg[0x385]]; //Get tire pressure
     tireP = msg.data[2]+msg.data[3]+msg.data[4]+msg.data[5];
 
@@ -46,7 +41,7 @@
             printf("%4.1f kWh \n",useable_kWh);
 
             // Display DTE
-            dte=convertDistance(minTripEff*useable_kWh);
+            dte=convertDistance(minTripEff*nomDrag/airDrag(ambient_F)*useable_kWh);
             tt.foreground(Green);
             tt.locate(20,80);            
             if(dte>=9.5){
@@ -57,7 +52,8 @@
 
             tt.set_font((unsigned char*) SCProSB31x55);
             tt.foreground(Yellow);
-            dte=convertDistance(mpkWh[dtePeriod]*useable_kWh);
+            //Totest:convert from 25C to current ambient temperature
+            dte=convertDistance(mpkWh[dtePeriod]);
             if(dte>199){
                 dte=199;
             }
@@ -76,7 +72,7 @@
             tt.locate(195,106);
             printf("%s\n",distanceUnit()); //LM - add metric conversion
 
-            dte=convertDistance(maxTripEff*useable_kWh);
+            dte=convertDistance(maxTripEff*nomDrag/airDrag(ambient_F)*useable_kWh);
             tt.foreground(Orange);
             if(dte>=99.5){
                 tt.locate(255,80);            
@@ -121,11 +117,11 @@
             lpackV_x2=packV_x2;
             ltireP=0;//Force tire pressure redraw, too
         }
-        if(force||aTemp!=laTemp){
+        if(force||ambient_F!=laTemp){
             tt.foreground(Cyan);
             tt.locate(20,146);
-            printf("%2.0f%s\n",convertF(aTemp),temperatureUnit());
-            laTemp=aTemp;
+            printf("%2.0f%s\n",convertF(ambient_F),temperatureUnit());
+            laTemp=ambient_F;
         }
         if(force||maxTemp!=lmaxTemp){
             tt.foreground(Cyan);
@@ -1139,6 +1135,7 @@
         tt.set_font((unsigned char*) SCProSB31x55);
         tt.foreground(Green);
         if (showMiles){
+            //Totest:convert from 25C to current ambient temperature
             float miles = mpkWh[dtePeriod]*((float)(gids-5)*.075);
             miles = convertDistance(miles); // LM - Metric support
             // Right justify
@@ -1155,9 +1152,11 @@
             tt.foreground(Cyan);
             tt.set_font((unsigned char*) Arial24x23);
             tt.locate(198,70);
+            //Totest:convert from 25C to current ambient temperature
             printf("%3.1f \n",mpkWh[dtePeriod]);
         } else {
             tt.locate(200,10);
+            //Totest:convert from 25C to current ambient temperature
             printf("%3.1f \n",mpkWh[dtePeriod]);
             tt.foreground(Cyan);
             tt.set_font((unsigned char*) Arial24x23);
@@ -1272,7 +1271,8 @@
     }
     if(pointerSep>maxPS){maxPS=pointerSep;}
     tt.locate(10,10);
-    printf("%3d sep  %3d max\n",pointerSep,maxPS);
+    //printf("%3d sep  %3d max\n",pointerSep,maxPS);
+    printf("%f %4.3f \n", ambient_F, airDrag(ambient_F));
     tt.locate(10,40);
     printf("%4.2fV %4.2fV \n",accV,accV2);
     for (i=0; i<4; i++){
@@ -1498,7 +1498,7 @@
 float convertC(float input) 
 {
     if (!metric) {
-        //convert!
+        //convert C to F!
         float output = input *1.8f;
         output += 32.0f;
         return output;   
@@ -1509,7 +1509,7 @@
 float convertF(float input) 
 {
     if (metric) {
-        //convert!
+        //convert F to C!
         float output = input -32.0f;
         output /= 1.8f;
         return output;   
@@ -1535,3 +1535,4 @@
         return "C";
     return "F";
 }
+