Dual CANbus monitor and instrumentation cluster. Presently tuned for the Nissan Leaf EV.

Dependencies:   SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2_ILI9341 mbed

Fork of CANary_corrupt by Tick Tock

After adding the LPC1768 platform, import as a program and do not select the "update to latest revision" box

User Guide

Eagle Schematic and Board design

/media/uploads/TickTock/canaryr6.zip

/media/uploads/TickTock/canary_sch.jpg

/media/uploads/TickTock/canaryr6brd.jpg

For LCD Rev 1.01:

/media/uploads/TickTock/lcdsch.jpg

For VCD Rev 2.00:

/media/uploads/TickTock/lcdr2.jpg

Parts List

qtyinstancepart #packagesupplierDescription
1BAT3Vhttp://www.ebay.com/itm/10x-CR2032-SMD-Battery-Holder-for-CR2032-Battery-/180938057979?pt=LH_DefaultDomain_0&hash=item2a20bfa8fbLithium 2032 coin battery holder
4C1-C4ECST1DC106R6032Tantalium capacitor 10uF
3FC1-FC3ZF1-20-01-T-WThttp://www.samtec.com/cable-systems/idc-ffc/ffc/zero-insertion.aspx20 conductor 1mm pitch flex cable connector (optional)
1FJ-20-R-08.00-4http://www.samtec.com/cable-systems/idc-ffc/ffc/zero-insertion.aspx8\" 20 conductor 1mm pitch flex connector, end reversed (optional)
2H1-H4(DON'T populate H1-H4 headers - solder mbed directly)
1H5http://www.ebay.com/itm/221186042943?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l26491x12 .1\" pitch header (optional)
1H62x6 .1\" pitch header (optional)
2IC1,IC2VP230LMDSOP8http://www.ebay.com/itm/130488665247?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649canbus transciever
1IC3LM1117-5VSOT2235V regulator
5JP*2 pin .1\" jumper header
1mbedLPC1768http://www.ebay.com/itm/200830573509?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649mbed uC
2Q1,Q22N2222SOT23General purpose NPN transistor
1R1R393M120639K resistor
1R2R103M120610K resistor
4R4-R6R102M12061K resistor
1R3R500M120650 Ohm resistor
2TR1-TR5ZJYS81R5-2PL51TG01http://www.digikey.com/product-detail/en/ZJYS81R5-2PL51T-G01/445-2223-1-ND/765232CM Choke
1Z11N5340BGC1702-15http://www.ebay.com/itm/150878122425?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l26496V, 5W Zener Diode
1Z1DC-DC conveterhttp://www.ebay.com/itm/251142727849?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l264912V-7V, 3W DC-DC converter
1X1USBhttp://www.ebay.com/itm/New-Vertical-USB-2-0-A-pcb-connector-socket-USB-A-Type-/300553895292?pt=LH_DefaultDomain_0&hash=item45fa687d7cvertical USB connector
2LCD0,LCD1TFThttp://www.mikroe.com/add-on-boards/display/tft-proto/320x240 LCD with touch screen
1E0Enclosurehttp://www.shapeways.com/model/1077799/canary.html?li=user-profile&materialId=63d printed enclosure

Assembly

1) LCD Displays

I found ribbon cable is a nice way to organize the wires to the displays. There are two versions of the display and each must be wired differently. The original project used HW REV. 1.01. For that version, you'll need 12 conductors and I connected them in the following order:

1LED+
2LED-
3RST
4SDI
5WR/SCLK
6CS
7X+
8X-
9Y+
10Y-
11VDD
12GND

If, instead, you have HW REV 2.0, you will need 13 conductors with the following order:

1LED+
2LED-
3RST
4SDI
5RS (SCLK)
6WR (DC)
7CS
8X+
9X-
10Y+
11Y-
12VDD
13GND

First I connected all the GND connections (2 GND & IM0, IM1, IM3 for REV1.01 or 2 GND, RD, & IM0 for REV2.00). Do not connect the bottom GND until you have the ribbon cable connected. After making all the ribbon cable connections (connecting the GND of the ribbon cable to the bottom GND pad), solder the GND bar from the previous step to the back of the bottom GND connection. Finally, make a connection from the back side 3.3V pin to IM2 for REV1.01 or to IM1,IM2,&IM3 for REV2.00. Take a break and repeat for the second display.

Examples of REV1.01 boards:

/media/uploads/TickTock/lcdtop.jpg /media/uploads/TickTock/lcdbot.jpg

Examples of REV2.00:

/media/uploads/TickTock/rev2front.jpg /media/uploads/TickTock/rev2back.jpg

Once the two displays are complete combine all wires except CS0, CS1, X+, X-, Y+, and Y-. Connect X- of the left display to X+ of the right. Similarly connect Y- of the left display to Y+ of the right. Insulate any exposed wires.

2) PCB

Refer to the schematics to place all the components on the board. If you plan to install into the CANary 3D enclosure, DO NOT install the battery holder or the socket for the mbed and, instead, connect two wires to the VB and GND pads nearby. You will have to install the battery holder against the back wall to avoid interfering with the right-hand display and the mbed will have to be directly soldered. I have not found a socket with a low enough profile to fit in the space provided (depth of enclosure is limited by the space behind the center console). Also, I recommend keeping as much lead as possible on the Zener diode (bending it as shown to clear the back wall). Although it is operating well within parameters, the Zener gets quite hot during extended operation and the leads help dissipate the heat and keep it away from the PCB and other components.Update: Several Zeners have failed resulting in damage to some users boards so I recommend using a DC-DC converter instead to bring the 12V down to 7V.

/media/uploads/TickTock/pcbtop.jpg /media/uploads/TickTock/pcbbot.jpg

Once the PCB is populated, solder the LCDs to the PCB. CS0 connects to the right display and CS1 connects to the left. /media/uploads/TickTock/brddis.jpg

Update: The Zener diodes tended to fail after a few months so I am recommending removing them and replacing with a DC-DC converter. This will run cooler and waste less energy, too. To install, remove the left display panel to gain access to the Zener. From there, the Zener can be removed and it's pads used to connect to the DC-DC converter. I recommend setting the output voltage on the bench before installing since the trim pot is tricky to reach once installed. Set it to 7V. The input can be connected to the left pad previously occupied by the zener and the output can connect to the right. GND(-) can be connected to the bottom right pad on the 2x6 header below the flex cable connector. Make sure the GND wire lies flat so it doesn't interfere with the connection of the flex cable. /media/uploads/TickTock/dcdcinst2.jpg

Once soldered in place, the DC-DC converter can easily be mounted to the back wall with double sided tape above the battery holder. /media/uploads/TickTock/dcdcinst3.jpg

3) Testing

1)First step is to buzz out all connections from the LCDs to the pins in the main board
2)Next check the touch screen connections. On the main board, place an Ohm meter across X+ and X-. You should read 700 Ohms. Repeat for Y+ and Y-. Then test the resistance from X+ to Y+. With nothing touching the screens, it should read >100K Ohms and <1K when touching either screen.
3)When all connections are checked, solder in the mbed. Download and install the touch2 program http://mbed.org/users/TickTock/code/touch2/ to test the basic operation of the mbed and touch screens.
tips:
Touch screen is sensitive - excess flux on X+,X-,Y+,Y- connection on mbed can result in flakey operation
If touch is not working, double-check the LCD0_CS and LCD1_CS are not swapped. LCD0_CS must connect to the CS of the LCD that has X- & Y- connected to the mbed. LCD1_CS must connect to the CS of the LCD that has X+ & Y+ connected to the mbed.
4)Once touch2 works, it is time to connect to the OBD connector. I highly recommend double checking all connections from the OBD to the PCB with the cable in place before connecting to the Leaf. Buzz out all the pins in the OBS to make sure none are shorting to each other, Check that the 12V goes to the Zener (and nothing else) and the switched 12V to the resistor divider (and nothing else). Test the ground connection properly connects to ground and nothing else.
5)Once you are confident there are no shorts or wrong connections from the OBD connector, take a deep breath and plug it into your leaf. Touch2 program should come up and function. Unplug and install the latest CANary firmware. If you have the REV2.00 LCD boards, you will need to edit the precompile.h file in the TOUCH_TFTx2_w9341 library and set USE_ILI9341 to 1. Test all features before installing into the enclosure (gids, cellpair, menu system, logging) since installing and removing from the enclosure is a PITA.

/media/uploads/TickTock/pcbdone.jpg /media/uploads/TickTock/functioning.jpg

4) Enclosure

The 3D printer leaves a lot of powder behind - I used a strong spray of water to get it out of all the cracks. The enclosure comes with a rather rough finish. I recommend convincing yourself you like it, then simply lightly sand then paint before assembly. Sanding is very difficult - the nylon is very nicely fused and doesn't want to sand. I tried sandblasting and that didn't work either. I had some limited success with filler and then sanding, but only on the outside - it is too difficult to sand the face. /media/uploads/TickTock/enclosure.jpg

5) Final Assembly

Make sure you are well rested with lots of patience before attempting assembly. It is a puzzle figuring out how to get both displays and the PCB in place. Enclosure was too expensive for me to keep iterating to optimize for assembly. I ended up snipping the thin display posts shorter and using various tools to push the displays into place. Also, some USB connectors are taller than others. If you have one of the taller ones, you will have to deflect the back wall a bit while inserting the PCB (being careful not to bend the housing) to get it to it's opening in the back wall. Do use a screw in the provided post to secure the PCB as USB insertion will otherwise dislodge it.

I added an additional safety line which wraps around the center post to prevent the enclosure from becoming a projectile in the event of an accident. /media/uploads/TickTock/safety.jpg Installed: /media/uploads/TickTock/installed.jpg

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();