Dual CANbus monitor and instrumentation cluster

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed

Fork of CANary by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Sat Apr 06 04:18:49 2013 +0000
Parent:
47:9cc7d876dd6d
Child:
49:a3d2c5bb3cfa
Commit message:
Merged in gg's edits. Fixed config load (problem with floats)

Changed in this revision

common.h Show annotated file Show diff for this revision Revisions of this file
displayModes.cpp Show annotated file Show diff for this revision Revisions of this file
displayModes.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
utility.cpp Show annotated file Show diff for this revision Revisions of this file
utility.h Show annotated file Show diff for this revision Revisions of this file
--- a/common.h	Tue Apr 02 07:23:46 2013 +0000
+++ b/common.h	Sat Apr 06 04:18:49 2013 +0000
@@ -10,8 +10,11 @@
 #define playbackScreen 9
 #define dateScreen 10
 #define cpHistScreen 11
-#define maxScreens 11
+#define cpBarScreen 12
+#define maxScreens 12
 #define btnGap 10
+#define ttSkin 0
+#define ggSkin 1
 
 #define maxBufLen 512
 #define canTimeout 5
--- a/displayModes.cpp	Tue Apr 02 07:23:46 2013 +0000
+++ b/displayModes.cpp	Sat Apr 06 04:18:49 2013 +0000
@@ -93,38 +93,81 @@
     tt.foreground(Yellow);
     tt.set_font((unsigned char*) Arial28x28);
     if(force) tt.cls();
-    if(force||gids!=lgids){
-        tt.locate(10,10);
-        printf("%4d gids \n",gids);
-        tt.locate(20,40);
-        printf("%4.1f kWh  \n",(float)gids*0.08);
-        tt.set_font((unsigned char*) SCProSB31x55);
-        tt.foreground(Green);
-        tt.locate(60,96);
-        printf("%4.1f mi  \n",(float)(gids-5)*0.31); // Approx for now
-        lgids=gids;
-        tt.foreground(Yellow);
-        tt.set_font((unsigned char*) Arial28x28);
-    }
-    if(force||SOC!=lSOC){
-        tt.locate(200,10);
-        printf("%4.1f%s\n",(float)SOC/10,"% ");
-        lSOC=SOC;
-    }
-    if(force||packV!=lpackV){
-        tt.locate(200,200);
-        printf("%4.1fV \n",(float)packV/2);
-        lpackV=packV;
-    }
-    if(force||accV!=laccV){
-        tt.locate(20,200);
-        printf("%3.1fV  \n",accV);
-        laccV=accV;
-    }
-    if(force||kW!=lkW){
-        tt.locate(180,40);
-        printf("%3.2fkW  \n",kW);
-        lkW=kW;
+    if(skin==ttSkin){
+        if(force||gids!=lgids){
+            tt.locate(10,10);
+            printf("%4d gids \n",gids);
+            tt.locate(20,40);
+            printf("%4.1f kWh  \n",(float)gids*0.08);
+            tt.set_font((unsigned char*) SCProSB31x55);
+            tt.foreground(Green);
+            tt.locate(60,96);
+            printf("%4.1f mi  \n",(float)(gids-5)*0.31); // Approx for now
+            lgids=gids;
+            tt.foreground(Yellow);
+            tt.set_font((unsigned char*) Arial28x28);
+        }
+        if(force||SOC!=lSOC){
+            tt.locate(200,10);
+            printf("%4.1f%s\n",(float)SOC/10,"% ");
+            lSOC=SOC;
+        }
+        if(force||packV!=lpackV){
+            tt.locate(200,200);
+            printf("%4.1fV \n",(float)packV/2);
+            lpackV=packV;
+        }
+        if(force||accV!=laccV){
+            tt.locate(20,200);
+            printf("%3.1fV  \n",accV);
+            laccV=accV;
+        }
+        if(force||kW!=lkW){
+            tt.locate(180,40);
+            printf("%3.2fkW  \n",kW);
+            lkW=kW;
+        }
+    }else {//if(skin==ggSkin){
+        if(force||gids!=lgids){
+            tt.locate(10,10);
+            printf("%4d GIDs \n",gids);
+            
+            tt.locate(40,40); // gg - add GIDs Percent of 281
+            printf("%4.1f%s \n", (float)gids*0.355872, "% ") ;
+            tt.locate(20,70);
+            //printf("%4.1f kWh  \n",(float)gids*0.08); // is input, not usable
+            printf("%4.1f kwh  \n",(float)gids*0.075); // gg - closer to usable
+            
+            tt.set_font((unsigned char*) SCProSB31x55);
+            tt.foreground(Green);
+            //tt.locate(60,96);
+            tt.locate(60,116); // gg - move down a little
+            printf("%4.1f mi  \n",(float)(gids-5)*0.31); // Approx for now
+            lgids=gids;
+            tt.foreground(Yellow);
+            tt.set_font((unsigned char*) Arial28x28);
+        }
+        
+        if(force||SOC!=lSOC){
+            tt.locate(200,10);
+            printf("%4.1f%s\n",(float)SOC/10,"% ");
+            lSOC=SOC;
+        }
+        if(force||packV!=lpackV){
+            tt.locate(200,200);
+            printf("%4.1fV \n",(float)packV/2);
+            lpackV=packV;
+        }
+        if(force||accV!=laccV){
+            tt.locate(20,200);
+            printf("%3.1fV  \n",accV);
+            laccV=accV;
+        }
+        if(force||kW!=lkW){
+            tt.locate(160,40); // gg - move left to keep from wrap
+            printf("%3.2fkw \n",kW); // use small w to save space
+            lkW=kW;
+        }
     }
 }
 
