View Single Post
Old 04-24-2011, 11:56 PM   #65 (permalink)
FalconFour
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
'S alright. Yeah, I'm working on making it as flexible as possible in all areas, particularly on the display. It's centered around a "main screen", the Instant figures, and allows you to cycle to different modes and menus to see the other data (tank, current, configuration, etc). Thinking of implementing a single button-press to "show this stat in big mode", when a figure is highlighted under the cursor, so anything can be made "big".

Right now I'm working on cross-referencing Arduino code with avr-libc code to kinda "reverse-engineer" MPGuino as elegantly as possible into standard Arduino code... there are a lot of cool and small Arduino functions that would greatly help the project, but the use of low-level AVR timer manipulations is reeeeallly messing up Arduino code and timings... so that's the biggest problem. I started writing out the main display routine but kept getting distracted by my inability to actually test it in the real code, so I've gotta solve that before I figure anything else out. Not very well versed in low level AVR registers like the ADC system (analog-to-digital), which seems to manage the button-inputs and whatnot. That's proving to be quite fun :P

edit: Found it... commented it... now need to figure out how to work around it.
Code:
	// turns off timer 0 overflow interrupt (breaks Arduino)
	TIMSK0 &= !(1 << TOIE0);
	// ok, done breaking things!
Most of the main() routines in MPGuino duplicate the efforts of Arduino's wiring.c library (part of its core that's compiled with every program). I've shaved off a number of bytes by "trimming the fat" and de-duplicating efforts, but I'm left with 3 lines that switch things around. Need to figure out how to implement these things in the existing wiring routines, because everything else seems to be pretty standard...
Code:
	TCCR2A = 1 << WGM20 | 1 << WGM21; // fast PWM mode for timer 2
	TIMSK2 |= 1 << TOIE2; // enables timer 2 overflow interrupt
	// turns off timer 0 overflow interrupt (breaks Arduino)
	TIMSK0 &= !(1 << TOIE0);
	// ok, done breaking things

Last edited by FalconFour; 04-25-2011 at 12:19 AM..
  Reply With Quote