Dual CANbus monitor and instrumentation cluster
Dependencies: SPI_TFTx2 TFT_fonts TOUCH_TFTx2 beep mbed
Fork of CANary by
Revision 55:591406a71fa8, committed 2013-04-09
- Comitter:
- garygid
- Date:
- Tue Apr 09 06:45:46 2013 +0000
- Parent:
- 54:6ce808d0995e
- Parent:
- 52:d5385fbf4ea1
- Child:
- 56:0de6b316c19b
- Commit message:
- GG Merged v52 into v53
Changed in this revision
displayModes.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/displayModes.cpp Tue Apr 09 06:16:26 2013 +0000 +++ b/displayModes.cpp Tue Apr 09 06:45:46 2013 +0000 @@ -721,8 +721,10 @@ tt.background(Navy); tt.foreground(Yellow); + if(force){ + tt.cls(); + } if(force||lgids!=gids){ - tt.cls(); tt.set_font((unsigned char*) Arial12x12); for(i=0;i<10;i++){ y=200-i*20; @@ -736,27 +738,27 @@ } x=50+0*6; - tt.locate(x-6,226); + tt.locate(x-10,226); printf("sec\n"); tt.line(x,10,x,220,DarkGrey); x=50+9*6; - tt.locate(x-6,226); + tt.locate(x-10,226); printf("min\n"); tt.line(x,10,x,220,DarkGrey); x=50+18*6; - tt.locate(x-6,226); + tt.locate(x-10,226); printf("hour\n"); tt.line(x,10,x,220,DarkGrey); x=50+25*6; - tt.locate(x-6,226); + tt.locate(x-10,226); printf("day\n"); tt.line(x,10,x,220,DarkGrey); x=50+32*6; - tt.locate(x-6,226); + tt.locate(x-10,226); printf("mon\n"); tt.line(x,10,x,220,DarkGrey); x=50+38*6; - tt.locate(x-6,226); + tt.locate(x-10,226); printf("year\n"); tt.line(x,10,x,220,DarkGrey); lgids=gids; @@ -785,10 +787,11 @@ 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)); + tt.locate(160,10); + printf("%4.1f \n",mpkWh[dtePeriod]*((float)(gids-5)*.075)); } else { + tt.locate(180,10); printf("%3.1f\n",mpkWh[dtePeriod]); } lx=50; @@ -799,7 +802,7 @@ ly=0; } if(dtePeriod==0){ - radius=4; + radius=6; color=Magenta; }else{ radius=2; @@ -826,7 +829,9 @@ 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); + if(y>0){ + tt.fillcircle(x,y,radius,color); + } tt.line(lx,ly,x,y,White); lx=x; ly=y;
--- a/main.cpp Tue Apr 09 06:16:26 2013 +0000 +++ b/main.cpp Tue Apr 09 06:45:46 2013 +0000 @@ -103,12 +103,11 @@ float kW[39]={0}; float mpkWh[39]={0}; // Logarithmic division scale (roughly - snapped to common units of time) -// First 10 are updated each second; the rest are updated each minute float timeConstant[39] = {1, 1.58, 2.51, 3.98, 6.31, 10, 15.8, 25.1, 39.8, 60, // 1 minute - 1.58, 2.51, 3.98, 6.31, 10, 15.8, 25.1, 39.8, 60, // 1 hour - 60*1.58, 60*2.51, 60*3.98, 60*6.31, 60*10, 60*15.8, 60*24, // 1 day - 60*24*1.58, 60*24*2.51, 60*24*3.98, 60*24*6.31, 60*24*10, 60*24*15.8, 60*24*30, // 1 month - 60*24*39.8, 60*24*63.1, 60*24*100, 60*24*158, 60*24*251, 60*24*365}; // 1 year + 60*1.58, 60*2.51, 60*3.98, 60*6.31, 60*10, 60*15.8, 60*25.1, 60*39.8, 60*60, // 1 hour + 60*60*1.58, 60*60*2.51, 60*60*3.98, 60*60*6.31, 60*60*10, 60*60*15.8, 60*60*24, // 1 day + 60*60*24*1.58, 60*60*24*2.51, 60*60*24*3.98, 60*60*24*6.31, 60*60*24*10, 60*60*24*15.8, 60*60*24*30, // 1 month + 60*60*24*39.8, 60*60*24*63.1, 60*60*24*100, 60*60*24*158, 60*60*24*251, 60*60*24*365}; // 1 year bool updateDTE = false; int main() { @@ -116,9 +115,8 @@ char sTemp[40]; unsigned long secs; unsigned char i,j,display=0,lwt=0; - unsigned char minuteCount=0; point lastTouch; - float average,mph9,kW9; + float average; can1.monitor(true); // set to snoop mode can2.monitor(true); // set to snoop mode @@ -162,7 +160,9 @@ // sprintf(sTemp,"CANary firmware rev51-gg1\n"); // gg - shows 4x4 buttons, // but the touch areas are still 3x3 //sprintf(sTemp,"CANary firmware rev51-gg2\n"); // gg - decodes 4x4 button touches, - sprintf(sTemp,"CANary firmware rev51-gg3\n"); // gg - cleaned 4x4 button and touches, + //sprintf(sTemp,"CANary firmware rev51-gg3\n"); // gg - cleaned 4x4 button and touches, + //sprintf(sTemp,"CANary firmware rev52\n"); + sprintf(sTemp,"CANary firmware rev54\n"); // merged 53 (51-gg3) and 52 logMsg(sTemp); // Look for new binary on thumbdrive @@ -596,38 +596,21 @@ numSsamples=0; mWs_x4=0; numWsamples=0; - // First ten are updated each second - for(i=1;i<10;i++){ - mph9=mph[i]/timeConstant[i]; - mph[i]-=mph9; - mph[i]+=mph[0]; - kW9=kW[i]/timeConstant[i]; - kW[i]-=kW9; - kW[i]+=kW[0]; - mpkWh[i]=mph[i]; - mpkWh[i]/=kW[i]; - if (mpkWh[i]<0) { - mpkWh[i]=99;// negative means inf. - } - //mpkWh[i]=floor(mpkWh[i]*10+0.5)/10; // Round to nearest 10th - } - // The rest are updated each minute - if(++minuteCount>59){ // - minuteCount=0; - for(i=10;i<39;i++){ + if(accOn){ + for(i=1;i<39;i++){ average=mph[i]/timeConstant[i]; mph[i]-=average; - mph[i]+=mph9; + mph[i]+=mph[0]; + mpkWh[i]=average; average=kW[i]/timeConstant[i]; kW[i]-=average; - kW[i]+=kW9; - mpkWh[i]=mph[i]; - mpkWh[i]/=kW[i]; + kW[i]+=kW[0]; + mpkWh[i]/=average; if (mpkWh[i]<0) { mpkWh[i]=99;// negative means inf. } //mpkWh[i]=floor(mpkWh[i]*10+0.5)/10; // Round to nearest 10th - } + } } updateDTE=true; if(logCP)