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

Definition at line 112 of file math8.h.

112 {
113#if QSUB8_C == 1
114 int t = i - j;
115 if (t < 0)
116 t = 0;
117 return static_cast<uint8_t>(t);
118#elif QSUB8_AVRASM == 1
119
120 asm volatile(
121 /* First, subtract j from i, conditioning the C flag */
122 "sub %0, %1 \n\t"
123
124 /* Now test the C flag.
125 If C is clear, we branch around a load of 0x00 into i.
126 If C is set, we go ahead and load 0x00 into i.
127 */
128 "brcc L_%= \n\t"
129 "ldi %0, 0x00 \n\t"
130 "L_%=: "
131 : "+d"(i) // r16-r31, restricted by ldi
132 : "r"(j));
133 return i;
134#else
135#error "No implementation for qsub8 available."
136#endif
137}
static uint32_t t
Definition Luminova.h:54

References LIB8STATIC_ALWAYS_INLINE, and t.

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

+ Here is the caller graph for this function: