test fork

Dependencies:   SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary_9341 by Tick Tock

Revision:
18:999401f359a5
Parent:
17:e32324a2678d
Child:
19:d576298c46f3
--- a/main.cpp	Mon Mar 04 04:41:24 2013 +0000
+++ b/main.cpp	Mon Mar 04 14:00:49 2013 +0000
@@ -60,7 +60,7 @@
 volatile bool canIdle = false, userIdle = false;
 bool touched=0; //flag to read touchscreen
 char counter = 0;
-unsigned char dMode[2] = {1,2}; //display mode
+unsigned char dMode[2] = {1,7}; //display mode
 unsigned char sMode = 0; // setup mode
 unsigned char lastDMode[2] = {0,0}; //last screen mode
 char displayLog[20][40];
@@ -139,7 +139,7 @@
 
     // 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");
+    /*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);
@@ -148,18 +148,28 @@
             sprintf(sTemp,"Unable to open destination file.\n");
             logMsg(sTemp);
         } else {
+            tt.set_display(2);
+            tt.foreground(White);
+            tt.background(Black);
+            tt.cls();
+            tt.locate(1,40);
+            printf("%s\n","Copying binary - Do no remove power.");
+            tt.locate(1,80);
+            printf("CANary will reset when complete.\n");
+            wait(1); //Wait 1 sec for display DMA to finish before writing file
             while ( int size = fread( writeBuffer, sizeof(char), maxBufLen*13, cfile )){
                 fwrite( writeBuffer, sizeof(char), size, file );
+                led4=led3;
+                led3=led2;
+                led2=led1;
+                led1=!led4;
             }
         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");
@@ -289,7 +299,7 @@
                 } else {
                     i=0;
                 }
-                if (lastTouch.y>btn11y1 && lastTouch.y<btn11y2) {
+                if (lastTouch.y>btn33y1 && lastTouch.y<btn33y2) {
                     if(sMode==1){
                         if (lastTouch.x>btn31x1 && lastTouch.x<btn31x2) {
                             dMode[i]=dMode[i]>0?dMode[i]-1:maxScreens;
@@ -299,7 +309,7 @@
                             dMode[i]=dMode[i]<maxScreens?dMode[i]+1:0;
                         }
                     } else sMode=1;
-                } else {
+                } else if (lastTouch.y>btn31y1 && lastTouch.y<btn31y2){
                     if (dMode[i]==monitorScreen||dMode[i]==changedScreen) {
                         if (lastTouch.x>btn31x1 && lastTouch.x<btn31x2) {
                             indexOffset=indexOffset>4?indexOffset-4:1;