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:
137:70853cf5a30f
Parent:
136:41a204105511
Child:
138:a2f5af85ed0d
--- a/main.cpp	Sat Jul 27 22:19:01 2013 +0000
+++ b/main.cpp	Sun Jul 28 05:32:17 2013 +0000
@@ -10,7 +10,9 @@
 // * Subtract accessory power from efficiency history (add back in when displaying)
 // * Add trip history display
 
-// rev136
+// rev137
+// Added update if screen touched on power
+// Fixed hang on immediate USB access
 
 #include "mbed.h"
 #include "CAN.h"
@@ -22,11 +24,10 @@
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
 
-char revStr[7] = "136"; // gg - revision string, max 6 characters
+char revStr[7] = "137"; // gg - revision string, max 6 characters
 
 FATFS USBdrive;
 LocalFileSystem local("local");
-bool waitasec = true;
 unsigned char wait5secs = 5;
 // to write to USB Flash Drives, or equivalent (SD card in Reader/Writer)
 // class10 SDcard in Reader/Writer recommended
@@ -156,7 +157,13 @@
     tt.background(Black);
     tt.set_display(2);       // select both displays
     tt.cls();
+    tt.foreground(White);
+    tt.set_font((unsigned char*) Arial12x12_prop);  // select the font
+    tt.locate(0,0);
     tt.claim(stdout);        // send stdout to the TFT display
+    if(tt.is_touched()){ // If touching screen on poweron then update firmware
+        updateFirmware();
+    }
     touchpad.rise(&touch_ISR);
     tt.wfi();               // enable interrupt on touch
     dled = 0.8; // turn on display LED 80%
@@ -263,7 +270,6 @@
             pointerSep=(writePointer+maxBufLen-readPointer)%maxBufLen;
             if (pointerSep>(maxBufLen/16)||carCanIdle||!logEn) {
                 // Dump buffer if > 1/16 full or canbus has stopped
-                //if (&efile == NULL) {
                 if (efr != FR_OK) {
                     logOpen = false;
                     printMsg("Failed to append log file.\n"); // failed to append 
@@ -847,14 +853,13 @@
                 }
                 logPackVoltages(); // Turbo3, only call
             }
-            if(!usbEn&&!waitasec){
+            if(!usbEn){
                 usbEn=detectUSB(); // Keep looking if none found
                 if(usbEn){ // Force update to clear USB init garbage
                     lastDMode[0]=99;
                     lastDMode[1]=99;
                 }
             }
-            waitasec=false; // work around to avoid hang when USB tries to init immediately
             tock=true;
         } // tick