Dual CANbus monitor and instrumentation cluster
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed
Fork of CANary by
Revision 79:68f0dd8d1f19, committed 2013-04-16
- Comitter:
- TickTock
- Date:
- Tue Apr 16 22:31:47 2013 +0000
- Parent:
- 78:a383971fe02f
- Commit message:
- Just turn on the message-send ticker when actually sending (instead of continuously triggering).
Changed in this revision
--- a/displayModes.cpp Tue Apr 16 13:01:13 2013 +0000 +++ b/displayModes.cpp Tue Apr 16 22:31:47 2013 +0000 @@ -768,6 +768,7 @@ void dteDisplay(bool force, bool showButtons, bool showMiles){ unsigned short i,x,y,lx,ly,gids,radius,color,r,t; + unsigned char toVal; static unsigned short lgids=0; static unsigned char leff[39]={0}; CANMessage msg; @@ -778,13 +779,16 @@ msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids gids = (msg.data[0]<<2)+(msg.data[1]>>6); if(gids==0){ - gids=281; + gids=281; // Display new, fuily charged capacity until real data obtained } tt.background(Navy); tt.foreground(Yellow); if(force){ tt.cls(); + toVal=33; + } else { + toVal=18;// no need to constantly update the long tc values } if(force||lgids!=gids){ tt.set_font((unsigned char*) Arial12x12); @@ -865,7 +869,7 @@ } if(dtePeriod==0){ radius=6; - color=Magenta; + color=Yellow; }else{ radius=2; color=Green; @@ -873,7 +877,7 @@ tt.fillcircle(lx,leff[0],radius,Navy); tt.fillcircle(lx,ly,radius,color); - for(i=1;i<33;i++){ + for(i=1;i<toVal;i++){ x=50+i*6; y=mpkWh[i]*20; if(y<200) { @@ -882,8 +886,8 @@ y=0; } if(i==dtePeriod){ - radius=4; - color=Magenta; + radius=6; + color=Yellow; }else{ radius=2; color=Green;
--- a/main.cpp Tue Apr 16 13:01:13 2013 +0000 +++ b/main.cpp Tue Apr 16 22:31:47 2013 +0000 @@ -51,7 +51,7 @@ // gg - revStr is used in 2 places // gg - and is easy to edit here // gg - added ZeroSecTick and revStr -char revStr[7] = "78"; +char revStr[7] = "79"; bool logEn = false, logOpen = false; bool yesBattLog = false ; // gg - Batt Log @@ -226,7 +226,7 @@ readConfig(); // Start 15ms timer for requests - msgReq.attach(&sendReq,0.015); + //msgReq.attach(&sendReq,0.015); // Start monitors can1.monitor(true); // set to snoop mode @@ -422,10 +422,13 @@ dMode[whichTouched] = brakeScreen ; // GoTo Brake Screen } else if (dMode[whichTouched]==cpScreen) { reqMsgCnt=0; + msgReq.attach(&sendReq,0.015); } else if (dMode[whichTouched]==cpHistScreen) { // gg - hist reqMsgCnt=0; + msgReq.attach(&sendReq,0.015); } else if (dMode[whichTouched]==cpBarScreen) { // gg - cpbars reqMsgCnt=0; + msgReq.attach(&sendReq,0.015); } else if (dMode[whichTouched]==config1Screen) { mbed_reset(); } else if (dMode[whichTouched]==playbackScreen) { // pause/unpause
--- a/utility.cpp Tue Apr 16 13:01:13 2013 +0000 +++ b/utility.cpp Tue Apr 16 22:31:47 2013 +0000 @@ -135,6 +135,7 @@ 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 @@ -190,36 +191,37 @@ case 0: can1.monitor(false); // set to active mode can1SleepMode = 0; // enable TX - data[0]=0x02; //change to request frame 1 + data[0]=0x02; //change to request group 1 data[1]=0x21; data[2]=0x01; break; - case 6: // frame 1 has 6 lines + case 6: // group 1 has 6 frames can1.monitor(false); // set to active mode can1SleepMode = 0; // enable TX - data[0]=0x02; //change to request frame 2 (cp data) + data[0]=0x02; //change to request group 2 (cp data) data[1]=0x21; data[2]=0x02; break; - case 35: // frame 2 has 29 lines - data[0]=0x02; //change to request frame 3 + case 35: // group 2 has 29 frames + data[0]=0x02; //change to request group 3 data[1]=0x21; data[2]=0x03; break; - case 40: // frame 3 has 5 lines - data[0]=0x02; //change to request frame 4 (temperature) + case 40: // group 3 has 5 frames + data[0]=0x02; //change to request group 4 (temperature) data[1]=0x21; data[2]=0x04; break; - case 43: // frame 4 has 3 lines - data[0]=0x02; //change to request frame 5 + case 43: // group 4 has 3 frames + data[0]=0x02; //change to request group 5 data[1]=0x21; data[2]=0x05; break; - case 54: // frame 5 has 11 lines + case 54: // group 5 has 11 frames reqMsgCnt = 99; can1SleepMode = 1; // disable TX can1.monitor(true); // set to snoop mode + msgReq.detach(); // stop ticker default: data[0]=0x30; //change to request next line message data[1]=0x01; @@ -278,6 +280,7 @@ void autoPollISR(){ reqMsgCnt = 0; //reset message counter + msgReq.attach(&sendReq,0.015); } void playbackISR() { //Used for autoplayback step=true;
--- a/utility.h Tue Apr 16 13:01:13 2013 +0000 +++ b/utility.h Tue Apr 16 22:31:47 2013 +0000 @@ -1,12 +1,12 @@ // utility.h -//#include "mbed.h" #include "CAN.h" #include "common.h" #include "TOUCH_TFTx2.h" #include "beep.h" extern Timer timer; +extern Ticker msgReq; extern volatile unsigned short secsNoMsg; extern volatile unsigned short secsNoTouch; extern volatile bool canIdle;