Dual CANbus monitor and instrumentation cluster

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed

Fork of CANary by Tick Tock

Branch:
Metric
Revision:
110:ffddff3ad2f2
Parent:
109:3e6f0e8fca0d
Child:
111:d1559bb25c43
--- a/main.cpp	Sun Jun 30 17:52:58 2013 +0000
+++ b/main.cpp	Sun Jun 30 19:52:38 2013 +0000
@@ -29,12 +29,12 @@
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
 
-char revStr[7] = "108";
+char revStr[7] = "110"; // gg - revision string, max 6 characters
+
 FATFS USBdrive;
 LocalFileSystem local("local");
 bool waitasec = true;
 // to write to USB Flash Drives, or equivalent (SD card in Reader/Writer)
-//MSCFileSystem fs("usb"); // to write to a USB Flash Drive
 FRESULT mfr=f_mount(0,&USBdrive);
 
 time_t seconds ;
@@ -59,11 +59,6 @@
 PwmOut dled(p23);
 Beep spkr(p21);
 
-// revision string, max 6 characters
-// gg - revStr is used in 2 places
-// gg - and is easy to edit here
-// gg - added ZeroSecTick and revStr
-
 bool debugMode = false;
 bool usbEn = false;
 bool logEn = true;
@@ -297,9 +292,10 @@
             if (repeatPoll) { // stop autopolling if enabled
                 autoPoll.detach();
             }
-            if (logOpen){
-                f_close(&efile);
-            } // if (logOpen)*/
+            //keep file open when asleep - new lseek not fast
+            //if (logOpen){
+            //    f_close(&efile);
+            //} // if (logOpen)*/
             seconds = time(NULL);
             t = *localtime(&seconds) ;
             strftime(sTemp, 40, "Sleeping: %a %m/%d/%Y %X\n", &t);
@@ -329,10 +325,15 @@
             strftime(sTemp, 40, "Waking: %a %m/%d/%Y %X\n", &t);
             printMsg(sTemp); // wakeup date time
             if (time(NULL)>(secs+1800)) {
-                logOpen = false; // Start new file if asleep for more than 30 minutes
+                if (logOpen){
+                    f_close(&efile);
+                    logOpen = false; // Start new file if asleep for more than 30 minutes
+                } // if (logOpen)
                 if (secsNoTouch>100) secsNoTouch = 100; // also mostly reset user Idle counter
             } else if (logOpen){ // insert timestamp on each wake if logging enabled (disabled for now)
-                efr = f_open(&efile,fileName,FA_WRITE|FA_OPEN_ALWAYS);
+                //file kept open
+                //efr = f_open(&efile,fileName,FA_WRITE|FA_OPEN_ALWAYS);
+                //f_lseek(&efile,0xffffffff); // goto end of file (append existing)
                 logEvent("WakingUp"); // gg - use messeges
                 logTS(); // Date-Time at wakeup
             }