Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackw01 <jackw01@users.noreply.github.com>2020-02-07 06:04:52 +0300
committerjackw01 <jackw01@users.noreply.github.com>2020-02-07 06:04:52 +0300
commit3fb73d4ddf4d20e16e013cd931189a30e9c55b4a (patch)
tree0be2ac569eb5966567d6d776fa3ad92693a107b7
parentfefc5f563a33963b9998f0475ad050813b30adcb (diff)
overload array subscript operator for CHSV structs like it is for CRGB
-rw-r--r--pixeltypes.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/pixeltypes.h b/pixeltypes.h
index ff327fd9..f4e57061 100644
--- a/pixeltypes.h
+++ b/pixeltypes.h
@@ -38,6 +38,18 @@ struct CHSV {
uint8_t raw[3];
};
+ /// Array access operator to index into the chsv object
+ inline uint8_t& operator[] (uint8_t x) __attribute__((always_inline))
+ {
+ return raw[x];
+ }
+
+ /// Array access operator to index into the chsv object
+ inline const uint8_t& operator[] (uint8_t x) const __attribute__((always_inline))
+ {
+ return raw[x];
+ }
+
/// default values are UNITIALIZED
inline CHSV() __attribute__((always_inline))
{
@@ -106,7 +118,7 @@ struct CRGB {
uint8_t raw[3];
};
- /// Array access operator to index into the crgb object
+ /// Array access operator to index into the crgb object
inline uint8_t& operator[] (uint8_t x) __attribute__((always_inline))
{
return raw[x];
@@ -478,7 +490,7 @@ struct CRGB {
uint8_t max = red;
if( green > max) max = green;
if( blue > max) max = blue;
-
+
// stop div/0 when color is black
if(max > 0) {
uint16_t factor = ((uint16_t)(limit) * 256) / max;