Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Revision 162:c6545fc0164a, committed 2013-11-21
- Comitter:
- TickTock
- Date:
- Thu Nov 21 23:08:00 2013 +0000
- Parent:
- 161:71ac85d11f03
- Child:
- 163:3b6fab958773
- Commit message:
- // Fixed efficiency screen discontinuity when CC power changes; // Added DTE & efficiency w/o CC to efficiency display
Changed in this revision
--- a/displayModes.cpp Thu Nov 21 14:17:35 2013 +0000
+++ b/displayModes.cpp Thu Nov 21 23:08:00 2013 +0000
@@ -809,7 +809,6 @@
} else { // Only compute judgement value if min cellpair meets <= 3712mV requirement
jv=0;
}
-
//------------------
tt.cls();
@@ -837,6 +836,18 @@
if( bd > iBinValMax ) bd = iBinValMax ;
nBin[bd]++ ;
}
+
+ //----------------
+ if( iBinValMax == 0 ) { // dummy data if no real data
+ min = 10 ;
+ max = 50 ;
+ avg = ( max + min ) / 2;
+ iBinValMax = max - min ;
+ for(int i=0; i<=(iBinValMax/2); i++) {
+ nBin[i] = i ;
+ nBin[iBinValMax-i] = i ;
+ }
+ }
// label the Y axis
tt.locate( 0, yWinMin ); printf("25\n");
@@ -878,7 +889,7 @@
// handle the button
if(sMode==1&&showButtons){
showButton(1,0,"Request","CP Data",4,4);
- }
+ }
}
//---------------
@@ -1088,7 +1099,6 @@
static unsigned char leff[39]={0};
CANMessage msg;
unsigned long targetBraking, regenBraking, temp;
- //static unsigned long maxTarget = 1000, maxRegen = 1000, tardivreg_x1000 = 1000;
static unsigned long maxTarget = 1000, tardivreg_x1000 = 1400;
static unsigned char lr=0, lt=0;
@@ -1124,17 +1134,10 @@
printf("mon\n");
tt.line(x,10,x,220,DarkGrey);
x=50+38*6;
- //tt.locate(x-10,226);
- //printf("year\n");
- //tt.line(x,10,x,220,DarkGrey);
- toVal=33;
- } else {
- toVal=24;// no need to constantly update the long tc values
- }
+ }
+ toVal=33;
if(force||lgids!=gids){ // update Y axis when kWh changes
tt.set_font((unsigned char*) Arial24x23);
- //for(i=0;i<10;i++){
- //y=200-i*20;
for(i=2;i<7;i++){
y=200-(i-2)*40;
tt.locate(0,y-8);
@@ -1183,15 +1186,26 @@
}
tt.foreground(Cyan);
tt.set_font((unsigned char*) Arial24x23);
- tt.locate(198,70);
- printf("%3.1f \n",mpkWh[dtePeriod]);
+ miles = mpkWh_noCC*((float)(gids-5)*.075);
+ miles = convertDistance(miles); // LM - Metric support
+ // Right justify
+ if (miles>99.9){ //space=13; num=17; . = 5
+ tt.locate(191,60);
+ printf("%4.1f\n",miles);
+ } else if (miles>9.9){
+ tt.locate(182,60);
+ printf(" %3.1f\n",miles);
+ } else {
+ tt.locate(173,60);
+ printf(" %2.1f\n",miles);
+ }
} else {
tt.locate(200,10);
printf("%3.1f \n",mpkWh[dtePeriod]);
tt.foreground(Cyan);
tt.set_font((unsigned char*) Arial24x23);
- tt.locate(222,70);
- printf("%2.1f \n",curEff);
+ tt.locate(240,60);
+ printf("%3.1f \n",mpkWh_noCC);
}
lx=50;
ly=mpkWh[0]*40;
--- a/displayModes.h Thu Nov 21 14:17:35 2013 +0000 +++ b/displayModes.h Thu Nov 21 23:08:00 2013 +0000 @@ -38,6 +38,7 @@ extern float kWh_trip[3]; extern float kW[39]; extern float mpkWh[39]; +extern float mpkWh_noCC; extern unsigned char whichTouched; extern unsigned char skin; extern unsigned char dtePeriod;
--- a/main.cpp Thu Nov 21 14:17:35 2013 +0000
+++ b/main.cpp Thu Nov 21 23:08:00 2013 +0000
@@ -7,9 +7,9 @@
// * 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?)
-// rev161
-// * Subtract climate control power from stored efficiency data and add current CC power back in for display
-// * Added X axis labels on CP histogram and scaled bar width
+// rev162
+// Fixed efficiency screen discontinuity when CC power changes
+// Added DTE & efficiency w/o CC to efficiency display
#include "mbed.h"
#include "CAN.h"
@@ -19,7 +19,7 @@
#include "utility.h"
#include "displayModes.h"
#include "TOUCH_TFTx2.h"
-char revStr[7] = "161"; // gg - revision string, max 6 characters
+char revStr[7] = "162"; // gg - revision string, max 6 characters
FATFS USBdrive;
LocalFileSystem local("local");
@@ -132,6 +132,7 @@
float mph[39]={0};
float kW[39]={0};
float mpkWh[39]={0};
+float mpkWh_noCC=0;
float unloadedV_x2,Resr,curRmax,curRmin,redRmax,redRmin,incRmax,incRmin;
signed short Imax, Imin;
// Logarithmic division scale (roughly - snapped to common units of time)
@@ -878,6 +879,7 @@
average=kW[i]/timeConstant[i];
kW[i]-=average;
kW[i]+=kW[0];
+ if(i==dtePeriod) mpkWh_noCC=mpkWh[i]/average; // compute efficiency w/o CC for dtePeriod
average+=CCkW; //add climate control power back in for display
mpkWh[i]/=average;
if (mpkWh[i]<0) {