@@ -140,13 +183,28 @@
     static unsigned short ls;
     unsigned char throttle;
     static unsigned char lthrottle;
+    short steerOutBounds = 0 ;
     CANMessage msg;
 
+    //---------------
     msg = lastMsg[indexLastMsg[0x180]]; //Get Throttle position
     throttle = msg.data[5];
+    
+    // ---- steering ----
     msg = lastMsg[indexLastMsg[0x002]]; //Get Steering angle
     steering = (msg.data[1]<<8)+msg.data[0];
-    s= (unsigned short) ((steering/10)+160)%310;
+    
+    if(skin==ttSkin){
+        s= (unsigned short) ((steering/10)+160)%310; // this modulo wraps display
+    }else{// if(skin==ggSkin){    
+        // do not go off screen left or right. gg - steering
+        short ss = (short) ((steering/15)+160); // less gain 10 -> 15
+        if(ss<0) { ss=0; steerOutBounds = 1; }
+        if(ss>310) { ss=310; steerOutBounds = 1; }
+        s = (unsigned short) ss;
+    }
+    
+    //--------------
     msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target and Regen
     regenBraking = (msg.data[0]<<3)+(msg.data[1]>>5);
     targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5);
@@ -172,16 +230,28 @@
         lastPressure[2] = 200;
         lastPressure[3] = 200;
     }
-
+    
+    // display the steering position small square
     if (s!=ls){
-        tt.fillrect(ls,5,ls+9,14, Navy);        
-        tt.fillrect(s,5,s+9,14, White);        
+        // steering position has moved
+        //tt.fillrect(ls,5,ls+9,14, Navy);    // blank old position    
+        
+        //---- gg - steering red
+        // box is blanked by top of Braking bar, so move up 5
+        tt.fillrect(ls,0,ls+9,9, Navy);    // blank old position    
+        if( steerOutBounds != 0 ) // draw out-of-bounds as a red box 
+            tt.fillrect(s,0,s+9,9, Red);     // draw out-of-bounds position 
+        else
+            tt.fillrect(s,0,s+9,9, White);   // draw new in-bounds position 
+            
+        //----
         //tt.foreground(Yellow);
         //tt.set_font((unsigned char*) Arial28x28);
         //tt.locate(10,40);
         //printf("%d %d    \n",s,ls);
         ls=s;
     }
