Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Revision:
168:9227024c4e3a
Parent:
167:58d4edf403d4
Child:
169:84d790ac18a2
--- a/displayModes.cpp	Tue Dec 03 20:45:05 2013 +0000
+++ b/displayModes.cpp	Wed Dec 04 12:45:39 2013 +0000
@@ -37,12 +37,11 @@
             if (useable_kWh<0){
                 useable_kWh=0;
             }
+            tt.locate(181,4);
             if (useable_kWh<9.95){
-                tt.locate(166,4);
-                printf("  %3.1fkWh\n",useable_kWh);
+                printf("%3.2fkWh\n",useable_kWh);
             } else {
-                tt.locate(166,4);
-                printf(" %3.1fkWh\n",useable_kWh);
+                printf("%3.1fkWh\n",useable_kWh);
             }
         }
         if(force||SOC_x10!=lSOC){
@@ -54,18 +53,18 @@
         total_kW=kW[0]+CCkW;
         if(force||total_kW!=lkW){
             tt.foreground(Yellow);
-            if(total_kW<-10){ //Right justify
-                tt.locate(171,34);
-                printf("%4.2fkW\n",total_kW);
+            if(total_kW<=-9.95){ //Right justify
+                tt.locate(186,34);
+                printf("%3.1fkW\n",total_kW);
             } else if (total_kW<0){
-                tt.locate(171,34);
-                printf(" %4.2fkW\n",total_kW);
-            } else if (total_kW<10){
-                tt.locate(165,34);
-                printf("  %4.2fkW\n",total_kW);
+                tt.locate(186,34);
+                printf("%3.2fkW\n",total_kW);
+            } else if (total_kW<9.95){
+                tt.locate(180,34);
+                printf(" %3.2fkW\n",total_kW);
             } else {
-                tt.locate(165,34);
-                printf(" %4.2fkW\n",total_kW);
+                tt.locate(180,34);
+                printf(" %3.1fkW\n",total_kW);
             }
             lkW=total_kW;
             if(CCon){
@@ -169,7 +168,7 @@
         if(force||maxTemp!=lmaxTemp){
             tt.foreground(Cyan);
             tt.locate(210,146);
-            if (convertC(maxTemp)<100){
+            if (convertC(maxTemp)<99.5){
                 printf(" %3.1f%s\n",convertC(maxTemp),temperatureUnit());
             }else{
                 printf("%4.1f%s\n",convertC(maxTemp),temperatureUnit());
@@ -334,26 +333,34 @@
     lastldl=ldl;
 }
 
-void tripDisplay (bool force, bool showButtons){
-    static float lkWh=0;
-    float mpkwh_f;
+void tripDisplay (bool force, bool showButtons, bool inclCC){
+    static int lkWh=0;
+    float mpkWh_f, kWh_f;
     tt.background(White);
     if(force){
         tt.cls();
     }
-    if(force||(int)(lkWh*100)!=(int)(kWh_trip[0]*100)){ //only update if changed
+    if(force||(lkWh!=(int)(kWh_trip[0]*100))){ //only update if changed
         tt.foreground(Navy);
         tt.set_font((unsigned char*) Arial28x28);
         tt.locate(6,210);
-        printf("kWh : %s : Eff\n",distanceUnit());
+        if(inclCC){
+            printf("kWh : %s : Eff  (+CC)\n",distanceUnit());
+        } else {
+            printf("kWh : %s : Eff (noCC)\n",distanceUnit());
+        }
         for(int i=0; i<3; i++){
-            if(kWh_trip[i]>0.01){
-                mpkwh_f = convertDistance(miles_trip[i])/kWh_trip[i];
+            kWh_f = kWh_trip[i];
+            if(inclCC){
+                kWh_f += CCkWh_trip[i];
+            }
+            if(kWh_f>0.01){
+                mpkWh_f = convertDistance(miles_trip[i])/kWh_f;
             } else {
-                mpkwh_f = 0;
+                mpkWh_f = 0;
             }
             tt.locate(6,20+i*60);
-            printf("%3.2f : %3.1f : %2.1f  \n",kWh_trip[i],convertDistance(miles_trip[i]),mpkwh_f);
+            printf("%3.2f : %3.1f : %2.1f  \n",kWh_f,convertDistance(miles_trip[i]),mpkWh_f);
         }
         tt.foreground(Navy);
         tt.set_font((unsigned char*) Arial12x12);
@@ -367,7 +374,7 @@
         printf("charge\n");
         tt.locate(265,145);
         printf("custom\n");
-        lkWh=kWh_trip[0];
+        lkWh=(int)(kWh_trip[0]*100);
     }
     if(showButtons){
         showButton(3,2," Reset"," ",4,4);
@@ -1445,7 +1452,10 @@
             showIndex(changed,showButtons);
             break;
         case tripScreen:
-            tripDisplay(changed,showButtons);
+            tripDisplay(changed,showButtons,false);
+            break;
+        case ccTripScreen:
+            tripDisplay(changed,showButtons,true);
             break;
         case healthScreen:
             healthDisplay(changed,showButtons);