test fork

Dependencies:   SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary_9341 by Tick Tock

Revision:
144:b0c9d30dd346
Parent:
143:88b5155622a5
Child:
145:47cdacc468a4
--- a/main.cpp	Mon Aug 05 03:34:06 2013 +0000
+++ b/main.cpp	Tue Aug 06 01:26:17 2013 +0000
@@ -10,9 +10,10 @@
 // * Subtract accessory power from efficiency history (add back in when displaying)
 // * Add trip history display
 
-// rev143
+// rev144
 // added accessory volt read from battData
 // put a copy of the config.txt on the USB drive during firmware update
+// added current trip efficiency below 10 minute efficiency to dte display
 
 #include "mbed.h"
 #include "CAN.h"
@@ -23,7 +24,7 @@
 #include "utility.h"
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
-char revStr[7] = "143"; // gg - revision string, max 6 characters
+char revStr[7] = "144"; // gg - revision string, max 6 characters
 
 FATFS USBdrive;
 LocalFileSystem local("local");
@@ -123,6 +124,7 @@
 unsigned char dtePeriod = 14; //ten minute averaging interval
 float kWh_trip[3]={0};
 float miles_trip[3]={0};
+float curEff = 0;
 float maxTripEff = 4;
 float minTripEff = 4;
 float mph[39]={0};
@@ -702,6 +704,7 @@
 
         if(tick){ // Executes once a second
             tick=false;
+            curEff = miles_trip[0]/kWh_trip[0];
             headlights = (lastMsg[indexLastMsg[0x358]].data[1]&0x80)?true:false;  // headlight/turn signal indicator
             if(indexLastMsg[0x355]>0){
                 miles_kmbar = (lastMsg[indexLastMsg[0x355]].data[4]&0x20)?true:false;  // indicates selected distance units
@@ -723,12 +726,11 @@
                 }
                 // Keep track of max and min trip efficiency
                 if (miles_trip[0]>3){ // Ignore very short trips
-                    float tmpeff = miles_trip[0]/kWh_trip[0];
-                    if (maxTripEff<tmpeff) {
-                        maxTripEff=tmpeff;
+                    if (maxTripEff<curEff) {
+                        maxTripEff=curEff;
                     }
-                    if (minTripEff>tmpeff) {
-                        minTripEff=tmpeff;
+                    if (minTripEff>curEff) {
+                        minTripEff=curEff;
                     }
                 }
                 if (repeatPoll) { // Log on shutdown if autopoll enabled