+    
     if (throttle!=lthrottle){
         if (throttle>239) throttle=239;
         if(throttle<lthrottle){
@@ -294,6 +364,132 @@
 }
 
 //----------------
+// gg - cpbars
+void cpBarPlot(bool force, bool showButtons){ 
+    short unsigned max, min, jv, i, bd;
+    unsigned avg;
+    short unsigned nBar[96] ; // bar height over min
+
+    if(force){
+        tt.foreground(White);
+        tt.background(Navy);
+        tt.set_font((unsigned char*) Arial12x12_prop);  // select the font
+        max=0;
+        min=9999;
+        avg=0;
+       
+        // calc each cell-pair voltage, find max and min
+        for(i=0; i<96; i++){
+           bd=(battData[i*2+3]<<8)+battData[i*2+4];
+           nBar[i] = bd; // init to bar height
+           avg+=bd;
+            if(bd>max) max=bd;
+            if(bd<min) min=bd;
+        }
+        avg /= 96;
+        
+        if(min<3713) {
+            jv=avg-(max-avg)*1.5;
+        } else { // Only compute judgement value if min cellpair meets <= 3712mV requirement
+            jv=0;
+        }
+        
+        //------------------
+        tt.cls();
+            
+        // show as vertical bar plot
+        int xWinMin = 26;
+        int xWinMax = 316;
+        int yWinMin = 50;
+        int yWinMax = 150;
+        // draw the Bar Graph Frame, 2 pixels wide
+        tt.rect( xWinMin-1,yWinMin-1, xWinMax+1,yWinMax+1,Red);
+        tt.rect( xWinMin-2,yWinMin-2, xWinMax+2,yWinMax+2,Green);
+        
+        // bar heights
+        int height = yWinMax - yWinMin ;
+        int iBarValMax = max - min ; // zero to N
+        
+        //----------------
+        if( iBarValMax == 0 ) {
+            // for testing
+            min = 3501 ; 
+            //max = min + 95*2 ; // for tall values
+            max = min + 95/4 ; // for small values
+            avg = ( max + min ) / 2;
+            iBarValMax = max - min ; // zero to N
+            for(int i=0; i<96; i++) {
+              //nBar[i] = i*2 + min ; // test tall values
+              nBar[i] = i/4 + min ; // test small values
+            }
+        }
+        //---------------
+        float nBarScale = float(height) / iBarValMax ;
+        if( nBarScale < 0.1 ) nBarScale = 0.1 ;
+    
+        // do the Bar-height scaling
+        for(int i=0; i<96; i++){
+          nBar[i] -= min ; // now, 0 to N = iBinValMax
+          nBar[i] *= nBarScale ; // scale, as needed
+        }
+        
+        // values, for now
+        tt.locate( 0, yWinMax+40 );
+        printf(" MAX  MIN  AVG CVLI T1  T2  T3  T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n",
+                max,min,avg,jv,
+                battData[224+5],battData[224+8],
+                battData[224+11],battData[224+14]);
+        
+        // label the X axis (approximate)
+        tt.locate( 2, yWinMax+5); printf("%04d", min );
+        //tt.locate( 2, yWinMin-14 ); printf("%04d = %04d from %1.4f", max, int( height / nBarScale ) + min, nBarScale );
+        tt.locate( 2, yWinMin-14 ); printf("%04d = (%d) mv range.", max , max - min );
+               
+        //---------------
+        // show the bars
+        int nBarWidth = 2 ;
+        int nBarSpace = 1 ; // 1 for testing
+        
+        int xPos = xWinMin + 2 ; // start one from the left
+         
+        for( int i=0; i<96; i++) {
+            height = nBar[i] ;
+            if( height > 100 ) height = 100 ; // clip tops
+            
+            // draw the bar, is always inside x-window
+            tt.fillrect( xPos,yWinMax-height, xPos+nBarWidth-1,yWinMax, Green);  
+              
+            // tic mark the y axis each 5
+            if(i%5 == 4){
+               tt.line( xPos,yWinMax+2, xPos,yWinMax+5, White);  // a white tick mark
+               tt.line( xPos+1,yWinMax+2, xPos+1,yWinMax+5, White);  // a white tick mark, to widen
+               //tt.rect( xPos,yWinMax+2, xPos+1,yWinMax+5, White);  // a white 2-wide tick mark is SLOW
+            }
+            // label the y axis each 10
+            if(i%10 == 9){
+               tt.locate( xPos-6, yWinMax+8 );
+               printf("%02d\n", i+1 );
+            }
+            
+            // step to the next bar position
+            xPos += nBarWidth + nBarSpace ; 
+        }
+        
+        showCP=false;
+    }
+    
+    // handle the button
+    if(sMode==1&&showButtons){
+        tt.foreground(Yellow);
+        tt.background(DarkCyan);
+        tt.set_font((unsigned char*) Arial12x12);
+        sprintf(sTemp1," Request");
+        sprintf(sTemp2," CP data");
+        showButton(1,0,sTemp1,sTemp2,3,3);               
+    }
+}
+
+//----------------
 // gg - hist
 void cpHistogram(bool force, bool showButtons){ 
     short unsigned max, min, jv, i, bd;
@@ -330,9 +526,6 @@
         tt.rect( xWinMin-1,yWinMin-1, xWinMax+1,yWinMax+1,Red);
         tt.rect( xWinMin-2,yWinMin-2, xWinMax+2,yWinMax+2,Green);
         
-        tt.locate( 0, yWinMax+10 );
-        printf(" MAX  MIN  AVG CVLI T1  T2  T3  T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n",max,min,avg,jv,battData[224+5],battData[224+8],battData[224+11],battData[224+14]);
-        
         // binning
         short nBin[301] ; // bins to count Min values in nBin[0], etc.
         int height ;
@@ -365,6 +558,10 @@
             }
         }
         
+        // the values, for now
+        tt.locate( 0, yWinMax+40 );
+        printf(" MAX  MIN  AVG CVLI T1  T2  T3  T4\n %04d %04d %04d %04d %02dC %02dC %02dC %02dC\n\n",max,min,avg,jv,battData[224+5],battData[224+8],battData[224+11],battData[224+14]);
+        
         //---------------
         // show the bars
         int nBarWidth = 3 ;
@@ -399,6 +596,7 @@
     }
 }
 
+//---------------
 void config1(bool force, bool showButtons){
     if (force) {
         tt.background(Black);
@@ -416,6 +614,8 @@
     sprintf(sTemp1,"  Save");
     sprintf(sTemp2,"  Config");
     showButton(2,0,sTemp1,sTemp2,3,3);
+    
+    //------- second row -----
     if (logEn) {
         sprintf(sTemp1," Disable");
     } else {
@@ -423,6 +623,7 @@
     }
     sprintf(sTemp2," Logging");
     showButton(0,1,sTemp1,sTemp2,3,3);
+    
     if (repeatPoll) {
         sprintf(sTemp1," Disable");
     } else {
@@ -430,6 +631,15 @@
     }
     sprintf(sTemp2," Auto CP");
     showButton(1,1,sTemp1,sTemp2,3,3);
+    
+    // add Enable/Disable Batt Log gg - yesBattLog
+    if (yesBattLog) {
+        sprintf(sTemp1," Disable");
+    } else {
+        sprintf(sTemp1," Enable");
+    }
+    sprintf(sTemp2," Batt Log");
+    showButton(2,1,sTemp1,sTemp2,3,3);
 }
 
 void pbScreen(bool force, bool showButtons){
@@ -570,6 +780,9 @@
         case cpHistScreen: // gg - hist
             cpHistogram(changed||showCP,(display==whichTouched));
             break;
+        case cpBarScreen: // gg - cpbars
+            cpBarPlot(changed||showCP,(display==whichTouched));
+            break;
         default:
             if (changed){
                 tt.background(Black);
@@ -628,6 +841,9 @@
                     case cpHistScreen: // gg - hist
                         sprintf(sTemp2," CP Hist");
                         break;
+                    case cpBarScreen: // gg - cpbars
+                        sprintf(sTemp2," CP Bars");
+                        break;
                 }
                 showButton(1,2,sTemp1,sTemp2,3,3);
                 wait_ms(100); //  pause a moment to reduce flicker
--- a/displayModes.h	Tue Apr 02 07:23:46 2013 +0000
+++ b/displayModes.h	Sat Apr 06 04:18:49 2013 +0000
@@ -18,6 +18,7 @@
 extern unsigned char battData[256];
 extern bool showCP;
 extern bool logEn;
+extern bool yesBattLog; // gg - Batt Log
 extern bool repeatPoll;
 extern unsigned char dMode[2];
 extern unsigned char lastDMode[2];
@@ -32,6 +33,7 @@
 extern float mpkWh;
 extern float MPH;
 extern unsigned char whichTouched;
+extern unsigned char skin;
 
 extern "C" {
     void printLast (bool force, bool showButtons);
@@ -42,6 +44,7 @@
     void braking (bool force, bool showButtons, bool prdata);
     void cpData(bool force, bool showButtons);
     void cpHistogram(bool force, bool showButtons); // gg - hist
+    void cpBarPlot(bool force, bool showButtons); // gg - cpbars
     void showDateTime(bool force, bool showButtons);
     void updateDisplay(char display);
     void showButton(unsigned char column, unsigned char row, char * text1, char * text2, unsigned char columns, unsigned char rows);
--- a/main.cpp	Tue Apr 02 07:23:46 2013 +0000
+++ b/main.cpp	Sat Apr 06 04:18:49 2013 +0000
@@ -45,7 +45,8 @@
 PwmOut dled(p23);
 Beep spkr(p21);
 
-bool logEn = false,logOpen = false;
+bool logEn = false, logOpen = false; 
+bool yesBattLog = false ; // gg - Batt Log
 FILE *cfile;
 FILE *file;
 char fileName[35] = "" ;
@@ -95,6 +96,7 @@
 char data[8];
 signed long motorRPM;
 float MPH = 0;
+unsigned char skin = 0;
 
 int main() {
     int readPointer=0;
@@ -141,7 +143,10 @@
     t = *localtime(&seconds) ;
     strftime(sTemp, 32, "%a %m/%d/%Y %X\n", &t);
     logMsg(sTemp);
-    sprintf(sTemp,"CANary firmware rev47\n");
+    
+    //---- revisions ----
+    sprintf(sTemp,"CANary firmware rev48\n");
+
     logMsg(sTemp);
 
     // Look for new binary on thumbdrive
@@ -182,12 +187,6 @@
 
     // Read config file
     readConfig();
-    i=dMode[1];
-    dMode[1]=logScreen;
-    lastDMode[1]=99;
-    updateDisplay(1);
-    wait_ms(3000); // Pause for a few seconds
-    dMode[1]=i;
 
     touched=false;
     secsNoTouch=2;
@@ -338,13 +337,15 @@
                                 }
                                 break;
                             case 10:
-                            case 40:
+                            case 40: 
                                 if (dMode[whichTouched]==changedScreen) {
                                     for(j=0;j<100;j++) msgChanged[j]=0; // clear changed data
                                     lastDMode[whichTouched]=99;//force refresh
                                 } else if (dMode[whichTouched]==cpScreen) {
                                     pollCP=true;
-                                } else if (dMode[whichTouched]==cpHistScreen) {
+                                } else if (dMode[whichTouched]==cpHistScreen) { // gg - hist
+                                    pollCP=true;
+                                } else if (dMode[whichTouched]==cpBarScreen) { // gg - cpbars
                                     pollCP=true;
                                 } else if (dMode[whichTouched]==config1Screen) {
                                     mbed_reset();
@@ -377,7 +378,7 @@
                                 }
                                 break;
                             case 01:
-                            case 31:
+                            case 31: // row 2 left
                                 if (dMode[whichTouched]==config1Screen) {
                                     logEn = !logEn;
                                     if (!logEn) repeatPoll=false; // disable auto polling, too
@@ -387,7 +388,7 @@
                                 }
                                 break;
                             case 11:
-                            case 41:
+                            case 41: // row 2 center
                                 if (dMode[whichTouched]==config1Screen){
                                     repeatPoll = !repeatPoll&&logEn;
                                     if (repeatPoll) {
@@ -431,8 +432,11 @@
                                 }
                                 break;
                             case 21:
-                            case 51:
-                                if (dMode[whichTouched]==dateScreen){
+                            case 51: // row 2 right button
+                                if (dMode[whichTouched]==config1Screen) { // gg - Batt Log Enable Button
+                                    yesBattLog = !yesBattLog;
+                                    
+                                } else if (dMode[whichTouched]==dateScreen){
                                     upDate(dtMode,false);
                                     lastDMode[whichTouched]=99;
                                 }
--- 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);
     }
--- a/utility.h	Tue Apr 02 07:23:46 2013 +0000
+++ b/utility.h	Sat Apr 06 04:18:49 2013 +0000
@@ -15,6 +15,7 @@
 extern bool touched;
 extern bool logOpen;
 extern bool logCP; // Turbo3
+extern bool yesBattLog ; // gg - Batt Log
 extern bool showCP;
 extern char writeBuffer[maxBufLen][13];
 extern volatile int writePointer;
@@ -42,6 +43,7 @@
 extern unsigned short numWsamples;
 extern signed long motorRPM;
 extern unsigned short numSsamples;
+extern unsigned char skin;
 
 extern "C" {
     void mbed_reset();