Dual CANbus monitor and instrumentation cluster

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed

Fork of CANary by Tick Tock

Revision:
48:d1ce92104a1f
Parent:
43:e7f6f80590e3
Child:
50:83d5864c64a0
--- a/utility.cpp	Tue Apr 02 07:23:46 2013 +0000
+++ b/utility.cpp	Sat Apr 06 04:18:49 2013 +0000
@@ -102,7 +102,8 @@
         }
         lasti=i; //remember the msb to detect rollover next time around
         i+=bdi;
-        if(i==22) logCP=true; //Turbo3
+        //if(i==22) logCP=true; //Turbo3
+        if( (i==22) && (yesBattLog) ) logCP=true; // only if enabled gg - Batt Log 
         i*=7;
         if(i<0xfa){ // Is there a better way to do this?
             battData[i+0]=canRXmsg.data[1];
@@ -222,7 +223,7 @@
 void saveConfig(){
     FILE *cfile;
     cfile = fopen("/local/config.txt", "w");
-    fprintf(cfile,"format 2\r\n");
+    fprintf(cfile,"format 3\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);
@@ -244,6 +245,7 @@
     fprintf(cfile,"ledLo %4.3f\r\n",ledLo);
     fprintf(cfile,"pollInt %d\r\n",pollInt);
     fprintf(cfile,"scale12V %4.2f\r\n",scale12V);
+    fprintf(cfile,"skin %d\r\n",skin);
     fclose(cfile);
 }
 
@@ -261,8 +263,12 @@
         tt.calibrate();   // run touchscreen calibration routine
         saveConfig();
     } else {
-        //tt.setcal(5570, 34030, 80, 108, 33700, 5780, 82, 108, 32500);// bypass calibration using my values
-        fscanf(cfile, "format %c\r\n", &ff ) ;
+        ledHi = 0.823;
+        ledLo = 0.1;
+        pollInt = 300;
+        scale12V = 16.2;
+        skin = ttSkin;
+        fscanf(cfile, "format %d\r\n", &ff ) ;
         fscanf(cfile, "x0_off %d\r\n", &tt.x0_off ) ;
         fscanf(cfile, "y0_off %d\r\n", &tt.y0_off ) ;
         fscanf(cfile, "x0_pp %d\r\n", &tt.x0_pp ) ;
@@ -275,19 +281,20 @@
         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, "ledHi %f\r\n", &ledHi ) ;
+            fscanf(cfile, "ledLo %f\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;
+            fscanf(cfile, "scale12V %f\r\n", &scale12V ) ;
+        }
+        if(ff>2){
+            fscanf(cfile, "skin %d\r\n", &skin ) ;
         }
         fclose(cfile);
-        if(ff<2) //If not latest format, save as latest format
+        if(ff<3){//If not latest format, save as latest format
             saveConfig();
+            sprintf(sTemp,"Config file format updated.\n");
+            logMsg(sTemp);
+        }
         sprintf(sTemp,"Config file loaded.\n");
         logMsg(sTemp);
     }