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 417 of file scale8.h.

417 {
418#if SCALE8_C == 1
419#if FASTLED_SCALE8_FIXED == 1
420 uint16_t scale_fixed = scale + 1;
421 i = (((uint16_t)i) * scale_fixed) >> 8;
422 j = (((uint16_t)j) * scale_fixed) >> 8;
423#else
424 i = ((uint16_t)i * (uint16_t)(scale)) >> 8;
425 j = ((uint16_t)j * (uint16_t)(scale)) >> 8;
426#endif
427#elif SCALE8_AVRASM == 1
430 cleanup_R1();
431#else
432#error "No implementation for nscale8x2 available."
433#endif
434}
UISlider scale("Scale", 4,.1, 4,.1)
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
Definition scale8.h:333
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:170

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

+ Here is the call graph for this function: