View Single Post
Old 08-20-2008, 03:47 PM   #149 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location: ÿ
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
Take a look at the mpguino/obduino code, there are functions for getting numbers and formatting them and displaying them and organizing the data by trip objects and utilizing the LCD and buttons. It is where Magister has already started. You don't need to reinvent all that as far as I know. You just need to replace the fuel injection timing bits with your obd functions (i.e. determine the elapsed fuel and mileage and add them to the trip accumulators every cycle), if we could #ifdef elm vs injector monitor at some point that might be good.

Basically each trip instance has it's own mpg, mph, gallons() functions that return a 32 bit number representing the value in 1000ths. It utilizes custom 64 bit math function to keep things simple that it can promote the values and multiply/divide them without being overly concerned with overflow/underflow, and it has a format function to convert the values (in 1000ths) to a rounded 2 decimal point string. Plus LCD positioning and displaying functions. Plus a lot I have probably failed to mention:

Revision 63: /trunk
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote