Dual CANbus monitor and instrumentation cluster

Dependencies:   SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed

Fork of CANary by Tick Tock

Branch:
Metric
Revision:
123:a8c0042df617
Parent:
122:138a40892a4c
Child:
124:0d622967b764
--- a/main.cpp	Wed Jul 17 13:48:51 2013 +0000
+++ b/main.cpp	Fri Jul 19 12:48:10 2013 +0000
@@ -10,6 +10,7 @@
 // * Change semilog efficiency graph to linear with 10 minute values
 // * Add additional 79b bank readouts
 // * Add ability to transfer settings config file to/from USB
+// * Is CAN/EV designator reversed in canlog?
 
 #include "mbed.h"
 #include "CAN.h"
@@ -21,7 +22,7 @@
 #include "displayModes.h"
 #include "TOUCH_TFTx2.h"
 
-char revStr[7] = "122"; // gg - revision string, max 6 characters
+char revStr[7] = "123"; // gg - revision string, max 6 characters
 
 FATFS USBdrive;
 LocalFileSystem local("local");
@@ -68,7 +69,7 @@
 char indexLastMsg[0x800]={0}; // index table for last message
 CANMessage lastMsg[100]; // table to store last message of eachtype
 
-unsigned char battData[BatDataBufMax]={0}; // 7 * 0x3D = BatDataBufMax
+unsigned char queryData[DataBufMax]={0}; // 7 * 0x3D = DataBufMax
 
 unsigned char msgChanged[100]; // inidcates which bytes changed
 char c;
@@ -139,13 +140,14 @@
 bool metric = false;
 bool shunt[96]={0};
 bool charging=false;
-
+bool reqRest=false;
 int main() {
     //can1SleepMode.mode(OpenDrain);
     //can2SleepMode.mode(OpenDrain);
     char sTemp[40];
     unsigned long secs;
     unsigned char i,j,display=0,lwt=0;
+    char reqData[8] = {0x30, 0x00, 0x18, 0xff, 0xff, 0xff, 0xff, 0xff};
     point lastTouch;
     float average;
     tt.set_orientation(1);
@@ -331,7 +333,8 @@
                 logTS(); // Date-Time at wakeup
             }
             if (repeatPoll) { // re-enable autopolling if enabled
-                autoPoll.attach(&autoPollISR,pollInt);
+                //autoPoll.attach(&autoPollISR,pollInt);
+                autoPoll.attach(&autoPollISR,10);
             }
         } // if idle
         
@@ -418,13 +421,13 @@
                                     dMode[whichTouched] = brakeScreen ; // GoTo Brake Screen
                                 } else if (dMode[whichTouched]==cpScreen) {
                                     reqMsgCnt=0;
-                                    msgReq.attach(&sendReq,0.015);
+                                    msgReq.attach(&sendReq,0.035);
                                 } else if (dMode[whichTouched]==cpHistScreen) { // gg - hist
                                     reqMsgCnt=0;
-                                    msgReq.attach(&sendReq,0.015);
+                                    msgReq.attach(&sendReq,0.035);
                                 } else if (dMode[whichTouched]==cpBarScreen) { // gg - cpbars
                                     reqMsgCnt=0;
-                                    msgReq.attach(&sendReq,0.015);
+                                    msgReq.attach(&sendReq,0.035);
                                 } else if (dMode[whichTouched]==configScreen) {
                                     mbed_reset();
                                 } else if (dMode[whichTouched]==playbackScreen) { // pause/unpause
@@ -668,6 +671,15 @@
             }
         }
 
+        if (reqRest){
+            reqRest=false;
+            if (reqMsgCnt<DataBaseG7){
+                can1.write(CANMessage(0x79b, reqData, 8));
+            }else{
+                can1.write(CANMessage(0x745, reqData, 8));
+            }
+        }
+
         if(tick){ // Executes once a second
             tick=false;
             headlights = (lastMsg[indexLastMsg[0x358]].data[1]&0x80)?true:false;  // headlight/turn signal indicator
@@ -705,7 +717,7 @@
                 if (repeatPoll&&(wait5secs==0)) { // Poll on startup if autopoll enabled
                     logOnce=true;
                     reqMsgCnt=0;
-                    msgReq.attach(&sendReq,0.015);
+                    msgReq.attach(&sendReq,0.035);
                 }
             }