test fork

Dependencies:   SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary_9341 by Tick Tock

Revision:
135:89986950d501
Parent:
134:ad243e4f1a17
Child:
136:41a204105511
--- a/main.cpp	Thu Jul 25 14:32:54 2013 +0000
+++ b/main.cpp	Fri Jul 26 04:35:31 2013 +0000
@@ -7,14 +7,12 @@
 // * Add coasting regen to regen/braking display
 // * Change semilog efficiency graph to linear with 10 minute values
 // * Add additional 79b bank readouts
-// * Add ability to transfer settings config file to/from USB
 // * Subtract accessory power from efficiency history (add back in when displaying)
+// * Add trip history display
 
-// rev134
-// Added orange highlight if psi<32
-// Qualified max and min trip efficiency update with trips > 3 miles
-// Keep mbed asleep during charging (EVcan only) unless logging active
-// Added miles & kWh to trip log
+// rev135
+// Hide buttons on health screen on powerdown
+// Turn off screen even if logging if car off and user idle
 
 #include "mbed.h"
 #include "CAN.h"
@@ -26,7 +24,7 @@
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
 
-char revStr[7] = "134"; // gg - revision string, max 6 characters
+char revStr[7] = "135"; // gg - revision string, max 6 characters
 
 FATFS USBdrive;
 LocalFileSystem local("local");
@@ -323,11 +321,9 @@
                 //__wfi(); // freeze CPU and wait for interrupt (from canbus or touch)
                 Sleep();
             }
-            if (logOpen){ // Re-attach EVcan
+            if (!logOpen){ // Re-attach EVcan
                 can1.attach(&recieve1);
             }
-            lastDMode[0]=99;
-            lastDMode[1]=99;
             secsNoTouch=2;
             carCanIdle=secsNoCarCanMsg>canTimeout;
             evCanIdle=secsNoEvCanMsg>canTimeout;
@@ -351,6 +347,7 @@
             if (repeatPoll) { // re-enable autopolling if enabled
                 autoPoll.attach(&autoPollISR,pollInt);
             }
+            wait5secs=3; // Refresh screen after 3 seconds
         } // if idle
         
         if(touched){ // call touchscreen procedure if touch interrupt detected
@@ -702,7 +699,7 @@
                         saveDmode=dMode[0];
                     }
                     dMode[0]=healthScreen;
-                    secsNoTouch=0;// Keep display on a few seconds
+                    secsNoTouch=2;// Keep display on a few seconds
                     sMode=0;
                     userIdle=false;
                 }
@@ -741,7 +738,8 @@
                 }
             }
             laccOn=accOn;
-            if(!accOn&&!logEn&&userIdle&&!playbackEn){ // Car off and logging disabled and no user activity
+            //if(!accOn&&!logEn&&userIdle&&!playbackEn){ // Car off and logging disabled and no user activity
+            if(!accOn&&userIdle&&!playbackEn){ // Car off and no user activity - turn off screen
                 dled = 0;
                 if (saveDmode<99){
                     dMode[0]=saveDmode;
@@ -759,6 +757,8 @@
                     reqMsgCnt=0;
                     msgReq.attach(&sendReq,0.015);
                 }
+                lastDMode[0]=99;
+                lastDMode[1]=99;
             }
 
             //remove health screen once moving