test fork
Dependencies: SPI_TFTx2 SPI_TFTx2_ILI9341 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary_9341 by
Diff: displayModes.cpp
- Revision:
- 170:7ee98e3611bc
- Parent:
- 169:84d790ac18a2
- Child:
- 171:355e284f5201
--- a/displayModes.cpp Tue Dec 17 15:25:41 2013 +0000 +++ b/displayModes.cpp Tue Dec 24 12:20:50 2013 +0000 @@ -33,7 +33,7 @@ tt.locate(10,4); tt.foreground(White); printf("%dgids \n",gids); - useable_kWh = (float)(gids-5)*0.075; + useable_kWh = (float)(gids-5)*kWperGid; if (useable_kWh<0){ useable_kWh=0; } @@ -229,7 +229,7 @@ tt.locate(40,40); // gg - add GIDs Percent of 281 printf("%4.1f%s \n", (float)gids*0.355872, "% ") ; tt.locate(20,70); - printf("%4.1f kwh \n",(float)gids*0.075); // gg - closer to usable + printf("%4.1f kwh \n",(float)gids*kWperGid); // gg - closer to usable tt.set_font((unsigned char*) SCProSB31x55); tt.foreground(Green); @@ -421,7 +421,11 @@ }*/ if(force||gids!=lgids){ tt.locate(10,10); - printf("%4d gids \n",gids); + if(gids>startGids){ // If not start of trip print kWh/gid too + printf("%4d gids %4.3f kW/gid\n",gids,(float)(kWh_trip[0]+CCkWh_trip[0])/(gids-startGids)); + }else{ + printf("%4d gids \n",gids); + } lgids=gids; } if(force||SOC_x10!=lSOC){ @@ -431,7 +435,7 @@ } if(force||SOH2_x100!=lSOH){ tt.locate(10,70); - printf(" %4.1f%s,%4.1f%s \n",(float)SOH_x2/2,"%",(float)SOH2_x100/100,"% SOH"); + printf(" %d%s,%3.1f%s \n",SOH_x2/2,"% SOH",(float)SOH2_x100/100," Hx"); lSOH=SOH2_x100; } if(force||Ah_x10000!=lAh){ @@ -458,7 +462,8 @@ void braking (bool force, bool showButtons, bool prdata=false){ unsigned long targetBraking, regenBraking; - static unsigned long maxTarget = 1000, maxRegen = 1000, tardivreg_x1000 = 1000; + //static unsigned long maxTarget = 1000, maxRegen = 1000, tardivreg_x1000 = 1000; + static unsigned long maxRegen = 1000, tardivreg_x1000 = 1000; unsigned long temp; static unsigned char lastPressure[4] = {200,200,200,200}; unsigned char i,r,t; @@ -1144,13 +1149,13 @@ void dteDisplay(bool force, bool showButtons, bool showMiles){ unsigned short i,x,y,lx,ly,gids,radius,color,r,t; - unsigned char toVal; + unsigned char toVal,availableRegen=0; static unsigned short lgids=0; static unsigned char leff[39]={0}; CANMessage msg; unsigned long targetBraking, regenBraking, temp; static unsigned long maxTarget = 1000, tardivreg_x1000 = 1400; - static unsigned char lr=0, lt=0; + static unsigned char lr=0, lt=0, lar=0; msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids gids = (msg.data[0]<<2)+(msg.data[1]>>6); @@ -1184,6 +1189,7 @@ printf("mon\n"); tt.line(x,10,x,220,DarkGrey); x=50+38*6; + lar=0; } toVal=33; if(force||lgids!=gids){ // update Y axis when kWh changes @@ -1309,6 +1315,19 @@ leff[i-1]=y; } + msg = lastMsg[indexLastMsg[0x260]]; //Get available regen + availableRegen = msg.data[1]*2; + + if(availableRegen>lar){ + tt.fillrect(264,240-availableRegen,266,239-lar,White); + tt.fillrect(308,240-availableRegen,310,239-lar,White); + lar=availableRegen; + }else if(availableRegen<lar){ + tt.fillrect(264,240-lar,266,239-availableRegen,Navy); + tt.fillrect(308,240-lar,310,239-availableRegen,Navy); + lar=availableRegen; + } + msg = lastMsg[indexLastMsg[0x1cb]]; //Get Target total braking targetBraking = (msg.data[2]<<3)+(msg.data[3]>>5); @@ -1335,9 +1354,9 @@ if (r>160) r=160; if (r>t) t=r; //Should never happen if(lr!=r||lt!=t){ - if (t<160) tt.fillrect(264,239-160,310,238-t,Navy); - if (r<t) tt.fillrect(264,239-t,310,238-r,Red); - if (0<r) tt.fillrect(264,239-r,310,238,Green); + if (t<160) tt.fillrect(268,239-160,306,238-t,Navy); + if (r<t) tt.fillrect(268,239-t,306,238-r,Red); + if (0<r) tt.fillrect(268,239-r,306,238,Green); } lt=t; lr=r; @@ -1358,7 +1377,10 @@ if(logEn){ if(pointerSep>maxPS){maxPS=pointerSep;} tt.locate(10,10); - printf("%3d sep %3d max\n",pointerSep,maxPS); + printf("%3d sep %3d max\n",pointerSep,maxPS); + }else{ + tt.locate(10,10); + printf("%d maxT\n",maxTarget); } /*msg = lastMsg[indexLastMsg[0x5fa]]; month = msg.data[5]>>4;