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 TFT_fonts TOUCH_TFTx2 mbed
Fork of CANary by
Diff: displayModes.cpp
- Revision:
- 50:83d5864c64a0
- Parent:
- 49:a3d2c5bb3cfa
- Child:
- 52:d5385fbf4ea1
- Child:
- 54:6ce808d0995e
diff -r a3d2c5bb3cfa -r 83d5864c64a0 displayModes.cpp
--- a/displayModes.cpp Sun Apr 07 08:29:04 2013 +0000
+++ b/displayModes.cpp Sun Apr 07 16:34:12 2013 +0000
@@ -94,7 +94,7 @@
tt.set_font((unsigned char*) Arial28x28);
if(force) tt.cls();
if(skin==ttSkin){
- if(force||gids!=lgids||mpkWh[9]!=lmpkWh){
+ if(force||gids!=lgids||mpkWh[dtePeriod]!=lmpkWh){
tt.locate(10,10);
printf("%4d gids \n",gids);
tt.locate(10,40);
@@ -102,9 +102,9 @@
tt.set_font((unsigned char*) SCProSB31x55);
tt.foreground(Green);
tt.locate(60,96);
- printf("%4.1f mi \n",mpkWh[9]*((float)(gids-5)*.075)); // Use 1 minute average
+ printf("%4.1f mi \n",mpkWh[dtePeriod]*((float)(gids-5)*.075));
lgids=gids;
- lmpkWh-mpkWh[9];
+ lmpkWh=mpkWh[dtePeriod];
tt.foreground(Yellow);
tt.set_font((unsigned char*) Arial28x28);
}
@@ -727,45 +727,90 @@
}
}
-void dteDisplay(bool force, bool showButtons){
- unsigned short i,x,y,lx,ly;
+void dteDisplay(bool force, bool showButtons, bool showMiles){
+ unsigned short i,x,y,lx,ly,gids,radius,color;
+ static unsigned short lgids=0;
+ static unsigned char leff[39]={0};
+ CANMessage msg;
+
+ msg = lastMsg[indexLastMsg[0x5bc]]; //Get gids
+ gids = (msg.data[0]<<2)+(msg.data[1]>>6);
+ if(gids==0){
+ gids=281;
+ }
+
tt.background(Navy);
tt.foreground(Yellow);
- if(force||updateDTE){
+ if(force||lgids!=gids){
tt.cls();
tt.set_font((unsigned char*) Arial12x12);
for(i=0;i<10;i++){
y=200-i*20;
tt.locate(10,y-8);
- printf("%d.0\n",i);
- tt.line(40,y,280,y,LightGrey);
+ if (showMiles){
+ printf("%3.0f\n",i*((float)(gids-5)*.075));
+ }else{
+ printf("%d.0\n",i);
+ }
+ tt.line(40,y,280,y,DarkGrey);
}
x=50+0*6;
- tt.locate(x-8,226);
+ tt.locate(x-6,226);
printf("sec\n");
- tt.line(x,10,x,220,LightGrey);
+ tt.line(x,10,x,220,DarkGrey);
x=50+9*6;
- tt.locate(x-8,226);
+ tt.locate(x-6,226);
printf("min\n");
- tt.line(x,10,x,220,LightGrey);
+ tt.line(x,10,x,220,DarkGrey);
x=50+18*6;
- tt.locate(x-8,226);
+ tt.locate(x-6,226);
printf("hour\n");
- tt.line(x,10,x,220,LightGrey);
+ tt.line(x,10,x,220,DarkGrey);
x=50+25*6;
- tt.locate(x-8,226);
+ tt.locate(x-6,226);
printf("day\n");
- tt.line(x,10,x,220,LightGrey);
+ tt.line(x,10,x,220,DarkGrey);
x=50+32*6;
- tt.locate(x-8,226);
+ tt.locate(x-6,226);
printf("mon\n");
- tt.line(x,10,x,220,LightGrey);
+ tt.line(x,10,x,220,DarkGrey);
x=50+38*6;
- tt.locate(x-8,226);
+ tt.locate(x-6,226);
printf("year\n");
- tt.line(x,10,x,220,LightGrey);
-
+ tt.line(x,10,x,220,DarkGrey);
+ lgids=gids;
+ }
+ if(force||updateDTE){
+ for(i=0;i<10;i++){
+ y=200-i*20;
+ if (y>60){
+ tt.line(40,y,280,y,DarkGrey);
+ } else {
+ tt.line(40,y,150,y,DarkGrey);
+ }
+ }
+
+ x=50+0*6;
+ tt.line(x,10,x,220,DarkGrey);
+ x=50+9*6;
+ tt.line(x,10,x,220,DarkGrey);
+ x=50+18*6;
+ tt.line(x,10,x,220,DarkGrey);
+ x=50+25*6;
+ tt.line(x,180,x,220,DarkGrey);
+ x=50+32*6;
+ tt.line(x,180,x,220,DarkGrey);
+ x=50+38*6;
+ tt.line(x,180,x,220,DarkGrey);
+ tt.set_font((unsigned char*) SCProSB31x55);
+ tt.foreground(Green);
+ tt.locate(180,10);
+ if (showMiles){
+ printf("%4.1f\n",mpkWh[dtePeriod]*((float)(gids-5)*.075));
+ } else {
+ printf("%3.1f\n",mpkWh[dtePeriod]);
+ }
lx=50;
ly=mpkWh[0]*20;
if(ly<200) {
@@ -773,7 +818,15 @@
}else{
ly=0;
}
- tt.fillcircle(lx,ly,4,Green);
+ if(dtePeriod==0){
+ radius=4;
+ color=Magenta;
+ }else{
+ radius=2;
+ color=Green;
+ }
+ tt.fillcircle(lx,leff[0],radius,Navy);
+ tt.fillcircle(lx,ly,radius,color);
for(i=1;i<39;i++){
x=50+i*6;
@@ -783,12 +836,23 @@
}else{
y=0;
}
- tt.circle(x,y,2,Green);
+ if(i==dtePeriod){
+ radius=4;
+ color=Magenta;
+ }else{
+ radius=2;
+ color=Green;
+ }
+ tt.fillcircle(x,leff[i],radius,Navy);
+ tt.line(x-6,leff[i-1],x,leff[i],Navy);
+ leff[i-1]=ly;
+ tt.fillcircle(x,y,radius,color);
tt.line(lx,ly,x,y,White);
lx=x;
ly=y;
}
- updateDTE=false;
+ leff[i-1]=y;
+ updateDTE=false;
}
}
@@ -807,9 +871,12 @@
braking(changed,(display==whichTouched));
break;
case dteScreen:
- dteDisplay(changed,(display==whichTouched));
+ dteDisplay(changed,(display==whichTouched),true);
break;
- case monitorScreen:
+ case effScreen:
+ dteDisplay(changed,(display==whichTouched),false);
+ break;
+ case monitorScreen:
printLast(changed,(display==whichTouched));
break;
case changedScreen:
@@ -870,6 +937,9 @@
case dteScreen:
sprintf(sTemp2," DTE");
break;
+ case effScreen:
+ sprintf(sTemp2," Eff");
+ break;
case monitorScreen:
sprintf(sTemp2," Monitor");
break;
