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

◆ nscale8x2_video()

LIB8STATIC void nscale8x2_video ( 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), ensuring that non-zero values passed in remain non zero, no matter how low the scale argument.

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

447 {
448#if SCALE8_C == 1
449 uint8_t nonzeroscale = (scale != 0) ? 1 : 0;
450 i = (i == 0) ? 0 : (((int)i * (int)(scale)) >> 8) + nonzeroscale;
451 j = (j == 0) ? 0 : (((int)j * (int)(scale)) >> 8) + nonzeroscale;
452#elif SCALE8_AVRASM == 1
455 cleanup_R1();
456#else
457#error "No implementation for nscale8x2 available."
458#endif
459}
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 void nscale8_video_LEAVING_R1_DIRTY(uint8_t &i, fract8 scale)
In place modifying version of scale8_video() that does not clean up the R1 register on AVR.
Definition scale8.h:311

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

+ Here is the call graph for this function: