FastLED 3.10.6
Loading...
Searching...
No Matches

◆ lsrX4()

fl::u8 fl::lsrX4 ( fl::u8 dividend)
inline

Helper function to divide a number by 16, aka four logical shift right (LSR)'s.

On avr-gcc, "u8 >> 4" generates a loop, which is big, and slow. merely forcing it to be four /=2's causes avr-gcc to emit a SWAP instruction followed by an AND 0x0F, which is faster, and smaller.

Definition at line 324 of file colorutils.cpp.hpp.

324 {
325#if defined(FL_IS_AVR)
326 dividend /= 2;
327 dividend /= 2;
328 dividend /= 2;
329 dividend /= 2;
330#else
331 dividend >>= 4;
332#endif
333 return dividend;
334}

Referenced by ColorFromPalette(), ColorFromPalette(), and ColorFromPalette().

+ Here is the caller graph for this function: