Quote:
Originally Posted by MPaulHolmes
Here's the modified throttleAverage code, as a sample. Thanks for the suggestion, Astro! I'm making the same change to pwmAverage and temperatureAverage. Totally unreadable, but pretty fast. haha:
Code:
throttleAverageTimes1024 // = (31*throttleAverageTimes1024)/1024 + 1*ADThrottle) / 32 * 1024;
// = 32*(throttleAverageTimes1024/1024) - 1*(throttleAverageTimes1024/1024) + 1*ADThrottle) / 32 * 1024;
= ((throttleAverageTimes1024 >> 5) - (throttleAverageTimes1024 >> 10) + (long)ADThrottle) << 5;
|
I had to look up a wiki to find out what >> did in C programming language.
(One day i will have to learn C.)
A bitwise shift. Very neat.
Sometimes readability needs to take a back seat to performance. After all that's what comments are for.