From 57bee072739048d617c3aec6e4400f7a5eabced8 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Mon, 5 Jun 2023 08:17:18 -0700 Subject: [PATCH] Refactor Feature Elements core (#710) * refactor byte elements * Word elements * refactor no settings core * refactor 2 byte 555 encoding --- src/internal/NeoColorFeatures.h | 15 +- src/internal/buffers/NeoBuffer.h | 20 ++- src/internal/buffers/NeoBufferMethods.h | 5 +- src/internal/features/DotStar4Elements.h | 117 --------------- src/internal/features/DotStarBgrFeature.h | 4 +- src/internal/features/DotStarBrgFeature.h | 4 +- src/internal/features/DotStarGbrFeature.h | 4 +- src/internal/features/DotStarGrbFeature.h | 4 +- src/internal/features/DotStarLbgrFeature.h | 4 +- src/internal/features/DotStarLbrgFeature.h | 4 +- src/internal/features/DotStarLgbrFeature.h | 4 +- src/internal/features/DotStarLgrbFeature.h | 4 +- src/internal/features/DotStarLrbgFeature.h | 4 +- src/internal/features/DotStarLrgbFeature.h | 4 +- src/internal/features/DotStarRbgFeature.h | 4 +- src/internal/features/DotStarRgbFeature.h | 4 +- src/internal/features/Lpd6803BrgFeature.h | 5 +- src/internal/features/Lpd6803GbrFeature.h | 5 +- src/internal/features/Lpd6803GrbFeature.h | 5 +- src/internal/features/Lpd6803RgbFeature.h | 5 +- src/internal/features/Lpd8806BrgFeature.h | 4 +- src/internal/features/Lpd8806GrbFeature.h | 4 +- src/internal/features/Neo2Byte555Elements.h | 46 ++++++ src/internal/features/Neo2ByteElements.h | 122 --------------- src/internal/features/Neo3ByteElements.h | 110 -------------- src/internal/features/Neo4ByteElements.h | 125 ---------------- src/internal/features/Neo6Byte4xxElements.h | 116 --------------- src/internal/features/Neo6ByteElements.h | 115 --------------- src/internal/features/Neo8ByteElements.h | 115 --------------- src/internal/features/Neo9ByteElements.h | 106 ------------- .../features/NeoAbcdefgpsSegmentFeature.h | 4 +- .../features/NeoBacedfpgsSegmentFeature.h | 4 +- src/internal/features/NeoBgrFeature.h | 4 +- src/internal/features/NeoBrgFeature.h | 4 +- src/internal/features/NeoByteElements.h | 139 ++++++++++++++++++ ...tar3Elements.h => NeoElementsNoSettings.h} | 6 +- src/internal/features/NeoGrb48Feature.h | 13 +- src/internal/features/NeoGrbFeature.h | 4 +- src/internal/features/NeoGrbwFeature.h | 4 +- src/internal/features/NeoRbgFeature.h | 4 +- src/internal/features/NeoRgb48Feature.h | 13 +- src/internal/features/NeoRgbFeature.h | 4 +- src/internal/features/NeoRgbw64Feature.h | 16 +- src/internal/features/NeoRgbwFeature.h | 4 +- src/internal/features/NeoRgbwxxFeature.h | 4 +- .../features/NeoSm168xxColorFeatures.h | 4 +- .../features/NeoTm1814ColorFeatures.h | 4 +- .../features/NeoTm1914ColorFeatures.h | 2 +- src/internal/features/P9813BgrFeature.h | 4 +- 49 files changed, 334 insertions(+), 995 deletions(-) delete mode 100644 src/internal/features/DotStar4Elements.h create mode 100644 src/internal/features/Neo2Byte555Elements.h delete mode 100644 src/internal/features/Neo2ByteElements.h delete mode 100644 src/internal/features/Neo3ByteElements.h delete mode 100644 src/internal/features/Neo4ByteElements.h delete mode 100644 src/internal/features/Neo6Byte4xxElements.h delete mode 100644 src/internal/features/Neo6ByteElements.h delete mode 100644 src/internal/features/Neo8ByteElements.h delete mode 100644 src/internal/features/Neo9ByteElements.h create mode 100644 src/internal/features/NeoByteElements.h rename src/internal/features/{DotStar3Elements.h => NeoElementsNoSettings.h} (88%) diff --git a/src/internal/NeoColorFeatures.h b/src/internal/NeoColorFeatures.h index 12ea4e9..83f77bf 100644 --- a/src/internal/NeoColorFeatures.h +++ b/src/internal/NeoColorFeatures.h @@ -26,14 +26,14 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once +// Core Element base classes +// +#include "features/NeoElementsNoSettings.h" +#include "features/NeoByteElements.h" +#include "features/Neo2Byte555Elements.h" + // NeoPixel Features // -#include "features/Neo2ByteElements.h" -#include "features/Neo3ByteElements.h" -#include "features/Neo4ByteElements.h" -#include "features/Neo6ByteElements.h" -#include "features/Neo6Byte4xxElements.h" -#include "features/Neo8ByteElements.h" #include "features/NeoBgrFeature.h" #include "features/NeoBrgFeature.h" #include "features/NeoGrb48Feature.h" @@ -55,8 +55,6 @@ typedef NeoGrb48Feature NeoGrbWs2816Feature; // DotStart Features // -#include "features/DotStar3Elements.h" -#include "features/DotStar4Elements.h" #include "features/DotStarBgrFeature.h" #include "features/DotStarBrgFeature.h" #include "features/DotStarGbrFeature.h" @@ -79,7 +77,6 @@ typedef NeoGrb48Feature NeoGrbWs2816Feature; // 7 Segment Features // -#include "features/Neo9ByteElements.h" #include "features/NeoAbcdefgpsSegmentFeature.h" #include "features/NeoBacedfpgsSegmentFeature.h" diff --git a/src/internal/buffers/NeoBuffer.h b/src/internal/buffers/NeoBuffer.h index c2501c7..fa18994 100644 --- a/src/internal/buffers/NeoBuffer.h +++ b/src/internal/buffers/NeoBuffer.h @@ -34,11 +34,15 @@ template class NeoBuffer public: NeoBuffer(uint16_t width, uint16_t height, - PGM_VOID_P pixels) : + PGM_VOID_P pixels = nullptr) : _method(width, height, pixels) { } + ~NeoBuffer() + { + } + operator NeoBufferContext() { return _method; @@ -64,14 +68,14 @@ public: int16_t y, typename T_BUFFER_METHOD::ColorObject color) { - _method.SetPixelColor(pixelIndex(x, y), color); + _method.SetPixelColor(PixelIndex(x, y), color); }; typename T_BUFFER_METHOD::ColorObject GetPixelColor( int16_t x, int16_t y) const { - return _method.GetPixelColor(pixelIndex(x, y)); + return _method.GetPixelColor(PixelIndex(x, y)); }; void ClearTo(typename T_BUFFER_METHOD::ColorObject color) @@ -120,7 +124,7 @@ public: if (indexDest < destPixelCount) { - const uint8_t* pSrc = T_BUFFER_METHOD::ColorFeature::getPixelAddress(_method.Pixels(), pixelIndex(xSrc + x, ySrc + y)); + const uint8_t* pSrc = T_BUFFER_METHOD::ColorFeature::getPixelAddress(_method.Pixels(), PixelIndex(xSrc + x, ySrc + y)); uint8_t* pDest = T_BUFFER_METHOD::ColorFeature::getPixelAddress(destBuffer.Pixels, indexDest); _method.CopyPixels(pDest, pSrc, 1); @@ -155,10 +159,7 @@ public: } } -private: - T_BUFFER_METHOD _method; - - uint16_t pixelIndex( + uint16_t PixelIndex( int16_t x, int16_t y) const { @@ -173,4 +174,7 @@ private: } return result; } + +private: + T_BUFFER_METHOD _method; }; \ No newline at end of file diff --git a/src/internal/buffers/NeoBufferMethods.h b/src/internal/buffers/NeoBufferMethods.h index 169e1ff..70ba1db 100644 --- a/src/internal/buffers/NeoBufferMethods.h +++ b/src/internal/buffers/NeoBufferMethods.h @@ -29,7 +29,7 @@ License along with NeoPixel. If not, see template class NeoBufferMethod { public: - NeoBufferMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels = NULL) : + NeoBufferMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels = nullptr) : _width(width), _height(height) { @@ -44,6 +44,7 @@ public: ~NeoBufferMethod() { free(_pixels); + _pixels = nullptr; } operator NeoBufferContext() @@ -143,7 +144,7 @@ public: typedef T_COLOR_FEATURE ColorFeature; private: - const uint16_t _width; + const uint16_t _width; const uint16_t _height; uint8_t* _pixels; }; diff --git a/src/internal/features/DotStar4Elements.h b/src/internal/features/DotStar4Elements.h deleted file mode 100644 index 09c2653..0000000 --- a/src/internal/features/DotStar4Elements.h +++ /dev/null @@ -1,117 +0,0 @@ -/*------------------------------------------------------------------------- -DotStar4Elements provides feature base classes to describe color elements -for NeoPixelBus Color Feature template classes when used with DotStars - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ -#pragma once - - -class DotStar4Elements -{ -public: - static const size_t PixelSize = 4; - - static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - - static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint8_t* pEnd = pPixelDest + (count * PixelSize); - while (pPixelDest < pEnd) - { - *pPixelDest++ = pPixelSrc[0]; - *pPixelDest++ = pPixelSrc[1]; - *pPixelDest++ = pPixelSrc[2]; - *pPixelDest++ = pPixelSrc[3]; - } - } - - static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint8_t* pEnd = pPixelDest + (count * PixelSize); - while (pPixelDest < pEnd) - { - *pPixelDest++ = *pPixelSrc++; - *pPixelDest++ = *pPixelSrc++; - *pPixelDest++ = *pPixelSrc++; - *pPixelDest++ = *pPixelSrc++; - } - } - - static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) - { - uint8_t* pEnd = pPixelDest + (count * PixelSize); - const uint8_t* pSrc = (const uint8_t*)pPixelSrc; - while (pPixelDest < pEnd) - { - *pPixelDest++ = pgm_read_byte(pSrc++); - *pPixelDest++ = pgm_read_byte(pSrc++); - *pPixelDest++ = pgm_read_byte(pSrc++); - *pPixelDest++ = pgm_read_byte(pSrc++); - } - } - - static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint8_t* pDestBack = pPixelDest + (count * PixelSize); - const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize); - while (pDestBack > pPixelDest) - { - *--pDestBack = *--pSrcBack; - *--pDestBack = *--pSrcBack; - *--pDestBack = *--pSrcBack; - *--pDestBack = *--pSrcBack; - } - } - - typedef RgbwColor ColorObject; -}; - - -class DotStar4ElementsNoSettings : public DotStar4Elements -{ -public: - typedef NeoNoSettings SettingsObject; - static const size_t SettingsSize = 0; - - static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings) - { - } - - static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } - - static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } -}; \ No newline at end of file diff --git a/src/internal/features/DotStarBgrFeature.h b/src/internal/features/DotStarBgrFeature.h index 30cf0d7..0581907 100644 --- a/src/internal/features/DotStarBgrFeature.h +++ b/src/internal/features/DotStarBgrFeature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once -class DotStarBgrFeature : public DotStar3ElementsNoSettings +class DotStarBgrFeature : + public NeoByteElements<4, RgbColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarBrgFeature.h b/src/internal/features/DotStarBrgFeature.h index 9edde6a..9a91e80 100644 --- a/src/internal/features/DotStarBrgFeature.h +++ b/src/internal/features/DotStarBrgFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class DotStarBrgFeature : public DotStar3ElementsNoSettings +class DotStarBrgFeature : + public NeoByteElements<4, RgbColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarGbrFeature.h b/src/internal/features/DotStarGbrFeature.h index f280a76..de490cb 100644 --- a/src/internal/features/DotStarGbrFeature.h +++ b/src/internal/features/DotStarGbrFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class DotStarGbrFeature : public DotStar3ElementsNoSettings +class DotStarGbrFeature : + public NeoByteElements<4, RgbColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarGrbFeature.h b/src/internal/features/DotStarGrbFeature.h index 6cdb266..54b89bf 100644 --- a/src/internal/features/DotStarGrbFeature.h +++ b/src/internal/features/DotStarGrbFeature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once -class DotStarGrbFeature : public DotStar3ElementsNoSettings +class DotStarGrbFeature : + public NeoByteElements<4, RgbColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarLbgrFeature.h b/src/internal/features/DotStarLbgrFeature.h index d5cfac2..379e5f0 100644 --- a/src/internal/features/DotStarLbgrFeature.h +++ b/src/internal/features/DotStarLbgrFeature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once -class DotStarLbgrFeature : public DotStar4ElementsNoSettings +class DotStarLbgrFeature : + public NeoByteElements<4, RgbwColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarLbrgFeature.h b/src/internal/features/DotStarLbrgFeature.h index 8addf5d..17e6e3f 100644 --- a/src/internal/features/DotStarLbrgFeature.h +++ b/src/internal/features/DotStarLbrgFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class DotStarLbrgFeature : public DotStar4ElementsNoSettings +class DotStarLbrgFeature : + public NeoByteElements<4, RgbwColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarLgbrFeature.h b/src/internal/features/DotStarLgbrFeature.h index 0d0958a..32f6f03 100644 --- a/src/internal/features/DotStarLgbrFeature.h +++ b/src/internal/features/DotStarLgbrFeature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once -class DotStarLgbrFeature : public DotStar4ElementsNoSettings +class DotStarLgbrFeature : + public NeoByteElements<4, RgbwColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarLgrbFeature.h b/src/internal/features/DotStarLgrbFeature.h index 5579e39..d9928ff 100644 --- a/src/internal/features/DotStarLgrbFeature.h +++ b/src/internal/features/DotStarLgrbFeature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once -class DotStarLgrbFeature : public DotStar4ElementsNoSettings +class DotStarLgrbFeature : + public NeoByteElements<4, RgbwColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarLrbgFeature.h b/src/internal/features/DotStarLrbgFeature.h index 414f1f3..45ef231 100644 --- a/src/internal/features/DotStarLrbgFeature.h +++ b/src/internal/features/DotStarLrbgFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class DotStarLrbgFeature : public DotStar4ElementsNoSettings +class DotStarLrbgFeature : + public NeoByteElements<4, RgbwColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarLrgbFeature.h b/src/internal/features/DotStarLrgbFeature.h index bcd95ee..4e925b9 100644 --- a/src/internal/features/DotStarLrgbFeature.h +++ b/src/internal/features/DotStarLrgbFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class DotStarLrgbFeature : public DotStar4ElementsNoSettings +class DotStarLrgbFeature : + public NeoByteElements<4, RgbwColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarRbgFeature.h b/src/internal/features/DotStarRbgFeature.h index 239d614..f0f440b 100644 --- a/src/internal/features/DotStarRbgFeature.h +++ b/src/internal/features/DotStarRbgFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class DotStarRbgFeature : public DotStar3ElementsNoSettings +class DotStarRbgFeature : + public NeoByteElements<4, RgbColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/DotStarRgbFeature.h b/src/internal/features/DotStarRgbFeature.h index 2630f13..7df17d8 100644 --- a/src/internal/features/DotStarRgbFeature.h +++ b/src/internal/features/DotStarRgbFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class DotStarRgbFeature : public DotStar3ElementsNoSettings +class DotStarRgbFeature : + public NeoByteElements<4, RgbColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/Lpd6803BrgFeature.h b/src/internal/features/Lpd6803BrgFeature.h index da60287..b9fa99b 100644 --- a/src/internal/features/Lpd6803BrgFeature.h +++ b/src/internal/features/Lpd6803BrgFeature.h @@ -27,7 +27,10 @@ License along with NeoPixel. If not, see #pragma once -class Lpd6803BrgFeature : public Neo2ByteElementsNoSettings +class Lpd6803BrgFeature : + public NeoByteElements<2, RgbColor, uint16_t>, + public NeoElementsNoSettings, + public Neo2Byte555Elements { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/Lpd6803GbrFeature.h b/src/internal/features/Lpd6803GbrFeature.h index 81e25dc..9ee4c43 100644 --- a/src/internal/features/Lpd6803GbrFeature.h +++ b/src/internal/features/Lpd6803GbrFeature.h @@ -27,7 +27,10 @@ License along with NeoPixel. If not, see #pragma once -class Lpd6803GbrFeature : public Neo2ByteElementsNoSettings +class Lpd6803GbrFeature : + public NeoByteElements<2, RgbColor, uint16_t>, + public NeoElementsNoSettings, + public Neo2Byte555Elements { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/Lpd6803GrbFeature.h b/src/internal/features/Lpd6803GrbFeature.h index 9799040..96bb423 100644 --- a/src/internal/features/Lpd6803GrbFeature.h +++ b/src/internal/features/Lpd6803GrbFeature.h @@ -27,7 +27,10 @@ License along with NeoPixel. If not, see #pragma once -class Lpd6803GrbFeature : public Neo2ByteElementsNoSettings +class Lpd6803GrbFeature : + public NeoByteElements<2, RgbColor, uint16_t>, + public NeoElementsNoSettings, + public Neo2Byte555Elements { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/Lpd6803RgbFeature.h b/src/internal/features/Lpd6803RgbFeature.h index 92bea7e..23668c7 100644 --- a/src/internal/features/Lpd6803RgbFeature.h +++ b/src/internal/features/Lpd6803RgbFeature.h @@ -26,7 +26,10 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class Lpd6803RgbFeature : public Neo2ByteElementsNoSettings +class Lpd6803RgbFeature : + public NeoByteElements<2, RgbColor, uint16_t>, + public NeoElementsNoSettings, + public Neo2Byte555Elements { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/Lpd8806BrgFeature.h b/src/internal/features/Lpd8806BrgFeature.h index 4d3f1fb..6852a7e 100644 --- a/src/internal/features/Lpd8806BrgFeature.h +++ b/src/internal/features/Lpd8806BrgFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class Lpd8806BrgFeature : public Neo3ByteElementsNoSettings +class Lpd8806BrgFeature : + public NeoByteElements<3, RgbColor, uint8_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/Lpd8806GrbFeature.h b/src/internal/features/Lpd8806GrbFeature.h index 36ffb6c..7e95713 100644 --- a/src/internal/features/Lpd8806GrbFeature.h +++ b/src/internal/features/Lpd8806GrbFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class Lpd8806GrbFeature : public Neo3ByteElementsNoSettings +class Lpd8806GrbFeature : + public NeoByteElements<3, RgbColor, uint8_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/Neo2Byte555Elements.h b/src/internal/features/Neo2Byte555Elements.h new file mode 100644 index 0000000..9968cae --- /dev/null +++ b/src/internal/features/Neo2Byte555Elements.h @@ -0,0 +1,46 @@ +/*------------------------------------------------------------------------- +Neo2Byte555Elements provides feature base classes to describe color elements +with 555 encoding for NeoPixelBus Color Feature template classes + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ +#pragma once + +class Neo2Byte555Elements +{ +protected: + static void encodePixel(uint8_t c1, uint8_t c2, uint8_t c3, uint16_t* color555) + { + *color555 = (0x8000 | + ((c1 & 0xf8) << 7) | + ((c2 & 0xf8) << 2) | + ((c3 & 0xf8) >> 3)); + } + + static void decodePixel(uint16_t color555, uint8_t* c1, uint8_t* c2, uint8_t* c3) + { + *c1 = (color555 >> 7) & 0xf8; + *c2 = (color555 >> 2) & 0xf8; + *c3 = (color555 << 3) & 0xf8; + } +}; \ No newline at end of file diff --git a/src/internal/features/Neo2ByteElements.h b/src/internal/features/Neo2ByteElements.h deleted file mode 100644 index 68ba226..0000000 --- a/src/internal/features/Neo2ByteElements.h +++ /dev/null @@ -1,122 +0,0 @@ -/*------------------------------------------------------------------------- -Neo2ByteElements provides feature base classes to describe color elements -for NeoPixelBus Color Feature template classes - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ -#pragma once - -class Neo2ByteElements -{ -public: - static const size_t PixelSize = 2; // 1 bit + 555 encoded elements - - static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - - static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint8_t* pEnd = pPixelDest + (count * PixelSize); - while (pPixelDest < pEnd) - { - for (uint8_t iElement = 0; iElement < PixelSize; iElement++) - { - *pPixelDest++ = pPixelSrc[iElement]; - } - } - } - - static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint8_t* pEnd = pPixelDest + (count * PixelSize); - while (pPixelDest < pEnd) - { - *pPixelDest++ = *pPixelSrc++; - } - } - - static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) - { - uint8_t* pEnd = pPixelDest + (count * PixelSize); - const uint8_t* pSrc = (const uint8_t*)pPixelSrc; - while (pPixelDest < pEnd) - { - *pPixelDest++ = pgm_read_byte(pSrc++); - } - } - - static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint8_t* pDestBack = pPixelDest + (count * PixelSize); - const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize); - while (pDestBack > pPixelDest) - { - *--pDestBack = *--pSrcBack; - } - } - - typedef RgbColor ColorObject; - -protected: - static void encodePixel(uint8_t c1, uint8_t c2, uint8_t c3, uint16_t* color555) - { - *color555 = (0x8000 | - ((c1 & 0xf8) << 7) | - ((c2 & 0xf8) << 2) | - ((c3 & 0xf8) >> 3)); - } - - static void decodePixel(uint16_t color555, uint8_t* c1, uint8_t* c2, uint8_t* c3) - { - *c1 = (color555 >> 7) & 0xf8; - *c2 = (color555 >> 2) & 0xf8; - *c3 = (color555 << 3) & 0xf8; - } -}; - -class Neo2ByteElementsNoSettings : public Neo2ByteElements -{ -public: - typedef NeoNoSettings SettingsObject; - static const size_t SettingsSize = 0; - - static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings) - { - } - - static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } - - static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } -}; \ No newline at end of file diff --git a/src/internal/features/Neo3ByteElements.h b/src/internal/features/Neo3ByteElements.h deleted file mode 100644 index a2a9984..0000000 --- a/src/internal/features/Neo3ByteElements.h +++ /dev/null @@ -1,110 +0,0 @@ -/*------------------------------------------------------------------------- -Neo3ByteElements provides feature base classes to describe color elements -for NeoPixelBus Color Feature template classes - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ -#pragma once - -class Neo3ByteElements -{ -public: - static const size_t PixelSize = 3; - - static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - - static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - const uint8_t* pEnd = pPixelDest + (count * PixelSize); - - while (pPixelDest < pEnd) - { - for (uint8_t iElement = 0; iElement < PixelSize; iElement++) - { - *pPixelDest++ = pPixelSrc[iElement]; - } - } - } - - static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - const uint8_t* pEnd = pPixelDest + (count * PixelSize); - - while (pPixelDest < pEnd) - { - *pPixelDest++ = *pPixelSrc++; - } - } - - static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) - { - const uint8_t* pEnd = pPixelDest + (count * PixelSize); - const uint8_t* pSrc = reinterpret_cast(pPixelSrc); - - while (pPixelDest < pEnd) - { - *pPixelDest++ = pgm_read_byte(pSrc++); - } - } - - static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint8_t* pDestBack = pPixelDest + (count * PixelSize); - const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize); - - while (pDestBack > pPixelDest) - { - *--pDestBack = *--pSrcBack; - } - } - - typedef RgbColor ColorObject; -}; - -class Neo3ByteElementsNoSettings : public Neo3ByteElements -{ -public: - typedef NeoNoSettings SettingsObject; - static const size_t SettingsSize = 0; - - static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings) - { - } - - static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } - - static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } -}; \ No newline at end of file diff --git a/src/internal/features/Neo4ByteElements.h b/src/internal/features/Neo4ByteElements.h deleted file mode 100644 index 1f78b18..0000000 --- a/src/internal/features/Neo4ByteElements.h +++ /dev/null @@ -1,125 +0,0 @@ -/*------------------------------------------------------------------------- -Neo4ByteElements provides feature base classes to describe color elements -for NeoPixelBus Color Feature template classes - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ -#pragma once - -class Neo4ByteElementsBase -{ -public: - static const size_t PixelSize = 4; - - static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - - static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint32_t* pDest = reinterpret_cast(pPixelDest); - const uint32_t* pSrc = reinterpret_cast(pPixelSrc); - const uint32_t* pEnd = pDest + count; // * PixelSize / sizeof(*pDest); - - while (pDest < pEnd) - { - *pDest++ = *pSrc; - } - } - - static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint32_t* pDest = reinterpret_cast(pPixelDest); - const uint32_t* pSrc = reinterpret_cast(pPixelSrc); - const uint32_t* pEnd = pDest + count; // * PixelSize / sizeof(*pDest); - - while (pDest < pEnd) - { - *pDest++ = *pSrc++; - } - } - - static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) - { - uint32_t* pDest = reinterpret_cast(pPixelDest); - const uint32_t* pSrc = reinterpret_cast(pPixelSrc); - const uint32_t* pEnd = pDest + count; // * PixelSize / sizeof(*pDest); - - while (pDest < pEnd) - { - *pDest++ = pgm_read_dword(pSrc++); - } - } - - static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint32_t* pDest = reinterpret_cast(pPixelDest); - const uint32_t* pSrc = reinterpret_cast(pPixelSrc); - uint32_t* pDestBack = pDest + count; // * PixelSize / sizeof(*pDest); - const uint32_t* pSrcBack = pSrc + count; // * PixelSize / sizeof(*pSrc); - - while (pDestBack > pDest) - { - *--pDestBack = *--pSrcBack; - } - } - -}; - -class Neo4ByteElements : public Neo4ByteElementsBase -{ -public: - typedef RgbwColor ColorObject; -}; - -class Neo4ByteRgbElements : public Neo4ByteElementsBase -{ -public: - typedef RgbColor ColorObject; -}; - -class Neo4ByteElementsNoSettings : public Neo4ByteElements -{ -public: - typedef NeoNoSettings SettingsObject; - static const size_t SettingsSize = 0; - - static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings) - { - } - - static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } - - static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } -}; \ No newline at end of file diff --git a/src/internal/features/Neo6Byte4xxElements.h b/src/internal/features/Neo6Byte4xxElements.h deleted file mode 100644 index 14961aa..0000000 --- a/src/internal/features/Neo6Byte4xxElements.h +++ /dev/null @@ -1,116 +0,0 @@ -/*------------------------------------------------------------------------- -Neo6Byte4xxElements provides feature base classes to describe color elements -for NeoPixelBus Color Feature template classes. While it takes 6 bytes, it -only uses four and ignores the last two - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ -#pragma once - - -class Neo6Byte4xxElements -{ -public: - static const size_t PixelSize = 6; - - static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - - static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint16_t* pDest = reinterpret_cast(pPixelDest); - const uint16_t* pSrc = reinterpret_cast(pPixelSrc); - const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest)); - - while (pDest < pEnd) - { - *pDest++ = *pSrc; - } - } - - static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint16_t* pDest = reinterpret_cast(pPixelDest); - const uint16_t* pSrc = reinterpret_cast(pPixelSrc); - const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest)); - - while (pDest < pEnd) - { - *pDest++ = *pSrc++; - } - } - - static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) - { - uint16_t* pDest = reinterpret_cast(pPixelDest); - const uint16_t* pSrc = reinterpret_cast(pPixelSrc); - const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest)); - - while (pDest < pEnd) - { - *pDest++ = pgm_read_word(pSrc++); - } - } - - static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint16_t* pDest = reinterpret_cast(pPixelDest); - const uint16_t* pSrc = reinterpret_cast(pPixelSrc); - uint16_t* pDestBack = pDest + (count * PixelSize / sizeof(*pDest)); - const uint16_t* pSrcBack = pSrc + (count * PixelSize / sizeof(*pSrc)); - - while (pDestBack > pDest) - { - *--pDestBack = *--pSrcBack; - } - } - - typedef RgbwColor ColorObject; -}; - -class Neo6Byte4xxElementsNoSettings : public Neo6Byte4xxElements -{ -public: - typedef NeoNoSettings SettingsObject; - static const size_t SettingsSize = 0; - - static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings) - { - } - - static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } - - static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } -}; \ No newline at end of file diff --git a/src/internal/features/Neo6ByteElements.h b/src/internal/features/Neo6ByteElements.h deleted file mode 100644 index 6a793fa..0000000 --- a/src/internal/features/Neo6ByteElements.h +++ /dev/null @@ -1,115 +0,0 @@ -/*------------------------------------------------------------------------- -Neo6ByteElements provides feature base classes to describe color elements -for NeoPixelBus Color Feature template classes - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ -#pragma once - - -class Neo6ByteElements -{ -public: - static const size_t PixelSize = 6; - - static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - - static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint16_t* pDest = reinterpret_cast(pPixelDest); - const uint16_t* pSrc = reinterpret_cast(pPixelSrc); - const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest)); - - while (pDest < pEnd) - { - *pDest++ = *pSrc; - } - } - - static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint16_t* pDest = reinterpret_cast(pPixelDest); - const uint16_t* pSrc = reinterpret_cast(pPixelSrc); - const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest)); - - while (pDest < pEnd) - { - *pDest++ = *pSrc++; - } - } - - static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) - { - uint16_t* pDest = reinterpret_cast(pPixelDest); - const uint16_t* pSrc = reinterpret_cast(pPixelSrc); - const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest)); - - while (pDest < pEnd) - { - *pDest++ = pgm_read_word(pSrc++); - } - } - - static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint16_t* pDest = reinterpret_cast(pPixelDest); - const uint16_t* pSrc = reinterpret_cast(pPixelSrc); - uint16_t* pDestBack = pDest + (count * PixelSize / sizeof(*pDest)); - const uint16_t* pSrcBack = pSrc + (count * PixelSize / sizeof(*pSrc)); - - while (pDestBack > pDest) - { - *--pDestBack = *--pSrcBack; - } - } - - typedef Rgb48Color ColorObject; -}; - -class Neo6ByteElementsNoSettings : public Neo6ByteElements -{ -public: - typedef NeoNoSettings SettingsObject; - static const size_t SettingsSize = 0; - - static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings) - { - } - - static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } - - static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } -}; \ No newline at end of file diff --git a/src/internal/features/Neo8ByteElements.h b/src/internal/features/Neo8ByteElements.h deleted file mode 100644 index 041c1cb..0000000 --- a/src/internal/features/Neo8ByteElements.h +++ /dev/null @@ -1,115 +0,0 @@ -/*------------------------------------------------------------------------- -Neo8ByteElements provides feature base classes to describe color elements -for NeoPixelBus Color Feature template classes - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ -#pragma once - - -class Neo8ByteElements -{ -public: - static const size_t PixelSize = 8; - - static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - - static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint32_t* pDest = reinterpret_cast(pPixelDest); - const uint32_t* pSrc = reinterpret_cast(pPixelSrc); - const uint32_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest)); - - while (pDest < pEnd) - { - *pDest++ = *pSrc; - } - } - - static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint32_t* pDest = reinterpret_cast(pPixelDest); - const uint32_t* pSrc = reinterpret_cast(pPixelSrc); - const uint32_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest)); - - while (pDest < pEnd) - { - *pDest++ = *pSrc++; - } - } - - static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) - { - uint32_t* pDest = reinterpret_cast(pPixelDest); - const uint32_t* pSrc = reinterpret_cast(pPixelSrc); - const uint32_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest)); - - while (pDest < pEnd) - { - *pDest++ = pgm_read_dword(pSrc++); - } - } - - static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint32_t* pDest = reinterpret_cast(pPixelDest); - const uint32_t* pSrc = reinterpret_cast(pPixelSrc); - uint32_t* pDestBack = pDest + (count * PixelSize / sizeof(*pDest)); - const uint32_t* pSrcBack = pSrc + (count * PixelSize / sizeof(*pSrc)); - - while (pDestBack > pDest) - { - *--pDestBack = *--pSrcBack; - } - } - - typedef Rgbw64Color ColorObject; -}; - -class Neo8ByteElementsNoSettings : public Neo8ByteElements -{ -public: - typedef NeoNoSettings SettingsObject; - static const size_t SettingsSize = 0; - - static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings) - { - } - - static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } - - static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } -}; \ No newline at end of file diff --git a/src/internal/features/Neo9ByteElements.h b/src/internal/features/Neo9ByteElements.h deleted file mode 100644 index 7298422..0000000 --- a/src/internal/features/Neo9ByteElements.h +++ /dev/null @@ -1,106 +0,0 @@ -/*------------------------------------------------------------------------- -Neo9ByteElements provides feature base classes to describe color elements -for NeoPixelBus Color Feature template classes - -Written by Michael C. Miller. - -I invest time and resources providing this open source code, -please support me by dontating (see https://github.com/Makuna/NeoPixelBus) - -------------------------------------------------------------------------- -This file is part of the Makuna/NeoPixelBus library. - -NeoPixelBus is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation, either version 3 of -the License, or (at your option) any later version. - -NeoPixelBus is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with NeoPixel. If not, see -. --------------------------------------------------------------------------*/ -#pragma once - -class Neo9ByteElements -{ -public: - static const size_t PixelSize = 9; // three 3 element - - static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) - { - return pPixels + indexPixel * PixelSize; - } - - static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint8_t* pEnd = pPixelDest + (count * PixelSize); - while (pPixelDest < pEnd) - { - for (uint8_t iElement = 0; iElement < PixelSize; iElement++) - { - *pPixelDest++ = pPixelSrc[iElement]; - } - } - } - - static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint8_t* pEnd = pPixelDest + (count * PixelSize); - while (pPixelDest < pEnd) - { - *pPixelDest++ = *pPixelSrc++; - } - } - - static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) - { - uint8_t* pEnd = pPixelDest + (count * PixelSize); - const uint8_t* pSrc = (const uint8_t*)pPixelSrc; - while (pPixelDest < pEnd) - { - *pPixelDest++ = pgm_read_byte(pSrc++); - } - } - - static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) - { - uint8_t* pDestBack = pPixelDest + (count * PixelSize); - const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize); - while (pDestBack > pPixelDest) - { - *--pDestBack = *--pSrcBack; - } - } - - typedef SevenSegDigit ColorObject; -}; - -class Neo9ByteElementsNoSettings : public Neo9ByteElements -{ -public: - typedef NeoNoSettings SettingsObject; - static const size_t SettingsSize = 0; - - static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings) - { - } - - static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } - - static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData) - { - return pData; - } -}; diff --git a/src/internal/features/NeoAbcdefgpsSegmentFeature.h b/src/internal/features/NeoAbcdefgpsSegmentFeature.h index e4af477..940abd8 100644 --- a/src/internal/features/NeoAbcdefgpsSegmentFeature.h +++ b/src/internal/features/NeoAbcdefgpsSegmentFeature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once // Abcdefgps byte order -class NeoAbcdefgpsSegmentFeature : public Neo9ByteElementsNoSettings +class NeoAbcdefgpsSegmentFeature : + public NeoByteElements<9, SevenSegDigit, uint8_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/NeoBacedfpgsSegmentFeature.h b/src/internal/features/NeoBacedfpgsSegmentFeature.h index 092b94a..9a36f85 100644 --- a/src/internal/features/NeoBacedfpgsSegmentFeature.h +++ b/src/internal/features/NeoBacedfpgsSegmentFeature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once // BACEDF.G+ byte order -class NeoBacedfpgsSegmentFeature : public Neo9ByteElementsNoSettings +class NeoBacedfpgsSegmentFeature : + public NeoByteElements<9, SevenSegDigit, uint8_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/NeoBgrFeature.h b/src/internal/features/NeoBgrFeature.h index 04ae35d..3d03efc 100644 --- a/src/internal/features/NeoBgrFeature.h +++ b/src/internal/features/NeoBgrFeature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once -class NeoBgrFeature : public Neo3ByteElementsNoSettings +class NeoBgrFeature : + public NeoByteElements<3, RgbColor, uint8_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/NeoBrgFeature.h b/src/internal/features/NeoBrgFeature.h index 374b4c6..09f2db1 100644 --- a/src/internal/features/NeoBrgFeature.h +++ b/src/internal/features/NeoBrgFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoBrgFeature : public Neo3ByteElementsNoSettings +class NeoBrgFeature : + public NeoByteElements<3, RgbColor, uint8_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/NeoByteElements.h b/src/internal/features/NeoByteElements.h new file mode 100644 index 0000000..23f3405 --- /dev/null +++ b/src/internal/features/NeoByteElements.h @@ -0,0 +1,139 @@ +/*------------------------------------------------------------------------- +NeoByteElements provides feature base classes to describe color elements +for NeoPixelBus Color Feature template classes + +Written by Michael C. Miller. + +I invest time and resources providing this open source code, +please support me by dontating (see https://github.com/Makuna/NeoPixelBus) + +------------------------------------------------------------------------- +This file is part of the Makuna/NeoPixelBus library. + +NeoPixelBus is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation, either version 3 of +the License, or (at your option) any later version. + +NeoPixelBus is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with NeoPixel. If not, see +. +-------------------------------------------------------------------------*/ + +#pragma once + +// NeoElementsBase contains common methods used by features to map and +// copy pixel memory data in native stream format +// +// V_PIXEL_SIZE - the size in bytes of a pixel in the data stream +// T_COLOR_OBJECT - the primary color object used to represent a pixel +// T_COPY - (uint8_t/uint16_t/uint32_t) the base type to use when copying/moving +template +class NeoElementsBase +{ +public: + static const size_t PixelSize = V_PIXEL_SIZE; + typedef T_COLOR_OBJECT ColorObject; + + static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) + { + return pPixels + indexPixel * PixelSize; + } + static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel) + { + return pPixels + indexPixel * PixelSize; + } + + static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + T_COPY* pDest = reinterpret_cast(pPixelDest); + T_COPY* pEnd = pDest + (count * PixelSize / sizeof(T_COPY)); + const T_COPY* pEndSrc = reinterpret_cast(pPixelSrc) + PixelSize / sizeof(T_COPY); + + while (pDest < pEnd) + { + const T_COPY* pSrc = reinterpret_cast(pPixelSrc); + while (pSrc < pEndSrc) + { + *pDest++ = *pSrc++; + } + } + } + + static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + const T_COPY* pSrc = reinterpret_cast(pPixelSrc); + T_COPY* pDest = reinterpret_cast(pPixelDest); + T_COPY* pEnd = pDest + (count * PixelSize / sizeof(T_COPY)); + + while (pDest < pEnd) + { + *pDest++ = *pSrc++; + } + } + + static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count) + { + const T_COPY* pSrc = reinterpret_cast(pPixelSrc); + const T_COPY* pSrcBack = pSrc + (count * PixelSize / sizeof(T_COPY)); + T_COPY* pDest = reinterpret_cast(pPixelDest); + T_COPY* pDestBack = pDest + (count * PixelSize / sizeof(T_COPY)); + + while (pDestBack > pDest) + { + *--pDestBack = *--pSrcBack; + } + } +}; + +// NeoByteElements is used for 8bit color element types and less +// +// V_PIXEL_SIZE - the size in bytes of a pixel in the data stream +// T_COLOR_OBJECT - the primary color object used to represent a pixel +// T_COPY - (uint8_t/uint16_t/uint32_t) the base type to use when copying/moving +template +class NeoByteElements : public NeoElementsBase +{ +public: + + static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) + { + uint8_t* pEnd = pPixelDest + (count * NeoElementsBase::PixelSize); + const uint8_t* pSrc = (const uint8_t*)pPixelSrc; + + while (pPixelDest < pEnd) + { + *pPixelDest++ = pgm_read_byte(pSrc++); + } + } +}; + +// NeoWordElements is used for 16bit color element types +// +// V_PIXEL_SIZE - the size in bytes of a pixel in the data stream +// T_COLOR_OBJECT - the primary color object used to represent a pixel +// T_COPY - (uint16_t/uint32_t) the base type to use when copying/moving +template +class NeoWordElements : public NeoElementsBase +{ +public: + + static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) + { + uint16_t* pDest = reinterpret_cast(pPixelDest); + uint16_t* pEnd = pDest + (count * NeoElementsBase::PixelSize / sizeof(uint16_t)); + const uint16_t* pSrc = reinterpret_cast(pPixelSrc); + + while (pDest < pEnd) + { + *pDest++ = pgm_read_word(pSrc++); + } + } +}; + + diff --git a/src/internal/features/DotStar3Elements.h b/src/internal/features/NeoElementsNoSettings.h similarity index 88% rename from src/internal/features/DotStar3Elements.h rename to src/internal/features/NeoElementsNoSettings.h index 83728f3..ef222b7 100644 --- a/src/internal/features/DotStar3Elements.h +++ b/src/internal/features/NeoElementsNoSettings.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -DotStar3Elements provides feature base classes to describe color elements -for NeoPixelBus Color Feature template classes when used with DotStars +NeoElementsNoSettings provides feature base classes to describe a + no settings feature Written by Michael C. Miller. @@ -26,7 +26,7 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class DotStar3ElementsNoSettings : public Neo4ByteRgbElements +class NeoElementsNoSettings { public: typedef NeoNoSettings SettingsObject; diff --git a/src/internal/features/NeoGrb48Feature.h b/src/internal/features/NeoGrb48Feature.h index 5f08d88..2b39f10 100644 --- a/src/internal/features/NeoGrb48Feature.h +++ b/src/internal/features/NeoGrb48Feature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoGrb48Feature : public Neo6ByteElementsNoSettings +class NeoGrb48Feature : + public NeoWordElements<6, Rgb48Color, uint16_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -48,9 +50,12 @@ public: const uint8_t* p = getPixelAddress(pPixels, indexPixel); // due to endianness the byte order must be copied to output - color.G = (static_cast(*p++) << 8) | *p++; - color.R = (static_cast(*p++) << 8) | *p++; - color.B = (static_cast(*p++) << 8) | *p; + color.G = (static_cast(*p++) << 8); + color.G |= *p++; + color.R = (static_cast(*p++) << 8); + color.R |= *p++; + color.B = (static_cast(*p++) << 8); + color.B |= *p; return color; } diff --git a/src/internal/features/NeoGrbFeature.h b/src/internal/features/NeoGrbFeature.h index c246e55..a5d971c 100644 --- a/src/internal/features/NeoGrbFeature.h +++ b/src/internal/features/NeoGrbFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoGrbFeature : public Neo3ByteElementsNoSettings +class NeoGrbFeature : + public NeoByteElements<3, RgbColor, uint8_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/NeoGrbwFeature.h b/src/internal/features/NeoGrbwFeature.h index e6aea51..342f28c 100644 --- a/src/internal/features/NeoGrbwFeature.h +++ b/src/internal/features/NeoGrbwFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoGrbwFeature : public Neo4ByteElementsNoSettings +class NeoGrbwFeature : + public NeoByteElements<4, RgbwColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/NeoRbgFeature.h b/src/internal/features/NeoRbgFeature.h index 7fde324..a6e5ba3 100644 --- a/src/internal/features/NeoRbgFeature.h +++ b/src/internal/features/NeoRbgFeature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once -class NeoRbgFeature : public Neo3ByteElementsNoSettings +class NeoRbgFeature : + public NeoByteElements<3, RgbColor, uint8_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/NeoRgb48Feature.h b/src/internal/features/NeoRgb48Feature.h index d7386f7..369f428 100644 --- a/src/internal/features/NeoRgb48Feature.h +++ b/src/internal/features/NeoRgb48Feature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoRgb48Feature : public Neo6ByteElementsNoSettings +class NeoRgb48Feature : + public NeoWordElements<6, Rgb48Color, uint16_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -48,9 +50,12 @@ public: const uint8_t* p = getPixelAddress(pPixels, indexPixel); // due to endianness the byte order must be copied to output - color.R = (static_cast(*p++) << 8) | *p++; - color.G = (static_cast(*p++) << 8) | *p++; - color.B = (static_cast(*p++) << 8) | *p; + color.R = (static_cast(*p++) << 8); + color.R |= *p++; + color.G = (static_cast(*p++) << 8); + color.G |= *p++; + color.B = (static_cast(*p++) << 8); + color.B |= *p; return color; } diff --git a/src/internal/features/NeoRgbFeature.h b/src/internal/features/NeoRgbFeature.h index 134af52..b47f476 100644 --- a/src/internal/features/NeoRgbFeature.h +++ b/src/internal/features/NeoRgbFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoRgbFeature : public Neo3ByteElementsNoSettings +class NeoRgbFeature : + public NeoByteElements<3, RgbColor, uint8_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/NeoRgbw64Feature.h b/src/internal/features/NeoRgbw64Feature.h index 892f45e..305917c 100644 --- a/src/internal/features/NeoRgbw64Feature.h +++ b/src/internal/features/NeoRgbw64Feature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once -class NeoRgbw64Feature : public Neo8ByteElementsNoSettings +class NeoRgbw64Feature : + public NeoWordElements<8, Rgbw64Color, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -51,10 +53,14 @@ public: const uint8_t* p = getPixelAddress(pPixels, indexPixel); // due to endianness the byte order must be copied to output - color.R = (static_cast(*p++) << 8) | *p++; - color.G = (static_cast(*p++) << 8) | *p++; - color.B = (static_cast(*p++) << 8) | *p++; - color.W = (static_cast(*p++) << 8) | *p; + color.R = (static_cast(*p++) << 8); + color.R |= *p++; + color.G = (static_cast(*p++) << 8); + color.G |= *p++; + color.B = (static_cast(*p++) << 8); + color.B |= *p++; + color.W = (static_cast(*p++) << 8); + color.W |= *p; return color; } diff --git a/src/internal/features/NeoRgbwFeature.h b/src/internal/features/NeoRgbwFeature.h index 7ab746b..a883ace 100644 --- a/src/internal/features/NeoRgbwFeature.h +++ b/src/internal/features/NeoRgbwFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoRgbwFeature : public Neo4ByteElementsNoSettings +class NeoRgbwFeature : + public NeoByteElements<4, RgbwColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/NeoRgbwxxFeature.h b/src/internal/features/NeoRgbwxxFeature.h index cd167ab..07813b9 100644 --- a/src/internal/features/NeoRgbwxxFeature.h +++ b/src/internal/features/NeoRgbwxxFeature.h @@ -26,7 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoRgbwxxFeature : public Neo6Byte4xxElementsNoSettings +class NeoRgbwxxFeature : + public NeoByteElements<6, RgbwColor, uint16_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) diff --git a/src/internal/features/NeoSm168xxColorFeatures.h b/src/internal/features/NeoSm168xxColorFeatures.h index 98dd482..9fd86eb 100644 --- a/src/internal/features/NeoSm168xxColorFeatures.h +++ b/src/internal/features/NeoSm168xxColorFeatures.h @@ -199,7 +199,7 @@ protected: }; -template class NeoRgbwSm168x4Elements : public Neo4ByteElements +template class NeoRgbwSm168x4Elements : public NeoByteElements<4, RgbwColor, uint32_t> { public: typedef T_SETTINGS SettingsObject; @@ -260,7 +260,7 @@ public: } }; -template class NeoRgbSm168x3Elements : public Neo3ByteElements +template class NeoRgbSm168x3Elements : public NeoByteElements<3, RgbColor, uint8_t> { public: typedef T_SETTINGS SettingsObject; diff --git a/src/internal/features/NeoTm1814ColorFeatures.h b/src/internal/features/NeoTm1814ColorFeatures.h index 674c4d1..b737679 100644 --- a/src/internal/features/NeoTm1814ColorFeatures.h +++ b/src/internal/features/NeoTm1814ColorFeatures.h @@ -25,7 +25,7 @@ License along with NeoPixel. If not, see . -------------------------------------------------------------------------*/ #pragma once - + class NeoTm1814Settings : public NeoRgbwCurrentSettings { public: @@ -51,7 +51,7 @@ public: } }; -class Neo4ByteElementsTm1814Settings : public Neo4ByteElements +class Neo4ByteElementsTm1814Settings : public NeoByteElements<4, RgbwColor, uint32_t> { private: const static uint16_t EncodeDivisor = 5; diff --git a/src/internal/features/NeoTm1914ColorFeatures.h b/src/internal/features/NeoTm1914ColorFeatures.h index 5ea14bd..92c7d9e 100644 --- a/src/internal/features/NeoTm1914ColorFeatures.h +++ b/src/internal/features/NeoTm1914ColorFeatures.h @@ -44,7 +44,7 @@ public: NeoTm1914_Mode Mode; }; -class Neo3ByteElementsTm1914Settings : public Neo3ByteElements +class Neo3ByteElementsTm1914Settings : public NeoByteElements<3, RgbColor, uint8_t> { public: typedef NeoTm1914Settings SettingsObject; diff --git a/src/internal/features/P9813BgrFeature.h b/src/internal/features/P9813BgrFeature.h index 728c5bc..c81fda6 100644 --- a/src/internal/features/P9813BgrFeature.h +++ b/src/internal/features/P9813BgrFeature.h @@ -27,7 +27,9 @@ License along with NeoPixel. If not, see #pragma once -class P9813BgrFeature : public DotStar3ElementsNoSettings +class P9813BgrFeature : + public NeoByteElements<4, RgbColor, uint32_t>, + public NeoElementsNoSettings { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)