FastLED 3.9.15
Loading...
Searching...
No Matches

◆ lsrX4()

uint8_t fl::lsrX4 ( uint8_t 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 240 of file colorutils.cpp.

240 {
241#if defined(__AVR__)
242 dividend /= 2;
243 dividend /= 2;
244 dividend /= 2;
245 dividend /= 2;
246#else
247 dividend >>= 4;
248#endif
249 return dividend;
250}

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

+ Here is the caller graph for this function: