From ad6e3a334073f602e8ea4d06d42abc86bdda9f80 Mon Sep 17 00:00:00 2001 From: Mark Kriegsman Date: Tue, 16 Feb 2016 23:13:34 -0500 Subject: In ColorFromPalette(s), skip redundant (and overflowing) increment of values after scale8 if scale8 is 'fixed' --- colorutils.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 16 deletions(-) diff --git a/colorutils.cpp b/colorutils.cpp index 80c694af..f1de1466 100644 --- a/colorutils.cpp +++ b/colorutils.cpp @@ -549,10 +549,25 @@ CRGB ColorFromPalette( const CRGBPalette16& pal, uint8_t index, uint8_t brightne if( brightness ) { brightness++; // adjust for rounding // Now, since brightness is nonzero, we don't need the full scale8_video logic; - // we can just to scale8 and then add one to all nonzero inputs. - if( red1 ) { red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); red1++; } - if( green1 ) { green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); green1++; } - if( blue1 ) { blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); blue1++; } + // we can just to scale8 and then add one (unless scale8 fixed) to all nonzero inputs. + if( red1 ) { + red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + red1++; +#endif + } + if( green1 ) { + green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + green1++; +#endif + } + if( blue1 ) { + blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + blue1++; +#endif + } cleanup_R1(); } else { red1 = 0; @@ -612,10 +627,25 @@ CRGB ColorFromPalette( const TProgmemRGBPalette16& pal, uint8_t index, uint8_t b if( brightness ) { brightness++; // adjust for rounding // Now, since brightness is nonzero, we don't need the full scale8_video logic; - // we can just to scale8 and then add one to all nonzero inputs. - if( red1 ) { red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); red1++; } - if( green1 ) { green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); green1++; } - if( blue1 ) { blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); blue1++; } + // we can just to scale8 and then add one (unless scale8 fixed) to all nonzero inputs. + if( red1 ) { + red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + red1++; +#endif + } + if( green1 ) { + green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + green1++; +#endif + } + if( blue1 ) { + blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + blue1++; +#endif + } cleanup_R1(); } else { red1 = 0; @@ -688,10 +718,25 @@ CRGB ColorFromPalette( const CRGBPalette32& pal, uint8_t index, uint8_t brightne if( brightness ) { brightness++; // adjust for rounding // Now, since brightness is nonzero, we don't need the full scale8_video logic; - // we can just to scale8 and then add one to all nonzero inputs. - if( red1 ) { red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); red1++; } - if( green1 ) { green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); green1++; } - if( blue1 ) { blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); blue1++; } + // we can just to scale8 and then add one (unless scale8 fixed) to all nonzero inputs. + if( red1 ) { + red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + red1++; +#endif + } + if( green1 ) { + green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + green1++; +#endif + } + if( blue1 ) { + blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + blue1++; +#endif + } cleanup_R1(); } else { red1 = 0; @@ -757,10 +802,25 @@ CRGB ColorFromPalette( const TProgmemRGBPalette32& pal, uint8_t index, uint8_t b if( brightness ) { brightness++; // adjust for rounding // Now, since brightness is nonzero, we don't need the full scale8_video logic; - // we can just to scale8 and then add one to all nonzero inputs. - if( red1 ) { red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); red1++; } - if( green1 ) { green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); green1++; } - if( blue1 ) { blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); blue1++; } + // we can just to scale8 and then add one (unless scale8 fixed) to all nonzero inputs. + if( red1 ) { + red1 = scale8_LEAVING_R1_DIRTY( red1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + red1++; +#endif + } + if( green1 ) { + green1 = scale8_LEAVING_R1_DIRTY( green1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + green1++; +#endif + } + if( blue1 ) { + blue1 = scale8_LEAVING_R1_DIRTY( blue1, brightness); +#if !(FASTLED_SCALE8_FIXED==1) + blue1++; +#endif + } cleanup_R1(); } else { red1 = 0; -- cgit v1.2.3