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

◆ qsub8()

LIB8STATIC_ALWAYS_INLINE uint8_t qsub8 ( uint8_t i,
uint8_t j )

Subtract one byte from another, saturating at 0x00.

Parameters
ibyte to subtract from
jbyte to subtract
Returns
i - j with a floor of 0
Examples
Fire2012.ino, Fire2012WithPalette.ino, NoisePlusPalette.ino, and TwinkleFox.ino.

Definition at line 103 of file math8.h.

103 {
104#if QSUB8_C == 1
105 int t = i - j;
106 if (t < 0)
107 t = 0;
108 return t;
109#elif QSUB8_AVRASM == 1
110
111 asm volatile(
112 /* First, subtract j from i, conditioning the C flag */
113 "sub %0, %1 \n\t"
114
115 /* Now test the C flag.
116 If C is clear, we branch around a load of 0x00 into i.
117 If C is set, we go ahead and load 0x00 into i.
118 */
119 "brcc L_%= \n\t"
120 "ldi %0, 0x00 \n\t"
121 "L_%=: "
122 : "+d"(i) // r16-r31, restricted by ldi
123 : "r"(j));
124 return i;
125#else
126#error "No implementation for qsub8 available."
127#endif
128}

References LIB8STATIC_ALWAYS_INLINE.

Referenced by coolLikeIncandescent(), fl::TwinkleFox::coolLikeIncandescentFunction(), fl::Fire2012::draw(), fillnoise8(), fl::NoisePalette::fillnoise8(), Fire2012(), Fire2012WithPalette(), getPaletteIndex(), getPaletteIndex(), operator-(), CRGB::operator-=(), rgb2hsv_approximate(), and CRGB::subtractFromRGB().

+ Here is the caller graph for this function: