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

◆ avg7()

LIB8STATIC_ALWAYS_INLINE int8_t avg7 ( int8_t i,
int8_t j )

Calculate an integer average of two signed 7-bit integers (int8_t).

If the first argument is even, result is rounded down. If the first argument is odd, result is rounded up.

Parameters
ifirst value to average
jsecond value to average
Returns
mean average of i and j, rounded

Definition at line 322 of file math8.h.

322 {
323#if AVG7_C == 1
324 return (i >> 1) + (j >> 1) + (i & 0x1);
325#elif AVG7_AVRASM == 1
326 asm volatile("asr %1 \n\t"
327 "asr %0 \n\t"
328 "adc %0, %1 \n\t"
329 : "+r"(i)
330 : "r"(j));
331 return i;
332#else
333#error "No implementation for avg7 available."
334#endif
335}

References LIB8STATIC_ALWAYS_INLINE.

Referenced by grad8(), grad8(), and grad8().

+ Here is the caller graph for this function: