-   OpenGauge / MPGuino FE computer (
-   -   Would anybody be interested in an optimized version of the base MPGuino 0.86 code? (

t vago 07-18-2013 12:33 AM

Would anybody be interested in an optimized version of the base MPGuino 0.86 code?
As I was going through the MPGuino 0.86 code in order to add my Chrysler fuel adjustment algorithm, I got to thinking that I could tweak the base code to reduce the code size, make the code more robust, and get rid of some nasty and subtle bugs in the code.

I went through the base code again, separate from the code I've been working on, and managed to shrink it by a smidge over 20%. It still retains the same functionality as the base 0.86 code. I added no new features to it.

I am going to test the optimized base code tomorrow to make sure it still works.

SizeRemoved BytesComment
17178.original 0.86 code
16898280Re-wrote microseconds() to more accurately calculate the 'microseconds' (actually clock cycles), and to remove a nasty bug that could cause unwanted nested interrupts. Removed (unsigned long) lastMicroseconds.
1687424Re-wrote elapsedMicroseconds to remove reference to floating point number, and to correct negation error.
16774100Re-wrote setup(). Completed moving displayFuncNames strings into flash memory.
156981076added setupGuino() to handle MPGuino-specific system variable setup and fuel injector interrupt setup. Removed floating point calculations (3.785, 1.609) and replaced with (3785 ul / 1000 ul, 1609ul / 1000ul).
1567424Removed indirect function references to ISR(INT0_vect) and ISR(INT1_vect). Re-wrote fuel injector close event to remove fuel consumption runaway bug. Re-wrote instantmpg() to remove integer division before integer multiplication bug.
15530144Re-wrote bignum(). Added LCD:: printBigNum() function. Moved bignumchar1[] and bignumchar2[] into flash.
15332198Re-wrote 64-bit math section to optimize code and to remove separate conditional functions.
15212120Re-wrote LCD:: print and LCD:: pushNibble, added LCD:: printFlash(), removed getstr(), removed tickleEnable().
137341478Removed instantlkm(). Removed Trip::lkm(). Turned injhius and injhisec into injtime[2]. Turned injIdleHius and injIdleHiSec into injIdleTime[2]. Added private Trip::doMiles() and private Trip::doGallons() functions. Eliminated redundant code in Trip::Miles(), Trip::EOCMiles(), Trip::Gallons, and Trip::IdleGallons().

Quezacotl 07-22-2013 03:55 AM

Nice. Optimization is always good :)

t vago 07-22-2013 10:04 AM

Yah - I just got to figure out why the optimized code randomly freezes. Might be something to do with how the interrupts are handled.

martinq 11-15-2013 04:36 PM

Any news on this project?

josemapiro 11-15-2013 05:38 PM


Originally Posted by martinq (Post 399618)
Any news on this project?

You can follow this project here

Josť Rodrigues

All times are GMT -4. The time now is 04:09 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright