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 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
436 cleanup_R1();
437#else
438#error "No implementation for nscale8x2 available."
439#endif
440}
UISlider scale("Scale", 1.0f, 0.0f, 1.0f, 0.01f)
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
Definition scale8.h:339
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:176

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

+ Here is the call graph for this function: