diff --git a/src/NeoPixelBus.h b/src/NeoPixelBus.h index 566748a..295f497 100644 --- a/src/NeoPixelBus.h +++ b/src/NeoPixelBus.h @@ -389,6 +389,12 @@ protected: return T_COLOR_FEATURE::pixels(_method.getData()); } + const uint8_t* _pixels() const + { + // get pixels data within the data stream + return T_COLOR_FEATURE::pixels(_method.getData()); + } + void _rotateLeft(uint16_t rotationCount, uint16_t first, uint16_t last) { // store in temp diff --git a/src/internal/DotStarColorFeatures.h b/src/internal/DotStarColorFeatures.h index 0ab2001..2239c8d 100644 --- a/src/internal/DotStarColorFeatures.h +++ b/src/internal/DotStarColorFeatures.h @@ -175,6 +175,11 @@ public: { return pData; } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } }; class DotStar4ElementsNoSettings : public DotStar4Elements @@ -191,6 +196,11 @@ public: { return pData; } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } }; class DotStarBgrFeature : public DotStar3ElementsNoSettings @@ -206,10 +216,10 @@ public: *p = color.R; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.B = *p++; @@ -247,10 +257,10 @@ public: *p = color.R; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.B = *p++; @@ -288,10 +298,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.G = *p++; @@ -329,10 +339,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.G = *p++; @@ -371,10 +381,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.R = *p++; @@ -412,10 +422,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.R = *p++; @@ -453,10 +463,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.R = *p++; @@ -494,10 +504,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.R = *p++; @@ -536,10 +546,10 @@ public: *p = color.R; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.G = *p++; @@ -577,10 +587,10 @@ public: *p = color.R; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.G = *p++; @@ -618,10 +628,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte color.B = *p++; @@ -659,10 +669,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = (*p++) & 0x1F; // mask out upper three bits color.B = *p++; diff --git a/src/internal/Lpd8806ColorFeatures.h b/src/internal/Lpd8806ColorFeatures.h index 2dade10..a7c5a43 100644 --- a/src/internal/Lpd8806ColorFeatures.h +++ b/src/internal/Lpd8806ColorFeatures.h @@ -101,10 +101,10 @@ public: *p = (color.G >> 1) | 0x80; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.B = (*p++) << 1; color.R = (*p++) << 1; @@ -139,10 +139,10 @@ public: *p = (color.B >> 1) | 0x80; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.G = (*p++) << 1; color.R = (*p++) << 1; diff --git a/src/internal/NeoColorFeatures.h b/src/internal/NeoColorFeatures.h index 257c682..d76862e 100644 --- a/src/internal/NeoColorFeatures.h +++ b/src/internal/NeoColorFeatures.h @@ -162,6 +162,11 @@ public: { return pData; } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } }; class Neo4ElementsNoSettings : public Neo4Elements @@ -178,6 +183,11 @@ public: { return pData; } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } }; class NeoGrbFeature : public Neo3ElementsNoSettings @@ -192,10 +202,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.G = *p++; color.R = *p++; @@ -231,10 +241,10 @@ public: *p = color.W; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.G = *p++; color.R = *p++; @@ -273,10 +283,10 @@ public: *p = color.W; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.R = *p++; color.G = *p++; @@ -313,10 +323,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.R = *p++; color.G = *p++; @@ -351,10 +361,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.B = *p++; color.R = *p++; @@ -389,10 +399,10 @@ public: *p = color.G; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.R = *p++; color.B = *p++; diff --git a/src/internal/NeoSegmentFeatures.h b/src/internal/NeoSegmentFeatures.h index 9e5ea54..f0118f6 100644 --- a/src/internal/NeoSegmentFeatures.h +++ b/src/internal/NeoSegmentFeatures.h @@ -98,10 +98,10 @@ public: } } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); uint8_t commonSize = (PixelSize < color.SegmentCount) ? PixelSize : color.SegmentCount; for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++) diff --git a/src/internal/NeoTm1814ColorFeatures.h b/src/internal/NeoTm1814ColorFeatures.h index 729b560..bc5035f 100644 --- a/src/internal/NeoTm1814ColorFeatures.h +++ b/src/internal/NeoTm1814ColorFeatures.h @@ -80,6 +80,11 @@ public: { return pData + SettingsSize; } + + static const uint8_t* pixels(const uint8_t* pData) + { + return pData; + } }; @@ -96,10 +101,10 @@ public: *p = color.B; } - static ColorObject retrievePixelColor(uint8_t* pPixels, uint16_t indexPixel) + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) { ColorObject color; - uint8_t* p = getPixelAddress(pPixels, indexPixel); + const uint8_t* p = getPixelAddress(pPixels, indexPixel); color.W = *p++; color.R = *p++;