Dual CANbus monitor and instrumentation cluster

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed

Fork of CANary by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Mon Jul 01 02:54:46 2013 +0000
Branch:
Metric
Parent:
112:b41b35401eb6
Child:
114:3f8c59a8a2b9
Commit message:
Fixed regen display when in Neutral

Changed in this revision

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/displayModes.cpp	Mon Jul 01 01:58:36 2013 +0000
+++ b/displayModes.cpp	Mon Jul 01 02:54:46 2013 +0000
@@ -72,16 +72,16 @@
 }
 
 void tripDisplay (bool force, bool showButtons){
-    static float lmiles=0;
+    static float lkWh=0;
     tt.background(White);
     if(force){
         tt.cls();
     }
-    if(force||(int)lmiles!=(int)miles_trip[0]){ //only update if changed
+    if(force||(int)(lkWh*100)!=(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());
+        printf("kWh : %s : Eff\n",distanceUnit());
         for(int i=0; i<3; i++){
             tt.locate(6,20+i*60);
             printf("%3.2f : %3.1f : %2.1f\n",kWh_trip[i],convertDistance(miles_trip[i]),convertDistance(miles_trip[i])/kWh_trip[i]);
@@ -91,6 +91,7 @@
         tt.foreground(Yellow);
         showButton(3,1," Reset","   A",4,4);
         showButton(3,2," Reset","   B",4,4);
+        lkWh=kWh_trip[0];
     }
 }
 
@@ -312,8 +313,8 @@
     msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen
     regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5);
     targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5);
-    msg = lastMsg[indexLastMsg[0x176]]; //Get Drive Mode
-    if (msg.data[3]==0xAA) { // In Park or Neutral
+    msg = lastMsg[indexLastMsg[0x421]]; //Get Drive Mode
+    if (msg.data[0]==0x18) { // In Neutral
         regenBraking = 0;  // No regen when in Neutral
     }
 
@@ -1026,8 +1027,8 @@
     msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen
     regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5);
     targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5);
-    msg = lastMsg[indexLastMsg[0x176]]; //Get Drive Mode
-    if (msg.data[3]==0xAA) { // In Park or Neutral
+    msg = lastMsg[indexLastMsg[0x421]]; //Get Drive Mode
+    if (msg.data[0]==0x18) { // In Neutral
         regenBraking = 0;  // No regen when in Neutral
     }
 
@@ -1312,8 +1313,8 @@
     msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen
     regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5);
     targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5);
-    msg = lastMsg[indexLastMsg[0x176]]; //Get Drive Mode
-    if (msg.data[3]==0xAA) { // In Park or Neutral
+    msg = lastMsg[indexLastMsg[0x421]]; //Get Drive Mode
+    if (msg.data[0]==0x18) { // In Neutral
         regenBraking = 0;  // No regen when in Neutral
     }
     msg = lastMsg[indexLastMsg[0x176]]; //Get rpms - not sure what this is but scales to mph with .0725
--- a/main.cpp	Mon Jul 01 01:58:36 2013 +0000
+++ b/main.cpp	Mon Jul 01 02:54:46 2013 +0000
@@ -24,7 +24,7 @@
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
 
-char revStr[7] = "112"; // gg - revision string, max 6 characters
+char revStr[7] = "113"; // gg - revision string, max 6 characters
 
 FATFS USBdrive;
 LocalFileSystem local("local");