test fork
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Diff: main.cpp
- Revision:
- 160:905fe45ed54b
- Parent:
- 159:577e9d015693
- Child:
- 161:71ac85d11f03
--- a/main.cpp Fri Nov 08 16:07:53 2013 +0000 +++ b/main.cpp Wed Nov 20 13:13:54 2013 +0000 @@ -8,8 +8,11 @@ // * Change pack volt color when CVLI fails // * Add tire pressure cal (40psi for me = FR 38, RR 38.2, FL 37.8, RL 38 - maybe 2psi error on my tire gauge?) -// rev159 -// * Added heater activation warning message +// rev160 +// * Tweaked heater monitor to only issue once per power on/off +// * Added filtering to timeSync routing (some times set time to bogus value) +// * Removed debug wait commands from config save and firmware update +// * Added 3-tone sound messages #include "mbed.h" #include "CAN.h" @@ -19,7 +22,7 @@ #include "utility.h" #include "displayModes.h" #include "TOUCH_TFTx2.h" -char revStr[7] = "159"; // gg - revision string, max 6 characters +char revStr[7] = "160"; // gg - revision string, max 6 characters FATFS USBdrive; LocalFileSystem local("local"); @@ -120,7 +123,7 @@ bool step = false; char header[5]; char data[8]; -signed long motorRPM; +signed long motorRPM_x2; unsigned char skin = ttSkin ; unsigned char dtePeriod = 14; //ten minute averaging interval float kWh_trip[3]={0}; @@ -615,7 +618,7 @@ } else if (dMode[whichTouched] == indexScreen) { // gg - index dMode[whichTouched] = configScreen ; // GoTo Config Screen } else if ((dMode[whichTouched]==dateScreen)&&accOn){ - syncDateTime(); + syncDone=false; // initiate clock sync lastDMode[whichTouched]=99; } else { lastDMode[whichTouched]=99;//repaint to clear highlight @@ -744,10 +747,13 @@ curEff = 0; } headlights = (lastMsg[indexLastMsg[0x358]].data[1]&0x80)?true:false; // headlight/turn signal indicator - lHeaterOn = heaterOn; + if(heaterOn){ + lHeaterOn=true; // Only indicate heater once per power cycle + } heaterOn =((lastMsg[indexLastMsg[0x54f]].data[5]&0x3f)>0)?true:false; if(heaterMon && heaterOn && !lHeaterOn){ //Heat on alarm - beep(1600,0.5); + beep3(800,0.25,1200,0.25,1600,0.25); + //beep(1600,0.5); } if(accOn&&indexLastMsg[0x355]>0){ miles_kmbar = (lastMsg[indexLastMsg[0x355]].data[4]&0x20)?true:false; // indicates selected distance units @@ -758,6 +764,7 @@ moving=(mph[0]>0.1); charging=(lastMsg[indexLastMsg[0x5bf]].data[2]>0)?true:false; // FF when charging if (laccOn&&!accOn){ // Car turned off + lHeaterOn=false; if (showHealth){ if (saveDmode==99){ saveDmode=dMode[0]; @@ -791,6 +798,7 @@ } } if (!laccOn&&accOn){ // Car turned on + lHeaterOn=false; miles_trip[0]=0; kWh_trip[0]=0; wait5secs=5; @@ -834,7 +842,11 @@ //compute historic efficiency if(numSsamples>0){ // Avoid div0 - mph[0]=((float) motorRPM)/numSsamples/220; // Empirically derived with MXV4s - may change with different wheels&tires + // calibrated to dash mph which reads slightly fast. + // 227 would give more accurate mph for MXV4s@40psi - 11.75" distance from center of tire to pavement + // but then efficiency estimation would not track miles driven as read from the odometer so + // making CANary have the same error as the Leaf instrumentation + mph[0]=((float) motorRPM_x2)/numSsamples/220; } else { mph[0]=0; } @@ -868,7 +880,7 @@ kWh_trip[1]=0; } - motorRPM=0; + motorRPM_x2=0; mWs_x4=0; // Compute ESR