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.
Size | Removed Bytes | Comment |
17178 | . | original 0.86 code |
16898 | 280 | Re-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. |
16874 | 24 | Re-wrote elapsedMicroseconds to remove reference to floating point number, and to correct negation error. |
16774 | 100 | Re-wrote setup(). Completed moving displayFuncNames strings into flash memory. |
15698 | 1076 | added 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). |
15674 | 24 | Removed 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. |
15530 | 144 | Re-wrote bignum(). Added LCD:: printBigNum() function. Moved bignumchar1[] and bignumchar2[] into flash. |
15332 | 198 | Re-wrote 64-bit math section to optimize code and to remove separate conditional functions. |
15212 | 120 | Re-wrote LCD:: print and LCD:: pushNibble, added LCD:: printFlash(), removed getstr(), removed tickleEnable(). |
13734 | 1478 | Removed 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(). |