Dual CANbus monitor and instrumentation cluster

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed

Fork of CANary by Tick Tock

Revision:
89:2263d349b484
Parent:
88:45185a5f1c9b
Child:
90:312eecd3b37a
--- a/main.cpp	Sat Apr 20 17:08:40 2013 +0000
+++ b/main.cpp	Sat Apr 20 19:30:10 2013 +0000
@@ -206,7 +206,7 @@
     //read efficiency history data
     cfile = fopen("/local/ehist.cny", "r");
     if (cfile!=NULL){ // found a efficiency history file
-        for(i=0;i<39;i++){
+        for(i=0;i<39;++i){
             if(!feof(cfile)){
                 fscanf(cfile,"%f %f\r\n",&mph[i],&kW[i]);
                 mpkWh[i]=mph[i]/kW[i];
@@ -218,7 +218,7 @@
     } else { // create initial file
         sprintf(sTemp,"History not found.  Created.\n");
         printMsg(sTemp); // history not found, created
-        for(i=0;i<39;i++){
+        for(i=0;i<39;++i){
             // Pre-load with 4 mpkWh @ 40 mph
             mph[i]=40*timeConstant[i];
             kW[i]=10*timeConstant[i];
@@ -285,7 +285,7 @@
                     logEn=false;
                 } else {
                     while (readPointer != writePointer) {
-                        for (j = 0; j<13; j++){
+                        for (j = 0; j<13; ++j){
                             fprintf(file,"%c",writeBuffer[readPointer][j]);
                         }
                         if(++readPointer >= maxBufLen){
@@ -420,7 +420,7 @@
                             //-----------------------------------------------
                             case 10: // 1,0 (col left of center,top row) on screen 0 or 1
                                 if (dMode[whichTouched]==changedScreen) {
-                                    for(j=0;j<100;j++) msgChanged[j]=0; // clear changed data
+                                    for(j=0;j<100;++j) msgChanged[j]=0; // clear changed data
                                     lastDMode[whichTouched]=99;//force refresh
                                 } else if (dMode[whichTouched] == indexScreen) { // gg - index
                                     sMode=0;
@@ -676,13 +676,14 @@
         }
 
         if(tick){ // Executes once a second
+            headlights = (lastMsg[indexLastMsg[0x358]].data[1]&0x80)?true:false;  // headlight/turn signal indicator
             accV=floor(mon12V*scale12V*10+0.5)/10; //Round to nearest 10th
             accOn=(accV>5)?true:false;
             if(laccOn&&!accOn){ // Car turned off
                 //write efficiency history data
                 cfile = fopen("/local/ehist.cny", "w");
                 if (cfile!=NULL){ // found a efficiency history file
-                    for(i=0;i<39;i++){
+                    for(i=0;i<39;++i){
                         fprintf(cfile,"%f %f\r\n",mph[i],kW[i]);
                     }
                     fclose(cfile);
@@ -726,7 +727,7 @@
             mWs_x4=0;
             numWsamples=0;
             if(accOn||playbackEn){
-                for(i=1;i<39;i++){
+                for(i=1;i<39;++i){
                     average=mph[i]/timeConstant[i];
                     mph[i]-=average;
                     mph[i]+=mph[0];
@@ -745,7 +746,7 @@
             if(logCP)
                 logPackVoltages(); // Turbo3, only call
             tick=false;
-        }
+        }// tick
 
         display=display<1?display+1:0; // toggle display
         updateDisplay(display);
@@ -759,7 +760,7 @@
         
         if(step){ // playback
             if(playbackOpen&&playbackEn){
-                for(i=0;i<120;i++){
+                for(i=0;i<120;++i){
                     if(!feof(file)){
                         fscanf(file,"%5c%8c",&header,&data);
                         logCan(header[0],CANMessage(0x7ff&((header[4]<<8)+header[3]), data, 8)); // Playback