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

◆ qadd8()

LIB8STATIC_ALWAYS_INLINE uint8_t qadd8 ( uint8_t i,
uint8_t j )

Add one byte to another, saturating at 0xFF.

Parameters
ifirst byte to add
jsecond byte to add
Returns
the sum of i + j, capped at 0xFF
Examples
Fire2012.ino, Fire2012WithPalette.ino, and Pacifica.ino.

Definition at line 40 of file math8.h.

40 {
41#if QADD8_C == 1
42 unsigned int t = i + j;
43 if (t > 255)
44 t = 255;
45 return static_cast<uint8_t>(t);
46#elif QADD8_AVRASM == 1
47 asm volatile(
48 /* First, add j to i, conditioning the C flag */
49 "add %0, %1 \n\t"
50
51 /* Now test the C flag.
52 If C is clear, we branch around a load of 0xFF into i.
53 If C is set, we go ahead and load 0xFF into i.
54 */
55 "brcc L_%= \n\t"
56 "ldi %0, 0xFF \n\t"
57 "L_%=: "
58 : "+d"(i) // r16-r31, restricted by ldi
59 : "r"(j));
60 return i;
61#elif QADD8_ARM_DSP_ASM == 1
62 asm volatile("uqadd8 %0, %0, %1" : "+r"(i) : "r"(j));
63 return i;
64#else
65#error "No implementation for qadd8 available."
66#endif
67}
static uint32_t t
Definition Luminova.h:54

References LIB8STATIC_ALWAYS_INLINE, and t.

Referenced by PixelController< RGB_ORDER, LANES, MASK >::dither(), PixelController< RGB_ORDER, LANES, MASK >::dither(), fl::Fire2012::draw(), fill_raw_2dnoise16into8(), fill_raw_noise8(), fillFrameBufferNoise(), fl::NoisePalette::fillnoise8(), Fire2012(), Fire2012WithPalette(), inoise8(), inoise8(), inoise8(), operator+(), CRGB::operator+=(), fl::Pacifica::pacifica_add_whitecaps(), pacifica_add_whitecaps(), rgb2hsv_approximate(), and wu_water().

+ Here is the caller graph for this function: