Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Branch:
Metric
Revision:
107:e9be732c1ad4
Parent:
106:f016912a03db
Child:
108:29b5a760adc2
diff -r f016912a03db -r e9be732c1ad4 main.cpp
--- a/main.cpp	Fri Jun 28 20:26:11 2013 +0000
+++ b/main.cpp	Sat Jun 29 02:44:02 2013 +0000
@@ -30,7 +30,7 @@
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
 
-char revStr[7] = "105";
+char revStr[7] = "107";
 
 LocalFileSystem local("local");
 
@@ -125,6 +125,8 @@
 signed long motorRPM;
 unsigned char skin = ttSkin ;
 unsigned char dtePeriod = 14; //ten minute averaging interval
+float kWh_trip[3]={0};
+float miles_trip[3]={0};
 float mph[39]={0};
 float kW[39]={0};
 float mpkWh[39]={0};
@@ -615,6 +617,9 @@
                                     debugMode = !debugMode;                                
                                 } else if (dMode[whichTouched] == indexScreen) { // gg - index
                                     dMode[whichTouched] = configScreen ; // GoTo Config Screen                                   
+                                } else if (dMode[whichTouched] == tripScreen) {
+                                    miles_trip[0]=0;
+                                    kWh_trip[0]=0;
                                 } else {
                                     lastDMode[whichTouched]=99;//repaint to clear highlight
                                 }                            
@@ -650,6 +655,9 @@
                              case 32: // right col, bottom row (not nav)  
                                 if (dMode[whichTouched] == configScreen) {
                                     updateFirmware();
+                                } else if (dMode[whichTouched] == tripScreen) {
+                                    miles_trip[1]=0;
+                                    kWh_trip[1]=0;
                                 } else {                             
                                     lastDMode[whichTouched]=99;//repaint to clear highlight
                                 }
@@ -714,6 +722,10 @@
                     fclose(hfile);
                 }
             }
+            if(!laccOn&&accOn){ // Car turned on
+                miles_trip[2]=0;
+                kWh_trip[2]=0;
+            }
             laccOn=accOn;
             if(!accOn&&!logEn&&userIdle&&!playbackEn){             
                 dled = 0; // turn off display if car off and logging disabled and no user activity
@@ -733,6 +745,10 @@
                 mph[0]=0;
             }
             mpkWh[0]=mph[0];
+            miles_trip[0]+=mph[0]/3600;
+            miles_trip[1]+=mph[0]/3600;
+            miles_trip[2]+=mph[0]/3600;
+
             if(numWsamples>0){ // Avoid div0
                 kW[0]=((float) mWs_x4)/numWsamples/4e3;     
                 mpkWh[0]/=kW[0];
@@ -743,7 +759,9 @@
                 kW[0]=0;
                 mpkWh[0]=0;
             }
-            //mpkWh[0]=floor(mpkWh[0]*10+0.5)/10; // Round to nearest 10th
+            kWh_trip[0]+=kW[0]/3600;
+            kWh_trip[1]+=kW[0]/3600;
+            kWh_trip[2]+=kW[0]/3600;
             motorRPM=0;
             numSsamples=0;
             mWs_x4=0;