Tank MPG is the easiest. Right now, for testing, it starts with a fixed value of 17.9999999 MPG to test rounding functions (I wasn't quite sure how the code worked yet, but I'm getting the hang of it now), but that value is discarded as soon as tank MPG moves away from 0.00. It calculates against the configured (but currently unused) tank capacity setting.
It uses its own "screen" which I currently call "F4 edit" due to all the comments I made in the code indicating where I patched it ("// ** F4 edit: blah blah"). The screen has both RemMiles and Time (clock).
Here's the code:
Put this somewhere around the screen routines. I put mine after doDisplaySystemInfo.
Code:
void doDisplayRem(void) {
LCD::gotoXY(0,0);
unsigned long remMPG = tank.mpg(); // may need to change this below
unsigned long remMiles = parms[tankSizeIdx]; // final value
if (remMPG < 50) remMPG = 17999; // if unreasonably low, make more reasonable
LCD::print("Rem miles:");
remMiles -= tank.gallons(); // subtract used gallons from total tank gallons
remMiles *= remMPG; // multiply available gallons by tank mpg
remMiles /= 1000; // since we multiplied two *1000 vals, knock down a notch
LCD::print(format(remMiles));
LCD::gotoXY(0,1);
LCD::print(" ");
}
Add a new displayFuncName:
Code:
displayFuncNames[x++] = PSTR("Rem tank miles ");
And add a new displayFuncs to the position where you added the displayFuncName (if at the top of the stack, add it to beginning of list; if at bottom, add to end):
And that should pretty much be that. You can also use the computation above to add it to any other screen you want (custom is nice), but real estate there is limited. So if you want to replace Current MPG on the Custom screen, you could do this:
Code:
void doDisplayCustom() {
unsigned long remMPG = tank.mpg(); // may need to change this below
unsigned long remMiles = parms[tankSizeIdx]; // final value
if (remMPG < 50) remMPG = 17999; // if unreasonably low, make more reasonable
remMiles -= tank.gallons(); // subtract used gallons from total tank gallons
remMiles *= remMPG; // multiply available gallons by tank mpg
remMiles /= 1000; // since we multiplied two *1000 vals, knock down a notch
displayTripCombo("MG","LK", instantmpg(), " S"," S", instantmph(), "GH","LH",
instantgph(), "RM", remMiles);
}
(I think. I haven't tried that... and I removed the metric functionality from mine, so I had to add that back above too.)
As they say... enjoy!