Attempts to merge SPI_TFT2 & SPI_TFT_ILI9341
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary by
Diff: main.cpp
- Revision:
- 153:e94cfe3c339c
- Parent:
- 152:a4d66901785d
- Child:
- 154:90ea16ca7475
--- a/main.cpp Sun Oct 06 14:49:09 2013 +0000 +++ b/main.cpp Sat Oct 12 03:48:30 2013 +0000 @@ -11,11 +11,10 @@ // * 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 -// rev152 -// Added clock sync with car clock option (MY2011,2012 only) -// Fixed wrap bug in manual date update (january=00, not 01) +// rev153 +// Added current reversal tone +// Added MY2013 autoSync support (just time - no date) #include "mbed.h" #include "CAN.h" @@ -26,7 +25,7 @@ #include "utility.h" #include "displayModes.h" #include "TOUCH_TFTx2.h" -char revStr[7] = "152"; // gg - revision string, max 6 characters +char revStr[7] = "153"; // gg - revision string, max 6 characters FATFS USBdrive; LocalFileSystem local("local"); @@ -158,6 +157,7 @@ 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; +bool idir, lidir; int main() { char sTemp[40]; @@ -708,6 +708,17 @@ } } + // Sound tone on power reversal + idir=(kW[0]>0)?true:false; + if(brakeMon){ + if (idir&&!lidir){ + spkr.beep(3200,0.03); // Started sinking current + }else if(!idir&&lidir){ + spkr.beep(800,0.03); // Started regen + } + lidir=idir; + } + if(tick){ // Executes once a second tick=false; curEff = miles_trip[0]/kWh_trip[0]; @@ -720,7 +731,6 @@ accOn=(accV>5)?true:false; moving=(mph[0]>0.1); charging=(lastMsg[indexLastMsg[0x5bf]].data[2]>0)?true:false; // FF when charging - //charging=!moving&&(kW[0]<-1); // not moving and generating energy so must be charging if (laccOn&&!accOn){ // Car turned off if (showHealth){ if (saveDmode==99){ @@ -886,10 +896,7 @@ } } 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; - } + syncDone=syncDateTime(); } tock=true; } // tick