test fork
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Diff: displayModes.cpp
- Revision:
- 162:c6545fc0164a
- Parent:
- 161:71ac85d11f03
- Child:
- 163:3b6fab958773
--- 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;