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:
- 152:a4d66901785d
- Parent:
- 151:3047ebb3c9a8
- Child:
- 153:e94cfe3c339c
--- a/main.cpp Mon Sep 30 15:31:01 2013 +0000 +++ b/main.cpp Sun Oct 06 14:49:09 2013 +0000 @@ -1,21 +1,21 @@ // main.cpp // //To Do: -// * User-configurable watchpoint // * Add 50% charge option // * Add coasting regen to regen/braking display -// * Change semilog efficiency graph to linear with 10 minute values +// * Add linear efficiency graph with 10 minute values // * Subtract accessory power from efficiency history (add back in when displaying) // * Add in-device config editor // * Store efficiency data at different temperatures // * Change pack volt color when CVLI fails -// * Add per-charge efficiency meter; add to triplop.txt // * Add tire pressure cal (40psi for me = FR 38, RR 38.2, FL 37.8, RL 38 - maybe 2psi error on my tire gauge?) // * Add heater activation warning message // * Add trip max/min efficiency reset +// * Add 2013 clock sync support -// rev151 -// added per_charge trip meter +// rev152 +// Added clock sync with car clock option (MY2011,2012 only) +// Fixed wrap bug in manual date update (january=00, not 01) #include "mbed.h" #include "CAN.h" @@ -26,7 +26,7 @@ #include "utility.h" #include "displayModes.h" #include "TOUCH_TFTx2.h" -char revStr[7] = "151"; // gg - revision string, max 6 characters +char revStr[7] = "152"; // gg - revision string, max 6 characters FATFS USBdrive; LocalFileSystem local("local"); @@ -64,6 +64,8 @@ bool yesBattLog = true; // gg - Batt Log unsigned char tNavRow = 3; // gg - 4x4 touch bool brakeMon = false; // disable until desired value read from config +bool autoSync = false; // auto clock sync on powerup +bool syncDone = true; FILE *hfile; // history file FIL efile; // external usb file @@ -155,6 +157,7 @@ bool moving=false; unsigned short chirpInt; unsigned short uMsgId[8] = {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; // messages to display on debug screen msgId:byte +unsigned short modelYear = 2011; int main() { char sTemp[40]; @@ -599,12 +602,10 @@ if (dMode[whichTouched]==configScreen) { // gg - Batt Log Enable Button debugMode = !debugMode; } else if (dMode[whichTouched] == indexScreen) { // gg - index - dMode[whichTouched] = configScreen ; // GoTo Config Screen - /*} else if (dMode[whichTouched] == tripScreen) { - miles_trip[1]=0; - kWh_trip[1]=0; - sMode=0; - lastDMode[whichTouched]=99;//repaint to clear highlight*/ + dMode[whichTouched] = configScreen ; // GoTo Config Screen + } else if ((dMode[whichTouched]==dateScreen)&&accOn){ + syncDateTime(); + lastDMode[whichTouched]=99; } else { lastDMode[whichTouched]=99;//repaint to clear highlight } @@ -655,6 +656,9 @@ lastDMode[whichTouched]=99;//repaint to clear highlight } else if (dMode[whichTouched] == indexScreen) { dMode[whichTouched] = tripScreen ; + } else if (dMode[whichTouched]==dateScreen){ + autoSync=!autoSync; // toggle autoSync mode + lastDMode[whichTouched]=99; } else { lastDMode[whichTouched]=99;//repaint to clear highlight } @@ -759,6 +763,7 @@ } dMode[0]=healthScreen; } + syncDone=!autoSync; // clear syncDone flag if autoSync enabled } laccOn=accOn; if(!accOn&&userIdle&&!playbackEn){ // Car off and no user activity - turn off screen @@ -880,6 +885,12 @@ lastDMode[1]=99; } } + if(!syncDone){ + if((lastMsg[indexLastMsg[0x5fa]].data[2]>>3>0)&&(lastMsg[indexLastMsg[0x5fa]].data[2]>>3<32)&&(lastMsg[indexLastMsg[0x5fc]].data[1]>>2<60)){ // sanity check result first + syncDateTime(); + syncDone=true; + } + } tock=true; } // tick