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 306 of file math8.h.

306 {
307#if AVG7_C == 1
308 return (i >> 1) + (j >> 1) + (i & 0x1);
309#elif AVG7_AVRASM == 1
310 asm volatile("asr %1 \n\t"
311 "asr %0 \n\t"
312 "adc %0, %1 \n\t"
313 : "+r"(i)
314 : "r"(j));
315 return i;
316#else
317#error "No implementation for avg7 available."
318#endif
319}

References LIB8STATIC_ALWAYS_INLINE.

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

+ Here is the caller graph for this function: