test fork

Dependencies:   SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed

Fork of CANary_9341 by Tick Tock

Files at this revision

API Documentation at this revision

Comitter:
TickTock
Date:
Sun Jul 21 11:23:57 2013 +0000
Branch:
Metric
Parent:
125:f58b7ab2abee
Parent:
79:68f0dd8d1f19
Child:
127:27c739fd6d71
Commit message:
attempt to restore default;

Changed in this revision

displayModes.cpp 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/displayModes.cpp	Sun Jul 21 11:08:38 2013 +0000
+++ b/displayModes.cpp	Sun Jul 21 11:23:57 2013 +0000
@@ -986,7 +986,11 @@
     msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids
     gids = (msg.data[0]<<2)+(msg.data[1]>>6);
     if(gids==0){
+<<<<<<< local
         gids=281; // Display new, fully charged capacity until real data obtained
+=======
+        gids=281; // Display new, fuily charged capacity until real data obtained
+>>>>>>> other
     }
 
     tt.background(Navy);
@@ -994,6 +998,26 @@
     if(force){
         tt.set_font((unsigned char*) Arial12x12);   
         tt.cls();
+<<<<<<< local
+=======
+        toVal=33;
+    } else {
+        toVal=18;// no need to constantly update the long tc values
+    }
+    if(force||lgids!=gids){
+        tt.set_font((unsigned char*) Arial12x12);
+        for(i=0;i<10;i++){
+            y=200-i*20;
+            tt.locate(10,y-8);
+            if (showMiles){
+                printf("%3.0f\n",i*((float)(gids-5)*.075));
+            }else{
+                printf("%d.0\n",i);
+            }
+            tt.line(40,y,254,y,DarkGrey);
+        }
+
+>>>>>>> other
         x=50+0*6;
         tt.locate(x-10,226);
         printf("sec\n");  
--- a/main.cpp	Sun Jul 21 11:08:38 2013 +0000
+++ b/main.cpp	Sun Jul 21 11:23:57 2013 +0000
@@ -51,12 +51,20 @@
 PwmOut dled(p23);
 Beep spkr(p21);
 
+<<<<<<< local
 bool debugMode = false;
 bool usbEn = false;
 bool logEn = true;
 bool logOpen = false; 
 bool yesBattLog = true; // gg - Batt Log
 unsigned char tNavRow = 3; // gg - 4x4 touch
+=======
+// revision string, max 6 characters
+// gg - revStr is used in 2 places
+// gg - and is easy to edit here
+// gg - added ZeroSecTick and revStr
+char revStr[7] = "79";
+>>>>>>> other
 
 FILE *hfile; // history file
 FIL efile; // external usb file
@@ -205,10 +213,17 @@
 
     // Read config file
     readConfig();
+<<<<<<< local
     if (repeatPoll) { // enable autopolling if enabled
         autoPoll.attach(&autoPollISR,pollInt);
     }
     
+=======
+
+    // Start 15ms timer for requests
+    //msgReq.attach(&sendReq,0.015);
+
+>>>>>>> other
     // Start monitors
     can1.monitor(true); // set to snoop mode
     can2.monitor(true); // set to snoop mode
@@ -424,7 +439,11 @@
                                 } else if (dMode[whichTouched]==cpBarScreen) { // gg - cpbars
                                     reqMsgCnt=0;
                                     msgReq.attach(&sendReq,0.015);
+<<<<<<< local
                                 } else if (dMode[whichTouched]==configScreen) {
+=======
+                                } else if (dMode[whichTouched]==config1Screen) {
+>>>>>>> other
                                     mbed_reset();
                                 } else if (dMode[whichTouched]==playbackScreen) { // pause/unpause
                                     playbackEn=!playbackEn;
--- a/utility.cpp	Sun Jul 21 11:08:38 2013 +0000
+++ b/utility.cpp	Sun Jul 21 11:23:57 2013 +0000
@@ -352,6 +352,53 @@
             motorRPM+=imotorRPM;
             numSsamples++;
         }
+<<<<<<< local
+=======
+        if(bdi<0xff){
+            i=canRXmsg.data[0]&0x0f; //lower nibble of D0 is index
+            if(lasti>i){ //detect rollover and offset index appropriately
+                bdi=0x10;
+            }
+            lasti=i; //remember the msb to detect rollover next time around
+            i+=bdi;
+            //if(i==22) logCP=true; //Turbo3
+            //if( (i==22) && (yesBattLog) ) logCP=true; // only if enabled gg - Batt Log 
+            if(i==22){
+                logCP=yesBattLog; // Only log if logging enabled
+                showCP=true; // Always show
+            }
+            i*=7;
+            if(i<0xfa){ // Is there a better way to do this?
+                battData[i+0]=canRXmsg.data[1];
+                battData[i+1]=canRXmsg.data[2];
+                battData[i+2]=canRXmsg.data[3];
+                battData[i+3]=canRXmsg.data[4];
+                battData[i+4]=canRXmsg.data[5];
+                battData[i+5]=canRXmsg.data[6];
+                battData[i+6]=canRXmsg.data[7];
+            }
+        }
+    }else if((mType==1)&&(canRXmsg.id==0x1db)){ //Battery Volts and Amps
+        packV=((canRXmsg.data[2]<<2)|(canRXmsg.data[3]>>6)); // 1 LSB = 0.5V
+        packA=((canRXmsg.data[0]<<3)|(canRXmsg.data[1]>>5)); // 1 LSB = 0.5A
+        if(packA>0x03ff){
+            packA|=0xf800;//extend sign;
+        }
+        packA -= 1; //Slight correction to value required (unique to my Leaf?)
+        imWs_x4 = packV; // Volts*milliSeconds*2
+        imWs_x4 *= -packA; // milliWattseconds*4
+        if (!((imotorRPM<2)&&(imWs_x4<0))){ //Ignore if charging from wall
+            mWs_x4 += imWs_x4; // total mWs_x4
+            numWsamples++;
+        }
+    }else if((mType==1)&&(canRXmsg.id==0x1da)){ //Motor Speed
+        imotorRPM=((canRXmsg.data[4]<<8)|(canRXmsg.data[5]));
+        if(imotorRPM<0){ // take absolute value
+            imotorRPM=-imotorRPM;
+        }
+        motorRPM+=imotorRPM;
+        numSsamples++;
+>>>>>>> other
     }
 }
 
@@ -399,32 +446,54 @@
                 data[1]=0x21;
                 data[2]=0x01;
                 break;
+<<<<<<< local
             case BatDataBaseG2: // group 1 has 6 frames
+=======
+            case 6: // group 1 has 6 frames
+                can1.monitor(false); // set to active mode
+                can1SleepMode = 0; // enable TX
+>>>>>>> other
                 data[0]=0x02; //change to request group 2 (cp data)
                 data[1]=0x21;
                 data[2]=0x02;
                 break;
+<<<<<<< local
             case BatDataBaseG3: // group 2 has 29 frames
+=======
+            case 35: // group 2 has 29 frames
+>>>>>>> other
                 data[0]=0x02; //change to request group 3
                 data[1]=0x21;
                 data[2]=0x03;
                 break;
+<<<<<<< local
             case BatDataBaseG4: // group 3 has 5 frames
+=======
+            case 40: // group 3 has 5 frames
+>>>>>>> other
                 data[0]=0x02; //change to request group 4 (temperature)
                 data[1]=0x21;
                 data[2]=0x04;
                 break;
+<<<<<<< local
             case BatDataBaseG5: // group 4 has 3 frames
+=======
+            case 43: // group 4 has 3 frames
+>>>>>>> other
                 data[0]=0x02; //change to request group 5
                 data[1]=0x21;
                 data[2]=0x05;
                 break;
+<<<<<<< local
             case BatDataBaseG6: // group 4 has 3 frames
                 data[0]=0x02; //change to request group 5
                 data[1]=0x21;
                 data[2]=0x06;
                 break;
             case BatDataBaseG7: // group 5 has 11 frames
+=======
+            case 54: // group 5 has 11 frames
+>>>>>>> other
                 reqMsgCnt = 99;
                 can1SleepMode = VP230Sleep; // disable TX
                 can1.monitor(true); // set to snoop mode
@@ -447,6 +516,38 @@
     msgReq.attach(&sendReq,0.015);
 }
 
+<<<<<<< local
+=======
+void sendTreq() {
+    char i;
+    char data[8] = {0x02, 0x21, 0x04, 0xff, 0xff, 0xff, 0xff, 0xff};
+    can1.monitor(false); // set to active mode
+    can1SleepMode = 0; // enable TX
+    can1.write(CANMessage(0x79b, data, 8));
+    
+    if( ZeroSecTick ) { ZeroSecTick = false; logTS(); } // gg - 0-second EV bus
+    
+    logCan(1,CANMessage(0x79b, data, 8)); // Group 4 request on EV
+    data[0]=0x30; //change to request next line message
+    data[1]=0x01;
+    data[2]=0x00;
+    for(i=0;i<3;i++){
+        wait_ms(16); //wait 16ms
+        can1.write(CANMessage(0x79b, data, 8));
+    }
+    can1SleepMode = 1; // disable TX
+    can1.monitor(true); // set to snoop mode
+}
+
+void autoPollISR() {  //This is the ticker ISR for auto-polling
+    pollCP=true;    //Set a flag to do in main loop instead of here
+}                   //since ticker blocks other interrupts*/
+
+void autoPollISR(){
+    reqMsgCnt = 0; //reset message counter
+    msgReq.attach(&sendReq,0.015);
+}
+>>>>>>> other
 void playbackISR() { //Used for autoplayback
     step=true;
 }