Dual CANbus monitor and instrumentation cluster supporting ILI9341 display controller

Dependencies:   SPI_TFTx2_ILI9341 TOUCH_TFTx2_ILI9341 TFT_fonts mbed

Fork of CANary by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Wed Dec 04 12:45:39 2013 +0000
Parent:
167:58d4edf403d4
Child:
169:84d790ac18a2
Commit message:
// Added trip meter including climate control impact;

Changed in this revision

common.h Show annotated file Show diff for this revision Revisions of this file
displayModes.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/common.h	Tue Dec 03 20:45:05 2013 +0000
+++ b/common.h	Wed Dec 04 12:45:39 2013 +0000
@@ -15,8 +15,9 @@
 #define config2Screen 14
 #define indexScreen 15
 #define tripScreen 16
-#define healthScreen 17
-#define testScreen 18
+#define ccTripScreen 17
+#define healthScreen 18
+#define testScreen 19
 #define maxScreens 19
 
 #define btnGap 10
--- 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);
--- a/main.cpp	Tue Dec 03 20:45:05 2013 +0000
+++ b/main.cpp	Wed Dec 04 12:45:39 2013 +0000
@@ -10,8 +10,8 @@
 // * Add on screen messages for heater on, etc, and use refresh feature above to clear in x seconds
 // * Add climate control impact to main max/min dte and new trip display
 
-// rev167
-// Added climate control impact to best case and worst case DTE (bug fix)
+// rev168
+// Added trip meter including climate control impact
 
 #include "mbed.h"
 #include "CAN.h"
@@ -21,7 +21,7 @@
 #include "utility.h"
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
-char revStr[7] = "167"; // gg - revision string, max 6 characters
+char revStr[7] = "168"; // gg - revision string, max 6 characters
 
 FATFS USBdrive;
 LocalFileSystem local("local");