8#pragma GCC diagnostic push
9#pragma GCC diagnostic ignored "-Wunused-parameter"
10#pragma GCC diagnostic ignored "-Wreturn-type"
42#if (FASTLED_SCALE8_FIXED == 1)
43 return (((uint16_t)i) * (1 + (uint16_t)(
scale))) >> 8;
45 return ((uint16_t)i * (uint16_t)(
scale)) >> 8;
47#elif SCALE8_AVRASM == 1
48#if defined(LIB8_ATTINY)
49#if (FASTLED_SCALE8_FIXED == 1)
56#if (FASTLED_SCALE8_FIXED == 1)
67 " sbrc %[scale], 0 \n\t"
68 " add %[work], %[i] \n\t"
74 : [work]
"+r"(work), [cnt]
"+r"(cnt)
80#if (FASTLED_SCALE8_FIXED == 1)
96 "clr __zero_reg__ \n\t"
106#error "No implementation for scale8 available."
111 return (((uint16_t)i) * (1 + (uint16_t)(
scale))) >> 8;
124#if SCALE8_C == 1 || defined(LIB8_ATTINY)
125 uint8_t j = (((int)i * (int)
scale) >> 8) + ((i &&
scale) ? 1 : 0);
130#elif SCALE8_AVRASM == 1
132 asm volatile(
" tst %[i]\n\t"
134 " mul %[i], %[scale]\n\t"
136 " clr __zero_reg__\n\t"
137 " cpse %[scale], r1\n\t"
138 " subi %[j], 0xFF\n\t"
159#error "No implementation for scale8_video available."
179#if (FASTLED_SCALE8_FIXED == 1)
180 return (((uint16_t)i) * ((uint16_t)(
scale) + 1)) >> 8;
182 return ((
int)i * (
int)(
scale)) >> 8;
184#elif SCALE8_AVRASM == 1
186#if (FASTLED_SCALE8_FIXED == 1)
210#error "No implementation for scale8_LEAVING_R1_DIRTY available."
226#if (FASTLED_SCALE8_FIXED == 1)
227 i = (((uint16_t)i) * ((uint16_t)(
scale) + 1)) >> 8;
229 i = ((int)i * (int)(
scale)) >> 8;
231#elif SCALE8_AVRASM == 1
233#if (FASTLED_SCALE8_FIXED == 1)
256#error "No implementation for nscale8_LEAVING_R1_DIRTY available."
270#if SCALE8_C == 1 || defined(LIB8_ATTINY)
271 uint8_t j = (((int)i * (int)
scale) >> 8) + ((i &&
scale) ? 1 : 0);
276#elif SCALE8_AVRASM == 1
278 asm volatile(
" tst %[i]\n\t"
280 " mul %[i], %[scale]\n\t"
283 " subi %[j], 0xFF\n\t"
304#error "No implementation for scale8_video_LEAVING_R1_DIRTY available."
319#if SCALE8_C == 1 || defined(LIB8_ATTINY)
320 i = (((int)i * (int)
scale) >> 8) + ((i &&
scale) ? 1 : 0);
321#elif SCALE8_AVRASM == 1
322 asm volatile(
" tst %[i]\n\t"
324 " mul %[i], %[scale]\n\t"
327 " subi %[i], 0xFF\n\t"
333#error "No implementation for scale8_video_LEAVING_R1_DIRTY available."
340#if CLEANUP_R1_AVRASM == 1
342 asm volatile(
"clr __zero_reg__ \n\t" : : :
"r1");
347 return CRGB(((
int)r * (
int)(
scale)) >> 8, ((
int)g * (
int)(
scale)) >> 8,
348 ((
int)b * (
int)(
scale)) >> 8);
365#if (FASTLED_SCALE8_FIXED == 1)
366 uint16_t scale_fixed =
scale + 1;
367 r = (((uint16_t)r) * scale_fixed) >> 8;
368 g = (((uint16_t)g) * scale_fixed) >> 8;
369 b = (((uint16_t)b) * scale_fixed) >> 8;
371 r = ((int)r * (int)(
scale)) >> 8;
372 g = ((int)g * (int)(
scale)) >> 8;
373 b = ((int)b * (int)(
scale)) >> 8;
375#elif SCALE8_AVRASM == 1
381#error "No implementation for nscale8x3 available."
400 uint8_t nonzeroscale = (
scale != 0) ? 1 : 0;
401 r = (r == 0) ? 0 : (((int)r * (int)(
scale)) >> 8) + nonzeroscale;
402 g = (g == 0) ? 0 : (((int)g * (int)(
scale)) >> 8) + nonzeroscale;
403 b = (b == 0) ? 0 : (((int)b * (int)(
scale)) >> 8) + nonzeroscale;
404#elif SCALE8_AVRASM == 1
410#error "No implementation for nscale8x3 available."
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;
430 i = ((uint16_t)i * (uint16_t)(
scale)) >> 8;
431 j = ((uint16_t)j * (uint16_t)(
scale)) >> 8;
433#elif SCALE8_AVRASM == 1
438#error "No implementation for nscale8x2 available."
455 uint8_t nonzeroscale = (
scale != 0) ? 1 : 0;
456 i = (i == 0) ? 0 : (((int)i * (int)(
scale)) >> 8) + nonzeroscale;
457 j = (j == 0) ? 0 : (((int)j * (int)(
scale)) >> 8) + nonzeroscale;
458#elif SCALE8_AVRASM == 1
463#error "No implementation for nscale8x2 available."
481#if FASTLED_SCALE8_FIXED == 1
482 result = (((uint32_t)(i) * (1 + ((uint32_t)
scale))) >> 8);
484 result = (i *
scale) / 256;
487#elif SCALE16BY8_AVRASM == 1
488#if FASTLED_SCALE8_FIXED == 1
492 " mul %A[i], %[scale] \n\t"
493 " add r0, %A[i] \n\t"
496 " adc %A[result], r1 \n\t"
499 " mul %B[i], %[scale] \n\t"
500 " add %A[result], r0 \n\t"
501 " adc %B[result], r1 \n\t"
504 " clr __zero_reg__ \n\t"
507 " add %A[result], %B[i] \n\t"
508 " adc %B[result], __zero_reg__ \n\t"
510 : [result]
"+r"(result)
518 " mul %A[i], %[scale] \n\t"
519 " mov %A[result], r1 \n\t"
523 " mul %B[i], %[scale] \n\t"
524 " add %A[result], r0 \n\t"
525 " adc %B[result], r1 \n\t"
528 " clr __zero_reg__ \n\t"
530 : [result]
"+r"(result)
536#error "No implementation for scale16by8 available."
549#if FASTLED_SCALE8_FIXED == 1
550 result = ((uint32_t)(i) * (1 + (uint32_t)(
scale))) / 65536;
552 result = ((uint32_t)(i) * (uint32_t)(
scale)) / 65536;
555#elif SCALE16_AVRASM == 1
556#if FASTLED_SCALE8_FIXED == 1
567 " mul %A[i], %A[scale] \n\t"
573 " movw %A[result], r0 \n\t"
579 : [result]
"=r"(result)
585 " mul %B[i], %B[scale] \n\t"
588 " movw %C[result], r0 \n\t"
589 : [result]
"+r"(result)
593 const uint8_t zero = 0;
596 " mul %B[i], %A[scale] \n\t"
598 " add %B[result], r0 \n\t"
599 " adc %C[result], r1 \n\t"
600 " adc %D[result], %[zero] \n\t"
603 " mul %A[i], %B[scale] \n\t"
605 " add %B[result], r0 \n\t"
606 " adc %C[result], r1 \n\t"
607 " adc %D[result], %[zero] \n\t"
612 : [result]
"+r"(result)
613 : [i]
"r"(i), [
scale]
"r"(
scale), [zero]
"r"(zero)
618 " add %A[result], %A[i] \n\t"
619 " adc %B[result], %B[i] \n\t"
620 " adc %C[result], %[zero] \n\t"
621 " adc %D[result], %[zero] \n\t"
622 : [result]
"+r"(result)
623 : [i]
"r"(i), [zero]
"r"(zero));
625 result = result >> 16;
631 " mul %A[i], %A[scale] \n\t"
637 " movw %A[result], r0 \n\t"
645 : [result]
"=r"(result)
651 " mul %B[i], %B[scale] \n\t"
654 " movw %C[result], r0 \n\t"
655 : [result]
"+r"(result)
659 const uint8_t zero = 0;
662 " mul %B[i], %A[scale] \n\t"
664 " add %B[result], r0 \n\t"
665 " adc %C[result], r1 \n\t"
666 " adc %D[result], %[zero] \n\t"
669 " mul %A[i], %B[scale] \n\t"
671 " add %B[result], r0 \n\t"
672 " adc %C[result], r1 \n\t"
673 " adc %D[result], %[zero] \n\t"
678 : [result]
"+r"(result)
679 : [i]
"r"(i), [
scale]
"r"(
scale), [zero]
"r"(zero)
682 result = result >> 16;
686#error "No implementation for scale16 available."
728 uint8_t ix = 255 -
x;
729 return 255 -
scale8(ix, ix);
734 uint8_t ix = 255 -
x;
740 uint8_t ix = 255 -
x;
755#pragma GCC diagnostic pop
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())
uint8_t fract8
ANSI: unsigned short _Fract.
uint16_t fract16
ANSI: unsigned _Fract.
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
Implements the FastLED namespace macros.
Representation of an RGB pixel (Red, Green, Blue)