From e1a711d787a280b32e6ffdc9294f30591f82af7f Mon Sep 17 00:00:00 2001 From: Daniel Garcia Date: Tue, 16 Feb 2016 20:41:24 -0800 Subject: Tweak getAverageLight to do the right thing in a fixed scale8 world --- pixeltypes.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'pixeltypes.h') diff --git a/pixeltypes.h b/pixeltypes.h index 5c7682f5..7d944f8e 100644 --- a/pixeltypes.h +++ b/pixeltypes.h @@ -461,10 +461,14 @@ struct CRGB { /// Get the average of the R, G, and B values inline uint8_t getAverageLight( ) const { - const uint8_t eightysix = 86; - uint8_t avg = scale8_LEAVING_R1_DIRTY( r, eightysix) + \ - scale8_LEAVING_R1_DIRTY( g, eightysix) + \ - scale8_LEAVING_R1_DIRTY( b, eightysix); +#if FASTLED_SCALE8_FIXED == 1 + const uint8_t eightyfive = 85; +#else + const uint8_t eightyfive = 86; +#endif + uint8_t avg = scale8_LEAVING_R1_DIRTY( r, eightyfive) + \ + scale8_LEAVING_R1_DIRTY( g, eightyfive) + \ + scale8_LEAVING_R1_DIRTY( b, eightyfive); cleanup_R1(); return avg; } -- cgit v1.2.3