test fork
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Diff: main.cpp
- Revision:
- 150:ef46ce63345c
- Parent:
- 149:e9739523109f
- Child:
- 151:3047ebb3c9a8
--- a/main.cpp Wed Sep 25 03:33:18 2013 +0000 +++ b/main.cpp Fri Sep 27 04:43:41 2013 +0000 @@ -12,11 +12,11 @@ // * 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 efficiency reset - +// * Add trip max/min efficiency reset -// rev149 -// Added temperature compensation for efficiency/DTE computation +// rev150 +// Added user message Id's to the config file +// Added copy of ehist.cny to USB on config save and load if present on firmware update #include "mbed.h" #include "CAN.h" @@ -27,7 +27,7 @@ #include "utility.h" #include "displayModes.h" #include "TOUCH_TFTx2.h" -char revStr[7] = "149"; // gg - revision string, max 6 characters +char revStr[7] = "150"; // gg - revision string, max 6 characters FATFS USBdrive; LocalFileSystem local("local"); @@ -133,7 +133,6 @@ float mph[39]={0}; float kW[39]={0}; float mpkWh[39]={0}; -float ambient_F; float unloadedV_x2,Resr,curRmax,curRmin,redRmax,redRmin,incRmax,incRmin; signed short Imax, Imin; // Logarithmic division scale (roughly - snapped to common units of time) @@ -156,8 +155,7 @@ unsigned char saveDmode=99; bool moving=false; unsigned short chirpInt; -unsigned short uMsgId[8] = {0x5103, 0x50a3, 0x54a4, 0x54b4, 0x54c0, 0x55b4, 0x0000, 0x0000}; // messages to display on debug screen msgId:byte -float nomDrag; +unsigned short uMsgId[8] = {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}; // messages to display on debug screen msgId:byte int main() { char sTemp[40]; @@ -205,9 +203,7 @@ printMsg(sTemp); // revision //read efficiency history data - if(!tt.is_touched()){ //skip if screen touched (reset efficiency) - hfile = fopen("/local/ehist.cny", "r"); - } + hfile = fopen("/local/ehist.cny", "r"); if (hfile!=NULL){ // found a efficiency history file for(i=0;i<39;i++){ if(!feof(hfile)){ @@ -229,8 +225,6 @@ mpkWh[i]=4; } } - - nomDrag = airDrag(77); // Compute drag coefficient for 25C // Read config file readConfig(); @@ -713,7 +707,6 @@ if(tick){ // Executes once a second tick=false; - ambient_F = lastMsg[indexLastMsg[0x54c]].data[6]-56; curEff = miles_trip[0]/kWh_trip[0]; headlights = (lastMsg[indexLastMsg[0x358]].data[1]&0x80)?true:false; // headlight/turn signal indicator if(accOn&&indexLastMsg[0x355]>0){ @@ -810,7 +803,7 @@ if(numWsamples>0){ // Avoid div0 mpkWh[0]=mph[0]; - kW[0]=((float) mWs_x4)/numWsamples/4e3; + kW[0]=((float) mWs_x4)/numWsamples/4e3; mpkWh[0]/=kW[0]; if (mpkWh[0]<0) { mpkWh[0]=99;// negative means inf. @@ -819,8 +812,6 @@ kW[0]=0; mpkWh[0]=0; } - // TOTest: Normalize kW[0] to 25C (after computing mpkWh[0]) - kW[0]=kW[0]/airDrag(ambient_F)*nomDrag; numWsamples=0; if (!charging){