David Hilton
David Hilton
If you run code with DEBUG_LOOP it will tell you.
Leaving in lots of Serial code is probably the main contributor.
Ah: the other thing that could cause long-running code is heavy math for the accelerometer. For example, get_spin consumes 2000 microseconds to do its calculation, the core of which is...
Maybe we can pull in this patch: http://code.google.com/p/arduino/issues/detail?id=140
I've pulled in [this library](http://code.google.com/p/digitalwritefast/downloads/detail?name=digitalWriteFastinterruptSafe.zip&can=2&q=), which is the implementation discussed [here](http://code.google.com/p/arduino/issues/detail?id=140). pinMode -> pinModeFast digitalWrite -> digitalWriteFast analogWrite -> analogWriteFast This saves around 250 bytes, and reduces execution time.
[arduino-lite](http://code.google.com/p/arduino-lite/wiki/APIReference) seems to be poorly maintained, but it should have a macro for analogWrite, which could be useful. No such optimization seems to exist for analogRead.
http://maxembedded.com/2011/06/20/the-adc-of-the-avr/ This link demonstrates how to convert analog to digital on the avr. We currently use similar code in read_avr_voltage.
adc reading implemented in read_adc.
I've not verified that all arduino functions are replaced (doable by compiling the library directly in avr-gcc)
Part of the desire was to make this library usable outside of the arduino environment, compiling via avr-gcc while including/linking no arduino code. At this point, I believe most of...