Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Mon Mar 04 04:41:24 2013 +0000
Parent:
16:2a6ca248e1cb
Child:
18:999401f359a5
Commit message:
Attempted to make firmware update from thumbdrive. Need timestamp to work, though.

Changed in this revision

common.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/common.h	Sun Mar 03 18:25:50 2013 +0000
+++ b/common.h	Mon Mar 04 04:41:24 2013 +0000
@@ -9,7 +9,7 @@
 #define cpScreen 7
 #define upLine "\033[1A"
 #define maxBufLen 768
-#define canTimeout 500
+#define canTimeout 5
 #define userTimeout 10
 #define btn31x1 12
 #define btn31x2 101
--- a/main.cpp	Sun Mar 03 18:25:50 2013 +0000
+++ b/main.cpp	Mon Mar 04 04:41:24 2013 +0000
@@ -8,7 +8,7 @@
 // * Date entry config screen (keypad)
 // * auto-poll option for cellpair data
 // * cellpair histogram
-// * 
+// * config screen (with ts cal, data, time, autopoll, enable/disable logging
 
 #include "mbed.h"
 #include "CAN.h"
@@ -60,7 +60,7 @@
 volatile bool canIdle = false, userIdle = false;
 bool touched=0; //flag to read touchscreen
 char counter = 0;
-unsigned char dMode[2] = {7,2}; //display mode
+unsigned char dMode[2] = {1,2}; //display mode
 unsigned char sMode = 0; // setup mode
 unsigned char lastDMode[2] = {0,0}; //last screen mode
 char displayLog[20][40];
@@ -137,10 +137,36 @@
         //    printf("%s\n", sTemp); // DAY MM/DD/YYYY HH:MM:SS
     }
 
+    // Look for new binary 
+    // Can't make this work right now since USB doesn't attach the right timestamp (so new binary isn't loaded)
+    cfile = fopen("/fs/CANary.bin", "rb");
+    if (cfile!=NULL){ //found a new binary on the thumbdrive so copy it over
+        sprintf(sTemp,"New binary found.\n");
+        logMsg(sTemp);
+        file = fopen("/local/CANary.bin", "wb");
+        if (file==NULL){ //failed to open destination
+            sprintf(sTemp,"Unable to open destination file.\n");
+            logMsg(sTemp);
+        } else {
+            while ( int size = fread( writeBuffer, sizeof(char), maxBufLen*13, cfile )){
+                fwrite( writeBuffer, sizeof(char), size, file );
+            }
+        fclose(cfile);
+        fclose(file);
+        remove("/fs/CANary.bin"); // delete original
+        mbed_reset(); //restart
+        }
+    } else {
+        sprintf(sTemp,"No binary found.\n");
+        logMsg(sTemp);
+    }
+
     // Look for config file
     cfile = fopen("/local/config.txt", "r");
     if (cfile==NULL){ // if doesn't exist --> create
-        sprintf(sTemp,"No config file found.\nCalibrating touch screen.\n");
+        sprintf(sTemp,"No config file found.\n");
+        logMsg(sTemp);
+        sprintf(sTemp,"Calibrating touch screen.\n");
         logMsg(sTemp);
         tt.calibrate();
         cfile = fopen("/local/config.txt", "w");