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:
- 170:7ee98e3611bc
- Parent:
- 169:84d790ac18a2
- Child:
- 171:355e284f5201
diff -r 84d790ac18a2 -r 7ee98e3611bc main.cpp --- a/main.cpp Tue Dec 17 15:25:41 2013 +0000 +++ b/main.cpp Tue Dec 24 12:20:50 2013 +0000 @@ -11,9 +11,10 @@ // * Add climate control impact to main max/min dte and new trip display // * Be more efficient with write buffer (use msgLen instead of always storing 8 bytes) -// rev168 -// Added trip meter including climate control impact -// Pulled updateConfig to dedicated procedure +// rev170 +// Added kWperGid scalar to config file. .075 appears to be too small +// Added CCkWh_trip to TripLog (after kWh_trip) +// Added uncalibrated available regen bars to dte screen #include "mbed.h" #include "CAN.h" @@ -23,8 +24,8 @@ #include "utility.h" #include "displayModes.h" #include "TOUCH_TFTx2.h" -char revStr[7] = "168"; // gg - revision string, max 6 characters - +char revStr[7] = "170"; // gg - revision string, max 6 characters +unsigned long maxTarget = 1000; FATFS USBdrive; LocalFileSystem local("local"); unsigned char wait5secs = 5; @@ -78,6 +79,7 @@ char writeBuffer[maxBufLen][13] __attribute__ ((section("AHBSRAM1"))); // buffer for USB write char indexLastMsg[0x800]={0}; // index table for last message CANMessage lastMsg[100]; // table to store last message of eachtype +CANMessage msg; unsigned char battData[BatDataBufMax]={0}; // 7 * 0x3D = BatDataBufMax @@ -114,6 +116,8 @@ bool accOn = false; // Accessories on bool laccOn = false; float scale12V = 16.2; // R1:R2 ratio +float kWperGid = 0.080; +unsigned short startGids = 0; // Gids at start of trip signed long mWs_x4 = 0; unsigned short numWsamples = 0; unsigned short numSsamples = 0; @@ -892,6 +896,8 @@ msgReq.attach(&sendReq,0.015); lastDMode[0]=99; lastDMode[1]=99; + msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids + startGids=(msg.data[0]<<2)+(msg.data[1]>>6); } }