Scale two one-byte values by a third one, which is treated as the numerator of a fraction whose demominator is 256.
In other words, it computes i,j * (scale / 256).
- Warning
- This function always modifies its arguments in place!
- Parameters
-
i | first value to scale |
j | second value to scale |
scale | scale factor, in n/256 units |
Definition at line 423 of file scale8.h.
423 {
424#if SCALE8_C == 1
425#if FASTLED_SCALE8_FIXED == 1
426 uint16_t scale_fixed =
scale + 1;
427 i = (((uint16_t)i) * scale_fixed) >> 8;
428 j = (((uint16_t)j) * scale_fixed) >> 8;
429#else
430 i = ((uint16_t)i * (uint16_t)(
scale)) >> 8;
431 j = ((uint16_t)j * (uint16_t)(
scale)) >> 8;
432#endif
433#elif SCALE8_AVRASM == 1
437#else
438#error "No implementation for nscale8x2 available."
439#endif
440}
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_LEAVING_R1_DIRTY(uint8_t i, fract8 scale)
This version of scale8() does not clean up the R1 register on AVR.
References cleanup_R1(), LIB8STATIC, scale, and scale8_LEAVING_R1_DIRTY().