46#if (FASTLED_SCALE8_FIXED == 1)
47 return (((uint16_t)i) * (1 + (uint16_t)(
scale))) >> 8;
49 return ((uint16_t)i * (uint16_t)(
scale)) >> 8;
51#elif SCALE8_AVRASM == 1
52#if defined(LIB8_ATTINY)
53#if (FASTLED_SCALE8_FIXED == 1)
60#if (FASTLED_SCALE8_FIXED == 1)
71 " sbrc %[scale], 0 \n\t"
72 " add %[work], %[i] \n\t"
78 : [work]
"+r"(work), [cnt]
"+r"(cnt)
84#if (FASTLED_SCALE8_FIXED == 1)
100 "clr __zero_reg__ \n\t"
110#error "No implementation for scale8 available."
115 return (((uint16_t)i) * (1 + (uint16_t)(
scale))) >> 8;
128#if SCALE8_C == 1 || defined(LIB8_ATTINY)
129 uint8_t j = (((int)i * (int)
scale) >> 8) + ((i &&
scale) ? 1 : 0);
134#elif SCALE8_AVRASM == 1
136 asm volatile(
" tst %[i]\n\t"
138 " mul %[i], %[scale]\n\t"
140 " clr __zero_reg__\n\t"
141 " cpse %[scale], r1\n\t"
142 " subi %[j], 0xFF\n\t"
163#error "No implementation for scale8_video available."
183#if (FASTLED_SCALE8_FIXED == 1)
184 return (((uint16_t)i) * ((uint16_t)(
scale) + 1)) >> 8;
186 return ((
int)i * (
int)(
scale)) >> 8;
188#elif SCALE8_AVRASM == 1
190#if (FASTLED_SCALE8_FIXED == 1)
214#error "No implementation for scale8_LEAVING_R1_DIRTY available."
230#if (FASTLED_SCALE8_FIXED == 1)
231 i = (((uint16_t)i) * ((uint16_t)(
scale) + 1)) >> 8;
233 i = ((int)i * (int)(
scale)) >> 8;
235#elif SCALE8_AVRASM == 1
237#if (FASTLED_SCALE8_FIXED == 1)
260#error "No implementation for nscale8_LEAVING_R1_DIRTY available."
274#if SCALE8_C == 1 || defined(LIB8_ATTINY)
275 uint8_t j = (((int)i * (int)
scale) >> 8) + ((i &&
scale) ? 1 : 0);
280#elif SCALE8_AVRASM == 1
282 asm volatile(
" tst %[i]\n\t"
284 " mul %[i], %[scale]\n\t"
287 " subi %[j], 0xFF\n\t"
308#error "No implementation for scale8_video_LEAVING_R1_DIRTY available."
323#if SCALE8_C == 1 || defined(LIB8_ATTINY)
324 i = (((int)i * (int)
scale) >> 8) + ((i &&
scale) ? 1 : 0);
325#elif SCALE8_AVRASM == 1
326 asm volatile(
" tst %[i]\n\t"
328 " mul %[i], %[scale]\n\t"
331 " subi %[i], 0xFF\n\t"
337#error "No implementation for scale8_video_LEAVING_R1_DIRTY available."
344#if CLEANUP_R1_AVRASM == 1
346 asm volatile(
"clr __zero_reg__ \n\t" : : :
"r1");
351 return CRGB(((
int)r * (
int)(
scale)) >> 8, ((
int)g * (
int)(
scale)) >> 8,
352 ((
int)b * (
int)(
scale)) >> 8);
369#if (FASTLED_SCALE8_FIXED == 1)
370 uint16_t scale_fixed =
scale + 1;
371 r = (((uint16_t)r) * scale_fixed) >> 8;
372 g = (((uint16_t)g) * scale_fixed) >> 8;
373 b = (((uint16_t)b) * scale_fixed) >> 8;
375 r = ((int)r * (int)(
scale)) >> 8;
376 g = ((int)g * (int)(
scale)) >> 8;
377 b = ((int)b * (int)(
scale)) >> 8;
379#elif SCALE8_AVRASM == 1
385#error "No implementation for nscale8x3 available."
404 uint8_t nonzeroscale = (
scale != 0) ? 1 : 0;
405 r = (r == 0) ? 0 : (((int)r * (int)(
scale)) >> 8) + nonzeroscale;
406 g = (g == 0) ? 0 : (((int)g * (int)(
scale)) >> 8) + nonzeroscale;
407 b = (b == 0) ? 0 : (((int)b * (int)(
scale)) >> 8) + nonzeroscale;
408#elif SCALE8_AVRASM == 1
414#error "No implementation for nscale8x3 available."
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;
434 i = ((uint16_t)i * (uint16_t)(
scale)) >> 8;
435 j = ((uint16_t)j * (uint16_t)(
scale)) >> 8;
437#elif SCALE8_AVRASM == 1
442#error "No implementation for nscale8x2 available."
459 uint8_t nonzeroscale = (
scale != 0) ? 1 : 0;
460 i = (i == 0) ? 0 : (((int)i * (int)(
scale)) >> 8) + nonzeroscale;
461 j = (j == 0) ? 0 : (((int)j * (int)(
scale)) >> 8) + nonzeroscale;
462#elif SCALE8_AVRASM == 1
467#error "No implementation for nscale8x2 available."
485#if FASTLED_SCALE8_FIXED == 1
486 result = (((uint32_t)(i) * (1 + ((uint32_t)
scale))) >> 8);
488 result = (i *
scale) / 256;
491#elif SCALE16BY8_AVRASM == 1
492#if FASTLED_SCALE8_FIXED == 1
496 " mul %A[i], %[scale] \n\t"
497 " add r0, %A[i] \n\t"
500 " adc %A[result], r1 \n\t"
503 " mul %B[i], %[scale] \n\t"
504 " add %A[result], r0 \n\t"
505 " adc %B[result], r1 \n\t"
508 " clr __zero_reg__ \n\t"
511 " add %A[result], %B[i] \n\t"
512 " adc %B[result], __zero_reg__ \n\t"
514 : [result]
"+r"(result)
522 " mul %A[i], %[scale] \n\t"
523 " mov %A[result], r1 \n\t"
527 " mul %B[i], %[scale] \n\t"
528 " add %A[result], r0 \n\t"
529 " adc %B[result], r1 \n\t"
532 " clr __zero_reg__ \n\t"
534 : [result]
"+r"(result)
540#error "No implementation for scale16by8 available."
554#if FASTLED_SCALE8_FIXED == 1
555 result = ((uint32_t)(i) * (1 + (uint32_t)(
scale))) / 65536;
557 result = ((uint32_t)(i) * (uint32_t)(
scale)) / 65536;
560#elif SCALE16_AVRASM == 1
561#if FASTLED_SCALE8_FIXED == 1
572 " mul %A[i], %A[scale] \n\t"
578 " movw %A[result], r0 \n\t"
584 : [result]
"=r"(result)
590 " mul %B[i], %B[scale] \n\t"
593 " movw %C[result], r0 \n\t"
594 : [result]
"+r"(result)
598 const uint8_t zero = 0;
601 " mul %B[i], %A[scale] \n\t"
603 " add %B[result], r0 \n\t"
604 " adc %C[result], r1 \n\t"
605 " adc %D[result], %[zero] \n\t"
608 " mul %A[i], %B[scale] \n\t"
610 " add %B[result], r0 \n\t"
611 " adc %C[result], r1 \n\t"
612 " adc %D[result], %[zero] \n\t"
617 : [result]
"+r"(result)
618 : [i]
"r"(i), [
scale]
"r"(
scale), [zero]
"r"(zero)
623 " add %A[result], %A[i] \n\t"
624 " adc %B[result], %B[i] \n\t"
625 " adc %C[result], %[zero] \n\t"
626 " adc %D[result], %[zero] \n\t"
627 : [result]
"+r"(result)
628 : [i]
"r"(i), [zero]
"r"(zero));
630 result = result >> 16;
636 " mul %A[i], %A[scale] \n\t"
642 " movw %A[result], r0 \n\t"
650 : [result]
"=r"(result)
656 " mul %B[i], %B[scale] \n\t"
659 " movw %C[result], r0 \n\t"
660 : [result]
"+r"(result)
664 const uint8_t zero = 0;
667 " mul %B[i], %A[scale] \n\t"
669 " add %B[result], r0 \n\t"
670 " adc %C[result], r1 \n\t"
671 " adc %D[result], %[zero] \n\t"
674 " mul %A[i], %B[scale] \n\t"
676 " add %B[result], r0 \n\t"
677 " adc %C[result], r1 \n\t"
678 " adc %D[result], %[zero] \n\t"
683 : [result]
"+r"(result)
684 : [i]
"r"(i), [
scale]
"r"(
scale), [zero]
"r"(zero)
687 result = result >> 16;
691#error "No implementation for scale16 available."
733 uint8_t ix = 255 -
x;
734 return 255 -
scale8(ix, ix);
739 uint8_t ix = 255 -
x;
745 uint8_t ix = 255 -
x;
760#pragma GCC diagnostic pop
#define FL_DISABLE_WARNING_RETURN_TYPE
#define FL_DISABLE_WARNING_IMPLICIT_INT_CONVERSION
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_UNUSED_PARAMETER
Defines the red, green, and blue (RGB) pixel struct.
Contains definitions that can be used to configure FastLED at compile time.
LIB8STATIC uint8_t brighten8_lin(uint8_t x)
Brighten a value (inverse of dim8_lin())
LIB8STATIC uint8_t dim8_lin(uint8_t x)
Linear version of the dimming function that halves for values < 128.
LIB8STATIC uint8_t dim8_video(uint8_t x)
Adjust a scaling value for dimming for video (value will never go below 1)
LIB8STATIC uint8_t brighten8_video(uint8_t x)
Brighten a value (inverse of dim8_video())
LIB8STATIC uint8_t dim8_raw(uint8_t x)
Adjust a scaling value for dimming.
LIB8STATIC uint8_t brighten8_raw(uint8_t x)
Brighten a value (inverse of dim8_raw())
LIB8STATIC_ALWAYS_INLINE void nscale8_LEAVING_R1_DIRTY(uint8_t &i, fract8 scale)
In place modifying version of scale8() that does not clean up the R1 register on AVR.
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
constexpr CRGB nscale8x3_constexpr(uint8_t r, uint8_t g, uint8_t b, fract8 scale)
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.
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.
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_video_LEAVING_R1_DIRTY(uint8_t i, fract8 scale)
This version of scale8_video() does not clean up the R1 register on AVR.
LIB8STATIC uint16_t scale16(uint16_t i, fract16 scale)
Scale a 16-bit unsigned value by an 16-bit value, which is treated as the numerator of a fraction who...
LIB8STATIC void nscale8x3(uint8_t &r, uint8_t &g, uint8_t &b, fract8 scale)
Scale three one-byte values by a fourth one, which is treated as the numerator of a fraction whose de...
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 demom...
LIB8STATIC_ALWAYS_INLINE uint8_t scale8_video(uint8_t i, fract8 scale)
The "video" version of scale8() guarantees that the output will be only be zero if one or both of the...
constexpr uint8_t scale8_constexpr(uint8_t i, fract8 scale)
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 demom...
LIB8STATIC void nscale8x3_video(uint8_t &r, uint8_t &g, uint8_t &b, fract8 scale)
Scale three one-byte values by a fourth one, which is treated as the numerator of a fraction whose de...
LIB8STATIC_ALWAYS_INLINE uint16_t scale16by8(uint16_t i, fract8 scale)
Scale a 16-bit unsigned value by an 8-bit value, which is treated as the numerator of a fraction whos...
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
#define LIB8STATIC
Define a LIB8TION member function as static inline with an "unused" attribute.
#define LIB8STATIC_ALWAYS_INLINE
Define a LIB8TION member function as always static inline.
Defines static inlining macros for lib8tion functions.
#define FASTLED_NAMESPACE_END
#define FASTLED_NAMESPACE_BEGIN
Implements the FastLED namespace macros.
u8 fract8
Fixed-Point Fractional Types.
u16 fract16
ANSI: unsigned _Fract.
Representation of an RGB pixel (Red, Green, Blue)