View Single Post
Old 06-24-2011, 06:00 AM   #123 (permalink)
EcoModding Lurker
FalconFour's Avatar
Join Date: Sep 2010
Location: Fresno, CA
Posts: 78

LEAF - '11 Nissan LEAF
Thanks: 4
Thanked 9 Times in 7 Posts
Just a little teaser... make of it what you will
Trip tmpTrip;
Trip instant;
Trip current;
Trip tank;
// from
// ...headache-inducing.
typedef long unsigned int (Trip::*TripFn)(void);
#define CALL_MEMBER_FN(object,ptrToMember)  ((object).*(ptrToMember))
TripFn idxCallers[] = { &Trip::miles, &Trip::gallons, &Trip::mpg, &Trip::mph, &Trip::time, &Trip::eocMiles, &Trip::idleGallons };
char *idxLabelsSm[] PROGMEM={ "Mil",       "Gal",        "MPG",       "MPH",      "H/M",         "EOC",            "Idl"        };
char *idxLabelsLg[] PROGMEM={"Miles",   "Gallons",     "MPG",      "MPH",      "Time",      "EOC Miles",      "Idle Gal"        };

char menuItem00[] PROGMEM = "Edit Display";
char menuItem01[] PROGMEM = "Clear Trip";
char menuItem02[] PROGMEM = "Clear Tank";
char menuItem03[] PROGMEM = "End Trip";
char menuItem04[] PROGMEM = "New Trip";
char menuItem05[] PROGMEM = "Set Clock";
char menuItem06[] PROGMEM = "Preferences";
char menuItem07[] PROGMEM = "System Setup";
char menuItem08[] PROGMEM = "History";
char menuItem09[] PROGMEM = "Switch Screen";
char menuItem10[] PROGMEM = "Screensaver";
char menuItem11[] PROGMEM = "Timeout";
char menuItem12[] PROGMEM = "Info Cycle";
char menuItem13[] PROGMEM = "Show Clock";
char menuItem14[] PROGMEM = "Show Graphic";
char menuItem15[] PROGMEM = "Dim Backlight";
char menuItem16[] PROGMEM = "Backlight";
char menuItem17[] PROGMEM = "Save Default";
char menuItem18[] PROGMEM = "Restore Mode";
char menuItem19[] PROGMEM = "Past 5 Tanks";
char menuItem20[] PROGMEM = "Past 5 Trips";
char menuItem21[] PROGMEM = "Big Display";
char menuItem22[] PROGMEM = "Instant";
char menuItem23[] PROGMEM = "Trip";
char menuItem24[] PROGMEM = "Tank";
I've been working on understanding and extending the phi_prompt library to where I need it to be to use it with this project (which I still don't have a proper name for). Needed to overcome a major limitation with being able to create dynamic menu entries, not just "fixed" ones like those shown above. That way I can display the currently-selected values on the options screens, and create menus based on what needs to be shown at the moment instead of a fixed menu of options for each possible outcome (yuck).

Believe me, I haven't forgotten about this project. It's kind of my "holy grail" of my understanding of avr-libc and Arduino. And for what it's worth, yeah, Arduino is definitely a pretty convoluted build system, but it really helps make the code amazingly portable. After having taken the whole build process apart (code -> libs -> core(->lib) -> link -> hex -> upload), and been able to take Arduino code and run it through AVR Studio's AVR Simulator... or, say, take the build folder and "avr-objdump -dC" the .elf file to step through the assembly, or write an inline ASM definition "optimizer" for time-sensitive functions, or create a rolling buffer of audio data in RAM and use it to generate an echo effect... or intelligently hand off timer-counting responsibilities between Timer0 and Timer2 depending on if Timer2 needs to be active at clk/1 to run a sine-wave tone generator, or if the toner is silent... or created animated sequences using the 16x2 character LCD, or wrote a full fledged, menu-based, self-contained diagnostic and monitoring tool for SMBus Smart Battery protocol-based laptop batteries... or... YES, I've done a SH*TLOAD of work with my Arduinos using the most low-level code imaginable, or just any code that gets the job done.

That said, I have no intention of making some all-in-all disconnection from the Arduino environment. It's astoundingly flexible, and I'll make sure that the ultimate "release distribution" compiles well under both Arduino *and* standard AVR-GCC build environments. I just prefer using Arduino since my physical dev environment *is* Arduino, and other IDEs feel more like dirty hacks than anything. I'm still playing with the idea of using AVR Studio, but it's got a real "unclean" feel to it - ffs, it has C++ support as an "add-on", and half the default build environment options are non-optimal for our setup. Only thing I don't like about Arduino is that it wastes time re-compiling all files each time I do something like a simple "syntax check" build.

Well, enough out of me for now... expect great things in the coming weeks - this thing's been eating at me for a while
  Reply With Quote