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

◆ nscale8x2()

LIB8STATIC void nscale8x2 ( uint8_t & i,
uint8_t & j,
fract8 scale )

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
ifirst value to scale
jsecond value to scale
scalescale factor, in n/256 units

Definition at line 427 of file scale8.h.

427 {
428#if SCALE8_C == 1
429#if FASTLED_SCALE8_FIXED == 1
430 uint16_t scale_fixed = scale + 1;
431 i = (((uint16_t)i) * scale_fixed) >> 8;
432 j = (((uint16_t)j) * scale_fixed) >> 8;
433#else
434 i = ((uint16_t)i * (uint16_t)(scale)) >> 8;
435 j = ((uint16_t)j * (uint16_t)(scale)) >> 8;
436#endif
437#elif SCALE8_AVRASM == 1
440 cleanup_R1();
441#else
442#error "No implementation for nscale8x2 available."
443#endif
444}
uint16_t scale
Definition Noise.ino:74
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
Definition scale8.h:343
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.
Definition scale8.h:180

References cleanup_R1(), LIB8STATIC, scale, and scale8_LEAVING_R1_DIRTY().

+ Here is the call graph for this function: