Dual CANbus monitor and instrumentation cluster
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed
Fork of CANary by
Diff: main.cpp
- Revision:
- 31:082372c83f68
- Parent:
- 30:e633a63eb257
- Child:
- 32:c9d9b6cb5de1
--- a/main.cpp Sat Mar 16 16:33:11 2013 +0000 +++ b/main.cpp Sun Mar 17 12:17:33 2013 +0000 @@ -65,7 +65,8 @@ volatile bool userIdle; bool touched=false; //flag to read touchscreen char counter = 0; -unsigned char dMode[2] = {dteScreen,brakeScreen}; //display mode +//unsigned char dMode[2] = {dteScreen,brakeScreen}; //display mode +unsigned char dMode[2] = {cpScreen,logScreen}; //display mode unsigned char sMode = 0; // setup mode unsigned char lastDMode[2] = {0,0}; //last screen mode unsigned char dtMode = 6; @@ -73,7 +74,9 @@ unsigned char displayLoc = 0; unsigned char indexOffset = 1; bool showCP = false; -bool pollCP = false; +bool tick16 = false; +unsigned char CPcount = 99; +unsigned char Tcount = 99; int main() { int readPointer=0; @@ -105,7 +108,8 @@ struct tm t; // pointer to a static tm structure NVIC_SetPriority(TIMER3_IRQn, 1); //set ticker priority NVIC_SetPriority(CAN_IRQn, 2); //higher than can (so RTC sync works) - + //ticker.attach(&tickerISR, 0.016); //send commands at 16ms rate + ticker.attach(&msgSend, 0.016); //send commands at 16ms rate seconds = time(NULL); t = *localtime(&seconds) ; @@ -293,7 +297,10 @@ for(j=0;j<100;j++) msgChanged[j]=0; // clear changed data lastDMode[i]=99;//force refresh } else if (dMode[i]==cpScreen) { - pollCP=true; + if (Tcount>3){ + CPcount=0; //reset CP message counter + Tcount=0; //reset Temp message counter + } } else if (dMode[i]==config1Screen) { mbed_reset(); } @@ -365,15 +372,13 @@ } } - if(pollCP){ // We do this inside main loop instead of ticker so CAN RX will not be blocked - sendCPreq(); // send cellpair data request. - wait_ms(16); - sendTreq(); //send temperature request - wait_ms(16); - pollCP=false; - showCP=true; - } - display=display<1?display+1:0; // toggle display - updateDisplay(display); + if (Tcount>4){ + display=display<1?display+1:0; // toggle display + updateDisplay(display); + }/* else if(tick16){ // We do this inside main loop instead of ticker so CAN RX will not be blocked + msgSend(); + tick16=false; + }*/ + } //while (true) } \ No newline at end of file