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

◆ map8()

LIB8STATIC fl::u8 map8 ( fl::u8 in,
fl::u8 rangeStart,
fl::u8 rangeEnd )

Map from one full-range 8-bit value into a narrower range of 8-bit values, possibly a range of hues.

E.g. map myValue into a hue in the range blue..purple..pink..red

hue = map8( myValue, HUE_BLUE, HUE_RED);
uint8_t hue
Definition advanced.h:94
@ HUE_BLUE
Blue (225°)
Definition hsv.h:103
@ HUE_RED
Red (0°)
Definition hsv.h:98
LIB8STATIC fl::u8 map8(fl::u8 in, fl::u8 rangeStart, fl::u8 rangeEnd)
Map from one full-range 8-bit value into a narrower range of 8-bit values, possibly a range of hues.
Definition lib8tion.h:467

Combines nicely with the waveform functions (like sin8(), etc) to produce continuous hue gradients back and forth:

hue = map8( sin8( myValue), HUE_BLUE, HUE_RED);

Mathematically simiar to lerp8by8(), but arguments are more like Arduino's "map"; this function is similar to

map( in, 0, 255, rangeStart, rangeEnd)

but faster and specifically designed for 8-bit values.

Definition at line 467 of file lib8tion.h.

468{
469 fl::u8 rangeWidth = rangeEnd - rangeStart;
470 fl::u8 out = scale8( in, rangeWidth);
471 out += rangeStart;
472 return out;
473}
unsigned char u8
Definition stdint.h:131

References LIB8STATIC.

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

+ Here is the caller graph for this function: