diff options
author | Daniel Garcia <danielgarcia@gmail.com> | 2016-02-17 07:41:24 +0300 |
---|---|---|
committer | Daniel Garcia <danielgarcia@gmail.com> | 2016-02-17 07:41:24 +0300 |
commit | e1a711d787a280b32e6ffdc9294f30591f82af7f (patch) | |
tree | f0faa5834bdbaab3461a7b7f1b06ff6a4473ff48 | |
parent | 181880a33abf9c4039faef6dd2614ba287e884f8 (diff) |
Tweak getAverageLight to do the right thing in a fixed scale8 world
-rw-r--r-- | pixeltypes.h | 12 |
1 files changed, 8 insertions, 4 deletions
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; } |