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, NoisePlusPalette.ino, and Pacifica.ino.

Definition at line 31 of file math8.h.

31 {
32#if QADD8_C == 1
33 unsigned int t = i + j;
34 if (t > 255)
35 t = 255;
36 return t;
37#elif QADD8_AVRASM == 1
38 asm volatile(
39 /* First, add j to i, conditioning the C flag */
40 "add %0, %1 \n\t"
41
42 /* Now test the C flag.
43 If C is clear, we branch around a load of 0xFF into i.
44 If C is set, we go ahead and load 0xFF into i.
45 */
46 "brcc L_%= \n\t"
47 "ldi %0, 0xFF \n\t"
48 "L_%=: "
49 : "+d"(i) // r16-r31, restricted by ldi
50 : "r"(j));
51 return i;
52#elif QADD8_ARM_DSP_ASM == 1
53 asm volatile("uqadd8 %0, %0, %1" : "+r"(i) : "r"(j));
54 return i;
55#else
56#error "No implementation for qadd8 available."
57#endif
58}

References LIB8STATIC_ALWAYS_INLINE.

Referenced by CRGB::addToRGB(), PixelController< RGB_ORDER, LANES, MASK >::dither(), PixelController< RGB_ORDER, LANES, MASK >::dither(), fl::Fire2012::draw(), fill_raw_2dnoise16into8(), fill_raw_noise8(), fillnoise8(), 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: