Dual CANbus monitor and instrumentation cluster supporting ILI9341 display controller

Dependencies:   SPI_TFTx2_ILI9341 TOUCH_TFTx2_ILI9341 TFT_fonts mbed

Fork of CANary by Tick Tock

Revision:
30:e633a63eb257
Parent:
26:462ccb580472
Child:
31:082372c83f68
--- a/main.cpp	Sat Mar 16 15:54:10 2013 +0000
+++ b/main.cpp	Sat Mar 16 16:33:11 2013 +0000
@@ -188,7 +188,7 @@
                 }
             }//logging enabled
         } else { // if (logOpen)
-            if (((writePointer+maxBufLen-readPointer)%maxBufLen)>(maxBufLen/16)||canIdle) {
+            if (((writePointer+maxBufLen-readPointer)%maxBufLen)>(maxBufLen/16)||canIdle||!logEn) {
                 // Dump buffer if > 1/16 full or canbus has stopped
                 if (file == NULL) {
                     logOpen = false;
@@ -206,7 +206,11 @@
                     }
                     led4 = !led4;
                 }
-            } // if > 1/16 full, canbus has stopped, or PB1 pressed
+            } // if > 1/16 full, canbus has stopped, or logging stopped
+            if (!logEn) {
+                fclose(file);
+                logOpen=false;
+            }
         } // if logOpen
         if (canIdle&&userIdle) { // canbus idle --> sleep to save power
             if (logOpen){