Dual CANbus monitor and instrumentation cluster supporting ILI9341 display controller
Dependencies: SPI_TFTx2_ILI9341 TOUCH_TFTx2_ILI9341 TFT_fonts mbed
Fork of CANary by
Diff: main.cpp
- Revision:
- 141:cf13a632ddb5
- Parent:
- 140:ab3e94eb0227
- Child:
- 142:c1a11d6f181c
diff -r ab3e94eb0227 -r cf13a632ddb5 main.cpp --- a/main.cpp Sun Aug 04 14:57:40 2013 +0000 +++ b/main.cpp Sun Aug 04 20:39:16 2013 +0000 @@ -10,10 +10,9 @@ // * Subtract accessory power from efficiency history (add back in when displaying) // * Add trip history display -// rev140 -// Added odometer to batt and trip log -// Added mi/km detection from dash -// Added audible brake monitor +// rev141 +// tweaked brakeMon sensitivity and threshold + #include "mbed.h" #include "CAN.h" @@ -24,7 +23,7 @@ #include "utility.h" #include "displayModes.h" #include "TOUCH_TFTx2.h" -char revStr[7] = "140"; // gg - revision string, max 6 characters +char revStr[7] = "141"; // gg - revision string, max 6 characters FATFS USBdrive; LocalFileSystem local("local"); @@ -62,7 +61,6 @@ bool yesBattLog = true; // gg - Batt Log unsigned char tNavRow = 3; // gg - 4x4 touch bool brakeMon = false; // disable until desired value read from config -unsigned char bp; FILE *hfile; // history file FIL efile; // external usb file @@ -79,8 +77,8 @@ char c; volatile int writePointer = 0; int readPointer=0; -volatile unsigned short secsNoCarCanMsg = 0; -volatile unsigned short secsNoEvCanMsg = 0; +volatile unsigned short secsNoCarCanMsg = canTimeout; +volatile unsigned short secsNoEvCanMsg = canTimeout; volatile unsigned short secsNoTouch = 0; volatile bool carCanIdle,evCanIdle,userIdle; bool touched=false; //flag to read touchscreen @@ -197,9 +195,6 @@ sprintf(sTemp,"CANary firmware rev%s\n", revStr); // gg - for Logging the revision printMsg(sTemp); // revision - secsNoCarCanMsg = 0; - secsNoEvCanMsg = 0; - //read efficiency history data hfile = fopen("/local/ehist.cny", "r"); if (hfile!=NULL){ // found a efficiency history file @@ -706,8 +701,10 @@ if(tick){ // Executes once a second tick=false; headlights = (lastMsg[indexLastMsg[0x358]].data[1]&0x80)?true:false; // headlight/turn signal indicator - miles_kmbar = (lastMsg[indexLastMsg[0x355]].data[4]&0x20)?true:false; // indicates selected distance units - metric = !miles_kmbar; + if(indexLastMsg[0x355]>0){ + miles_kmbar = (lastMsg[indexLastMsg[0x355]].data[4]&0x20)?true:false; // indicates selected distance units + metric = !miles_kmbar; + } accV=floor(mon12V*scale12V*10+0.5)/10; //Round to nearest 10th accOn=(accV>5)?true:false; moving=(mph[0]>0.1);