Dual CANbus monitor and instrumentation cluster

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed

Fork of CANary by Tick Tock

Revision:
35:5acbd8a64a89
Parent:
34:4751a8259b18
Child:
36:dbd39c315258
--- a/utility.cpp	Wed Mar 20 13:57:00 2013 +0000
+++ b/utility.cpp	Thu Mar 21 12:05:22 2013 +0000
@@ -27,7 +27,7 @@
 
 void touch_ISR(){
     LPC_GPIOINT->IO2IntClr = (LPC_GPIOINT->IO2IntStatR | LPC_GPIOINT->IO2IntStatF);
-    touched=true; // jsut set flag - touch screen algorythm is long and we don't want to block other interrupts
+    touched=true; // just set flag - touch screen algorythm is long and we don't want to block other interrupts
 }
 
 unsigned short getTimeStamp() {
@@ -193,7 +193,7 @@
 void saveConfig(){
     FILE *cfile;
     cfile = fopen("/local/config.txt", "w");
-    fprintf(cfile,"format 1\r\n");
+    fprintf(cfile,"format 2\r\n");
     fprintf(cfile,"x0_off %d\r\n",tt.x0_off);
     fprintf(cfile,"y0_off %d\r\n",tt.y0_off);
     fprintf(cfile,"x0_pp %d\r\n",tt.x0_pp);
@@ -211,6 +211,10 @@
         fprintf(cfile,"dMode1 %d\r\n",dteScreen);
     else
         fprintf(cfile,"dMode1 %d\r\n",dMode[1]);
+    fprintf(cfile,"ledHi %4.3f\r\n",ledHi);
+    fprintf(cfile,"ledLo %4.3f\r\n",ledLo);
+    fprintf(cfile,"pollInt %d\r\n",pollInt);
+    fprintf(cfile,"scale12V %4.2f\r\n",scale12V);
     fclose(cfile);
 }
 
@@ -243,7 +247,20 @@
         fscanf(cfile, "x_mid %d\r\n", &tt.x_mid ) ;
         fscanf(cfile, "dMode0 %d\r\n", &dMode[0] ) ;
         fscanf(cfile, "dMode1 %d\r\n", &dMode[1] ) ;
+        if(ff>1){
+            fscanf(cfile, "ledHi %4.3f\r\n", &ledHi ) ;
+            fscanf(cfile, "ledLo %4.3f\r\n", &ledLo ) ;
+            fscanf(cfile, "pollInt %d\r\n", &pollInt ) ;
+            fscanf(cfile, "scale12V %4.2f\r\n", &scale12V ) ;
+        }else{ //old format - set defaults
+            ledHi = 0.8;
+            ledLo = 0.1;
+            pollInt = 300;
+            scale12V = 16.2;
+        }
         fclose(cfile);
+        if(ff<2) //If not latest format, save as latest format
+            saveConfig();
     }
 }