From f5bace5a1adc73f6d70a8b5d9481e6b2a38b7317 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Mon, 13 Mar 2023 14:17:39 -0700 Subject: [PATCH] refactor color features (#661) * dotstars * SevenSegment * featured all moved * cleanup --- src/NeoPixelBus.h | 8 - src/internal/DotStarColorFeatures.h | 698 ---------------- src/internal/Lpd6803ColorFeatures.h | 301 ------- src/internal/NeoColorFeatures.h | 781 ++---------------- src/internal/NeoSegmentFeatures.h | 216 ----- src/internal/features/DotStar3Elements.h | 48 ++ .../DotStar4Elements.h} | 63 +- src/internal/features/DotStarBgrFeature.h | 69 ++ src/internal/features/DotStarBrgFeature.h | 68 ++ src/internal/features/DotStarGbrFeature.h | 68 ++ src/internal/features/DotStarGrbFeature.h | 69 ++ src/internal/features/DotStarLbgrFeature.h | 69 ++ src/internal/features/DotStarLbrgFeature.h | 68 ++ src/internal/features/DotStarLgbrFeature.h | 69 ++ src/internal/features/DotStarLgrbFeature.h | 69 ++ src/internal/features/DotStarLrbgFeature.h | 68 ++ src/internal/features/DotStarLrgbFeature.h | 68 ++ src/internal/features/DotStarRbgFeature.h | 68 ++ src/internal/features/DotStarRgbFeature.h | 68 ++ src/internal/features/Lpd6803BrgFeature.h | 72 ++ src/internal/features/Lpd6803GbrFeature.h | 73 ++ src/internal/features/Lpd6803GrbFeature.h | 72 ++ src/internal/features/Lpd6803RgbFeature.h | 73 ++ src/internal/features/Lpd8806BrgFeature.h | 66 ++ src/internal/features/Lpd8806GrbFeature.h | 65 ++ .../Neo2ByteElements.h} | 223 ++--- src/internal/features/Neo3ByteElements.h | 110 +++ src/internal/features/Neo4ByteElements.h | 125 +++ src/internal/features/Neo6ByteElements.h | 115 +++ src/internal/features/Neo8ByteElements.h | 115 +++ src/internal/features/Neo9ByteElements.h | 106 +++ .../features/NeoAbcdefgpsSegmentFeature.h | 70 ++ .../features/NeoBacedfpgsSegmentFeature.h | 91 ++ src/internal/features/NeoBgrFeature.h | 66 ++ src/internal/features/NeoBrgFeature.h | 64 ++ src/internal/features/NeoGrb48Feature.h | 64 ++ src/internal/features/NeoGrbFeature.h | 64 ++ src/internal/features/NeoGrbwFeature.h | 68 ++ src/internal/features/NeoRbgFeature.h | 66 ++ src/internal/features/NeoRgb48Feature.h | 64 ++ src/internal/features/NeoRgbFeature.h | 64 ++ src/internal/features/NeoRgbw64Feature.h | 68 ++ src/internal/features/NeoRgbwFeature.h | 67 ++ .../{ => features}/NeoSm168xxColorFeatures.h | 0 .../{ => features}/NeoTm1814ColorFeatures.h | 0 .../{ => features}/NeoTm1914ColorFeatures.h | 0 src/internal/features/P9813BgrFeature.h | 75 ++ 47 files changed, 2892 insertions(+), 2150 deletions(-) delete mode 100644 src/internal/DotStarColorFeatures.h delete mode 100644 src/internal/Lpd6803ColorFeatures.h delete mode 100644 src/internal/NeoSegmentFeatures.h create mode 100644 src/internal/features/DotStar3Elements.h rename src/internal/{P9813ColorFeatures.h => features/DotStar4Elements.h} (71%) create mode 100644 src/internal/features/DotStarBgrFeature.h create mode 100644 src/internal/features/DotStarBrgFeature.h create mode 100644 src/internal/features/DotStarGbrFeature.h create mode 100644 src/internal/features/DotStarGrbFeature.h create mode 100644 src/internal/features/DotStarLbgrFeature.h create mode 100644 src/internal/features/DotStarLbrgFeature.h create mode 100644 src/internal/features/DotStarLgbrFeature.h create mode 100644 src/internal/features/DotStarLgrbFeature.h create mode 100644 src/internal/features/DotStarLrbgFeature.h create mode 100644 src/internal/features/DotStarLrgbFeature.h create mode 100644 src/internal/features/DotStarRbgFeature.h create mode 100644 src/internal/features/DotStarRgbFeature.h create mode 100644 src/internal/features/Lpd6803BrgFeature.h create mode 100644 src/internal/features/Lpd6803GbrFeature.h create mode 100644 src/internal/features/Lpd6803GrbFeature.h create mode 100644 src/internal/features/Lpd6803RgbFeature.h create mode 100644 src/internal/features/Lpd8806BrgFeature.h create mode 100644 src/internal/features/Lpd8806GrbFeature.h rename src/internal/{Lpd8806ColorFeatures.h => features/Neo2ByteElements.h} (53%) create mode 100644 src/internal/features/Neo3ByteElements.h create mode 100644 src/internal/features/Neo4ByteElements.h create mode 100644 src/internal/features/Neo6ByteElements.h create mode 100644 src/internal/features/Neo8ByteElements.h create mode 100644 src/internal/features/Neo9ByteElements.h create mode 100644 src/internal/features/NeoAbcdefgpsSegmentFeature.h create mode 100644 src/internal/features/NeoBacedfpgsSegmentFeature.h create mode 100644 src/internal/features/NeoBgrFeature.h create mode 100644 src/internal/features/NeoBrgFeature.h create mode 100644 src/internal/features/NeoGrb48Feature.h create mode 100644 src/internal/features/NeoGrbFeature.h create mode 100644 src/internal/features/NeoGrbwFeature.h create mode 100644 src/internal/features/NeoRbgFeature.h create mode 100644 src/internal/features/NeoRgb48Feature.h create mode 100644 src/internal/features/NeoRgbFeature.h create mode 100644 src/internal/features/NeoRgbw64Feature.h create mode 100644 src/internal/features/NeoRgbwFeature.h rename src/internal/{ => features}/NeoSm168xxColorFeatures.h (100%) rename src/internal/{ => features}/NeoTm1814ColorFeatures.h (100%) rename src/internal/{ => features}/NeoTm1914ColorFeatures.h (100%) create mode 100644 src/internal/features/P9813BgrFeature.h diff --git a/src/NeoPixelBus.h b/src/NeoPixelBus.h index dfd1ca6..72cb175 100644 --- a/src/NeoPixelBus.h +++ b/src/NeoPixelBus.h @@ -50,14 +50,6 @@ License along with NeoPixel. If not, see #include "internal/SegmentDigit.h" #include "internal/NeoColorFeatures.h" -#include "internal/NeoTm1814ColorFeatures.h" -#include "internal/NeoTm1914ColorFeatures.h" -#include "internal/NeoSm168xxColorFeatures.h" -#include "internal/DotStarColorFeatures.h" -#include "internal/Lpd8806ColorFeatures.h" -#include "internal/Lpd6803ColorFeatures.h" -#include "internal/P9813ColorFeatures.h" -#include "internal/NeoSegmentFeatures.h" #include "internal/Layouts.h" #include "internal/NeoTopology.h" diff --git a/src/internal/DotStarColorFeatures.h b/src/internal/DotStarColorFeatures.h deleted file mode 100644 index 2ffe993..0000000 --- a/src/internal/DotStarColorFeatures.h +++ /dev/null @@ -1,698 +0,0 @@ -/*------------------------------------------------------------------------- -DotStarColorFeatures provides feature classes to describe color order and -color depth for NeoPixelBus template class 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 DotStar3Elements -{ -public: - static const size_t PixelSize = 4; // still requires 4 to be sent - - 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 RgbColor ColorObject; -}; - -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 DotStar3ElementsNoSettings : public DotStar3Elements -{ -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; - } -}; - -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; - } -}; - -class DotStarBgrFeature : public DotStar3ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xff; // upper three bits are always 111 and brightness at max - *p++ = color.B; - *p++ = color.G; - *p = color.R; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - p++; // ignore the first byte - color.B = *p++; - color.G = *p++; - color.R = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - pgm_read_byte(p++); // ignore the first byte - color.B = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.R = pgm_read_byte(p); - - return color; - } - -}; - -class DotStarLbgrFeature : public DotStar4ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 - *p++ = color.B; - *p++ = color.G; - *p = color.R; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.W = (*p++) & 0x1F; // mask out upper three bits - color.B = *p++; - color.G = *p++; - color.R = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits - color.B = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.R = pgm_read_byte(p); - - return color; - } - -}; - -class DotStarGrbFeature : public DotStar3ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xff; // upper three bits are always 111 and brightness at max - *p++ = color.G; - *p++ = color.R; - *p = color.B; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - p++; // ignore the first byte - color.G = *p++; - color.R = *p++; - color.B = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - pgm_read_byte(p++); // ignore the first byte - color.G = pgm_read_byte(p++); - color.R = pgm_read_byte(p++); - color.B = pgm_read_byte(p); - - return color; - } - -}; - -class DotStarLgrbFeature : public DotStar4ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 - *p++ = color.G; - *p++ = color.R; - *p = color.B; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.W = (*p++) & 0x1F; // mask out upper three bits - color.G = *p++; - color.R = *p++; - color.B = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits - color.G = pgm_read_byte(p++); - color.R = pgm_read_byte(p++); - color.B = pgm_read_byte(p); - - return color; - } - -}; - -/* RGB Feature -- Some APA102s ship in RGB order */ -class DotStarRgbFeature : public DotStar3ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xff; // upper three bits are always 111 and brightness at max - *p++ = color.R; - *p++ = color.G; - *p = color.B; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - p++; // ignore the first byte - color.R = *p++; - color.G = *p++; - color.B = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - pgm_read_byte(p++); // ignore the first byte - color.R = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.B = pgm_read_byte(p); - - return color; - } - -}; - -class DotStarLrgbFeature : public DotStar4ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 - *p++ = color.R; - *p++ = color.G; - *p = color.B; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.W = (*p++) & 0x1F; // mask out upper three bits - color.R = *p++; - color.G = *p++; - color.B = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits - color.R = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.B = pgm_read_byte(p); - - return color; - } - -}; -/* RBG Feature -- Some APA102s ship in RBG order */ -class DotStarRbgFeature : public DotStar3ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xff; // upper three bits are always 111 and brightness at max - *p++ = color.R; - *p++ = color.B; - *p = color.G; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - p++; // ignore the first byte - color.R = *p++; - color.B = *p++; - color.G = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - pgm_read_byte(p++); // ignore the first byte - color.R = pgm_read_byte(p++); - color.B = pgm_read_byte(p++); - color.G = pgm_read_byte(p); - - return color; - } - -}; - -class DotStarLrbgFeature : public DotStar4ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 - *p++ = color.R; - *p++ = color.B; - *p = color.G; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.W = (*p++) & 0x1F; // mask out upper three bits - color.R = *p++; - color.B = *p++; - color.G = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits - color.R = pgm_read_byte(p++); - color.B = pgm_read_byte(p++); - color.G = pgm_read_byte(p); - - return color; - } - -}; - -/* GBR Feature -- Some APA102s ship in GBR order */ -class DotStarGbrFeature : public DotStar3ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xff; // upper three bits are always 111 and brightness at max - *p++ = color.G; - *p++ = color.B; - *p = color.R; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - p++; // ignore the first byte - color.G = *p++; - color.B = *p++; - color.R = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - pgm_read_byte(p++); // ignore the first byte - color.G = pgm_read_byte(p++); - color.B = pgm_read_byte(p++); - color.R = pgm_read_byte(p); - - return color; - } - -}; - -class DotStarLgbrFeature : public DotStar4ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 - *p++ = color.G; - *p++ = color.B; - *p = color.R; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.W = (*p++) & 0x1F; // mask out upper three bits - color.G = *p++; - color.B = *p++; - color.R = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits - color.G = pgm_read_byte(p++); - color.B = pgm_read_byte(p++); - color.R = pgm_read_byte(p); - - return color; - } - -}; -/* BRG Feature -- Some APA102s ship in BRG order */ -class DotStarBrgFeature : public DotStar3ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xff; // upper three bits are always 111 and brightness at max - *p++ = color.B; - *p++ = color.R; - *p = color.G; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - p++; // ignore the first byte - color.B = *p++; - color.R = *p++; - color.G = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - pgm_read_byte(p++); // ignore the first byte - color.B = pgm_read_byte(p++); - color.R = pgm_read_byte(p++); - color.G = pgm_read_byte(p); - - return color; - } - -}; - -class DotStarLbrgFeature : public DotStar4ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 - *p++ = color.B; - *p++ = color.R; - *p = color.G; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.W = (*p++) & 0x1F; // mask out upper three bits - color.B = *p++; - color.R = *p++; - color.G = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits - color.B = pgm_read_byte(p++); - color.R = pgm_read_byte(p++); - color.G = pgm_read_byte(p); - - return color; - } - -}; diff --git a/src/internal/Lpd6803ColorFeatures.h b/src/internal/Lpd6803ColorFeatures.h deleted file mode 100644 index fdc4347..0000000 --- a/src/internal/Lpd6803ColorFeatures.h +++ /dev/null @@ -1,301 +0,0 @@ -/*------------------------------------------------------------------------- -Lpd6803ColorFeatures provides feature classes to describe color order and -color depth for NeoPixelBus template class when used with DotStar like chips - -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 Lpd68033ElementsNoSettings -{ -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; - } -}; - -class Lpd68033Elements : public Lpd68033ElementsNoSettings -{ -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) - { - *pPixelDest++ = pPixelSrc[0]; - *pPixelDest++ = pPixelSrc[1]; - } - } - - 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++; - } - } - - 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++); - } - } - - 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; - } - } - - 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 Lpd6803BrgFeature : public Lpd68033Elements -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - uint16_t color555; - - encodePixel(color.B, color.R, color.G, &color555); - *p++ = color555 >> 8; - *p = color555 & 0xff; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - uint16_t color555; - - color555 = ((*p++) << 8); - color555 |= (*p); - - decodePixel(color555, &color.B, &color.R, &color.G); - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - uint16_t color555; - - color555 = (pgm_read_byte(p++) << 8); - color555 |= pgm_read_byte(p); - - decodePixel(color555, &color.B, &color.R, &color.G); - - return color; - } -}; - -class Lpd6803GrbFeature : public Lpd68033Elements -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - uint16_t color555; - - encodePixel(color.G, color.R, color.B, &color555); - *p++ = color555 >> 8; - *p = color555 & 0xff; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - uint16_t color555; - - color555 = ((*p++) << 8); - color555 |= (*p); - - decodePixel(color555, &color.G, &color.R, &color.B); - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - uint16_t color555; - - color555 = (pgm_read_byte(p++) << 8); - color555 |= pgm_read_byte(p); - - decodePixel(color555, &color.G, &color.R, &color.B); - - return color; - } -}; - -class Lpd6803GbrFeature : public Lpd68033Elements -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - uint16_t color555; - - encodePixel(color.G, color.B, color.R, &color555); - *p++ = color555 >> 8; - *p = color555 & 0xff; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - uint16_t color555; - - color555 = ((*p++) << 8); - color555 |= (*p); - - decodePixel(color555, &color.G, &color.B, &color.R); - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - uint16_t color555; - - color555 = (pgm_read_byte(p++) << 8); - color555 |= pgm_read_byte(p); - - decodePixel(color555, &color.G, &color.B, &color.R); - - return color; - } -}; - - -class Lpd6803RgbFeature : public Lpd68033Elements -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - uint16_t color555; - - encodePixel(color.R, color.G, color.B, &color555); - *p++ = color555 >> 8; - *p = color555 & 0xff; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - uint16_t color555; - - color555 = ((*p++) << 8); - color555 |= (*p); - - decodePixel(color555, &color.R, &color.G, &color.B); - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - uint16_t color555; - - color555 = (pgm_read_byte(p++) << 8); - color555 |= pgm_read_byte(p); - - decodePixel(color555, &color.R, &color.G, &color.B); - - return color; - } -}; - diff --git a/src/internal/NeoColorFeatures.h b/src/internal/NeoColorFeatures.h index afe1538..c953f88 100644 --- a/src/internal/NeoColorFeatures.h +++ b/src/internal/NeoColorFeatures.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -NeoColorFeatures provides feature classes to describe color order and +NeoColorFeatures includes all the feature classes that describe color order and color depth for NeoPixelBus template class Written by Michael C. Miller. @@ -26,734 +26,59 @@ 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 Neo4ByteElements -{ -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; - } - } - - typedef RgbwColor ColorObject; -}; - -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 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 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; - } -}; - -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; - } -}; - -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; - } -}; - -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; - } -}; - -class NeoGrbFeature : public Neo3ByteElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = color.G; - *p++ = color.R; - *p = color.B; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.G = *p++; - color.R = *p++; - color.B = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); - - color.G = pgm_read_byte(p++); - color.R = pgm_read_byte(p++); - color.B = pgm_read_byte(p); - - return color; - } -}; - -class NeoGrbwFeature : public Neo4ByteElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = color.G; - *p++ = color.R; - *p++ = color.B; - *p = color.W; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.G = *p++; - color.R = *p++; - color.B = *p++; - color.W = *p; - - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); - - color.G = pgm_read_byte(p++); - color.R = pgm_read_byte(p++); - color.B = pgm_read_byte(p++); - color.W = pgm_read_byte(p); - - return color; - } -}; - -class NeoRgbwFeature : public Neo4ByteElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = color.R; - *p++ = color.G; - *p++ = color.B; - *p = color.W; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.R = *p++; - color.G = *p++; - color.B = *p++; - color.W = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); - - color.R = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.B = pgm_read_byte(p++); - color.W = pgm_read_byte(p); - - return color; - } -}; - -class NeoRgbFeature : public Neo3ByteElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = color.R; - *p++ = color.G; - *p = color.B; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.R = *p++; - color.G = *p++; - color.B = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); - - color.R = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.B = pgm_read_byte(p); - - return color; - } -}; - -class NeoBrgFeature : public Neo3ByteElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = color.B; - *p++ = color.R; - *p = color.G; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.B = *p++; - color.R = *p++; - color.G = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); - - color.B = pgm_read_byte(p++); - color.R = pgm_read_byte(p++); - color.G = pgm_read_byte(p); - - return color; - } -}; - -class NeoRbgFeature : public Neo3ByteElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = color.R; - *p++ = color.B; - *p = color.G; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.R = *p++; - color.B = *p++; - color.G = *p; - - return color; - } - - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); - - color.R = pgm_read_byte(p++); - color.B = pgm_read_byte(p++); - color.G = pgm_read_byte(p); - - return color; - } -}; - -class NeoBgrFeature : public Neo3ByteElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = color.B; - *p++ = color.G; - *p = color.R; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.B = *p++; - color.G = *p++; - color.R = *p; - - return color; - } - - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); - - color.B = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.R = pgm_read_byte(p); - - return color; - } -}; - -class NeoRgbw64Feature : public Neo8ByteElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); - - *p++ = color.R; - *p++ = color.G; - *p++ = color.B; - *p = color.W; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); - - color.R = *p++; - color.G = *p++; - color.B = *p++; - color.W = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint16_t* p = reinterpret_cast(getPixelAddress(reinterpret_cast(pPixels), indexPixel)); - - color.R = pgm_read_word(p++); - color.G = pgm_read_word(p++); - color.B = pgm_read_word(p++); - color.W = pgm_read_word(p); - - return color; - } -}; - -class NeoRgb48Feature : public Neo6ByteElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); - - *p++ = color.R; - *p++ = color.G; - *p = color.B; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); - - color.R = *p++; - color.G = *p++; - color.B = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint16_t* p = reinterpret_cast(getPixelAddress(reinterpret_cast(pPixels), indexPixel)); - - color.R = pgm_read_word(p++); - color.G = pgm_read_word(p++); - color.B = pgm_read_word(p); - - return color; - } -}; +// NeoPixel Features +// +#include "features/Neo2ByteElements.h" +#include "features/Neo3ByteElements.h" +#include "features/Neo4ByteElements.h" +#include "features/Neo6ByteElements.h" +#include "features/Neo8ByteElements.h" +#include "features/NeoBgrFeature.h" +#include "features/NeoBrgFeature.h" +#include "features/NeoGrb48Feature.h" +#include "features/NeoGrbFeature.h" +#include "features/NeoGrbwFeature.h" +#include "features/NeoRbgFeature.h" +#include "features/NeoRgb48Feature.h" +#include "features/NeoRgbFeature.h" +#include "features/NeoRgbw64Feature.h" +#include "features/NeoRgbwFeature.h" +#include "features/NeoSm168xxColorFeatures.h" +#include "features/NeoTm1814ColorFeatures.h" +#include "features/NeoTm1914ColorFeatures.h" typedef NeoRgb48Feature NeoRgbUcs8903Feature; typedef NeoRgbw64Feature NeoRgbwUcs8904Feature; - - -class NeoGrb48Feature : public Neo6ByteElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); - - *p++ = color.G; - *p++ = color.R; - *p = color.B; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); - - color.G = *p++; - color.R = *p++; - color.B = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint16_t* p = reinterpret_cast(getPixelAddress(reinterpret_cast(pPixels), indexPixel)); - - color.G = pgm_read_word(p++); - color.R = pgm_read_word(p++); - color.B = pgm_read_word(p); - - return color; - } -}; - 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" +#include "features/DotStarGrbFeature.h" +#include "features/DotStarLbgrFeature.h" +#include "features/DotStarLbrgFeature.h" +#include "features/DotStarLgbrFeature.h" +#include "features/DotStarLgrbFeature.h" +#include "features/DotStarLrbgFeature.h" +#include "features/DotStarLrgbFeature.h" +#include "features/DotStarRbgFeature.h" +#include "features/DotStarRgbFeature.h" +#include "features/Lpd8806BrgFeature.h" +#include "features/Lpd8806GrbFeature.h" +#include "features/Lpd6803BrgFeature.h" +#include "features/Lpd6803GrbFeature.h" +#include "features/Lpd6803GbrFeature.h" +#include "features/Lpd6803RgbFeature.h" +#include "features/P9813BgrFeature.h" + +// 7 Segment Features +// +#include "features/Neo9ByteElements.h" +#include "features/NeoAbcdefgpsSegmentFeature.h" +#include "features/NeoBacedfpgsSegmentFeature.h" + +typedef NeoAbcdefgpsSegmentFeature SevenSegmentFeature; // Abcdefg order is default diff --git a/src/internal/NeoSegmentFeatures.h b/src/internal/NeoSegmentFeatures.h deleted file mode 100644 index ef3a2fc..0000000 --- a/src/internal/NeoSegmentFeatures.h +++ /dev/null @@ -1,216 +0,0 @@ -/*------------------------------------------------------------------------- -NeoSegmentFeatures provides feature classes to describe seven segment display -elements for NeoPixelBus template class - -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 Neo9Elements -{ -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 Neo9ElementsNoSettings : public Neo9Elements -{ -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; - } -}; - -// Abcdefgps byte order -class NeoAbcdefgSegmentFeature : public Neo9ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count; - for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++) - { - *p++ = color.Segment[iSegment]; - } - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count; - - for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++) - { - color.Segment[iSegment] = *p++; - } - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count; - - for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++) - { - color.Segment[iSegment] = pgm_read_byte(p++); - } - - return color; - } - -}; - - -// BACEDF.G+ byte order -class NeoBacedfpgsSegmentFeature : public Neo9ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - // Segment Digit is Abcdefgps order - *p++ = color.Segment[LedSegment_B]; - *p++ = color.Segment[LedSegment_A]; - *p++ = color.Segment[LedSegment_C]; - - *p++ = color.Segment[LedSegment_E]; - *p++ = color.Segment[LedSegment_D]; - *p++ = color.Segment[LedSegment_F]; - - *p++ = color.Segment[LedSegment_Decimal]; - *p++ = color.Segment[LedSegment_G]; - *p++ = color.Segment[LedSegment_Custom]; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.Segment[LedSegment_B] = *p++; - color.Segment[LedSegment_A] = *p++; - color.Segment[LedSegment_C] = *p++; - - color.Segment[LedSegment_E] = *p++; - color.Segment[LedSegment_D] = *p++; - color.Segment[LedSegment_F] = *p++; - - color.Segment[LedSegment_Decimal] = *p++; - color.Segment[LedSegment_G] = *p++; - color.Segment[LedSegment_Custom] = *p++; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - color.Segment[LedSegment_B] = pgm_read_byte(p++); - color.Segment[LedSegment_A] = pgm_read_byte(p++); - color.Segment[LedSegment_C] = pgm_read_byte(p++); - - color.Segment[LedSegment_E] = pgm_read_byte(p++); - color.Segment[LedSegment_D] = pgm_read_byte(p++); - color.Segment[LedSegment_F] = pgm_read_byte(p++); - - color.Segment[LedSegment_Decimal] = pgm_read_byte(p++); - color.Segment[LedSegment_G] = pgm_read_byte(p++); - color.Segment[LedSegment_Custom] = pgm_read_byte(p++); - - return color; - } - -}; - -typedef NeoBacedfpgsSegmentFeature SevenSegmentFeature; // Abcdefg order is default \ No newline at end of file diff --git a/src/internal/features/DotStar3Elements.h b/src/internal/features/DotStar3Elements.h new file mode 100644 index 0000000..83728f3 --- /dev/null +++ b/src/internal/features/DotStar3Elements.h @@ -0,0 +1,48 @@ +/*------------------------------------------------------------------------- +DotStar3Elements 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 DotStar3ElementsNoSettings : public Neo4ByteRgbElements +{ +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/P9813ColorFeatures.h b/src/internal/features/DotStar4Elements.h similarity index 71% rename from src/internal/P9813ColorFeatures.h rename to src/internal/features/DotStar4Elements.h index de0423c..09c2653 100644 --- a/src/internal/P9813ColorFeatures.h +++ b/src/internal/features/DotStar4Elements.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -P9813ColorFeatures provides feature classes to describe color order and -color depth for NeoPixelBus template class when used with P9813s +DotStar4Elements provides feature base classes to describe color elements +for NeoPixelBus Color Feature template classes when used with DotStars Written by Michael C. Miller. @@ -26,10 +26,11 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class P98133Elements + +class DotStar4Elements { public: - static const size_t PixelSize = 4; // still requires 4 to be sent + static const size_t PixelSize = 4; static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel) { @@ -90,10 +91,11 @@ public: } } - typedef RgbColor ColorObject; + typedef RgbwColor ColorObject; }; -class P98133ElementsNoSettings : public P98133Elements + +class DotStar4ElementsNoSettings : public DotStar4Elements { public: typedef NeoNoSettings SettingsObject; @@ -112,51 +114,4 @@ public: { return pData; } -}; - -class P9813BgrFeature : public P98133ElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = 0xC0 | ((~color.B & 0xC0) >> 2) | ((~color.G & 0xC0) >> 4) | ((~color.R & 0xC0) >> 6); - *p++ = color.B; - *p++ = color.G; - *p = color.R; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - p++; // ignore the first byte - color.B = *p++; - color.G = *p++; - color.R = *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - pgm_read_byte(p++); // ignore the first byte - color.B = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.R = pgm_read_byte(p); - - return color; - } - -}; - - - - - - +}; \ No newline at end of file diff --git a/src/internal/features/DotStarBgrFeature.h b/src/internal/features/DotStarBgrFeature.h new file mode 100644 index 0000000..30cf0d7 --- /dev/null +++ b/src/internal/features/DotStarBgrFeature.h @@ -0,0 +1,69 @@ +/*------------------------------------------------------------------------- +DotStarBgrFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarBgrFeature : public DotStar3ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xff; // upper three bits are always 111 and brightness at max + *p++ = color.B; + *p++ = color.G; + *p = color.R; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + p++; // ignore the first byte + color.B = *p++; + color.G = *p++; + color.R = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + pgm_read_byte(p++); // ignore the first byte + color.B = pgm_read_byte(p++); + color.G = pgm_read_byte(p++); + color.R = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarBrgFeature.h b/src/internal/features/DotStarBrgFeature.h new file mode 100644 index 0000000..9edde6a --- /dev/null +++ b/src/internal/features/DotStarBrgFeature.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- +DotStarBrgFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarBrgFeature : public DotStar3ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xff; // upper three bits are always 111 and brightness at max + *p++ = color.B; + *p++ = color.R; + *p = color.G; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + p++; // ignore the first byte + color.B = *p++; + color.R = *p++; + color.G = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + pgm_read_byte(p++); // ignore the first byte + color.B = pgm_read_byte(p++); + color.R = pgm_read_byte(p++); + color.G = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarGbrFeature.h b/src/internal/features/DotStarGbrFeature.h new file mode 100644 index 0000000..f280a76 --- /dev/null +++ b/src/internal/features/DotStarGbrFeature.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- +DotStarGbrFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarGbrFeature : public DotStar3ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xff; // upper three bits are always 111 and brightness at max + *p++ = color.G; + *p++ = color.B; + *p = color.R; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + p++; // ignore the first byte + color.G = *p++; + color.B = *p++; + color.R = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + pgm_read_byte(p++); // ignore the first byte + color.G = pgm_read_byte(p++); + color.B = pgm_read_byte(p++); + color.R = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarGrbFeature.h b/src/internal/features/DotStarGrbFeature.h new file mode 100644 index 0000000..6cdb266 --- /dev/null +++ b/src/internal/features/DotStarGrbFeature.h @@ -0,0 +1,69 @@ +/*------------------------------------------------------------------------- +DotStarGrbFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarGrbFeature : public DotStar3ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xff; // upper three bits are always 111 and brightness at max + *p++ = color.G; + *p++ = color.R; + *p = color.B; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + p++; // ignore the first byte + color.G = *p++; + color.R = *p++; + color.B = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + pgm_read_byte(p++); // ignore the first byte + color.G = pgm_read_byte(p++); + color.R = pgm_read_byte(p++); + color.B = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarLbgrFeature.h b/src/internal/features/DotStarLbgrFeature.h new file mode 100644 index 0000000..d5cfac2 --- /dev/null +++ b/src/internal/features/DotStarLbgrFeature.h @@ -0,0 +1,69 @@ +/*------------------------------------------------------------------------- +DotStarLbgrFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarLbgrFeature : public DotStar4ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 + *p++ = color.B; + *p++ = color.G; + *p = color.R; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.W = (*p++) & 0x1F; // mask out upper three bits + color.B = *p++; + color.G = *p++; + color.R = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits + color.B = pgm_read_byte(p++); + color.G = pgm_read_byte(p++); + color.R = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarLbrgFeature.h b/src/internal/features/DotStarLbrgFeature.h new file mode 100644 index 0000000..8addf5d --- /dev/null +++ b/src/internal/features/DotStarLbrgFeature.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- +DotStarLbrgFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarLbrgFeature : public DotStar4ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 + *p++ = color.B; + *p++ = color.R; + *p = color.G; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.W = (*p++) & 0x1F; // mask out upper three bits + color.B = *p++; + color.R = *p++; + color.G = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits + color.B = pgm_read_byte(p++); + color.R = pgm_read_byte(p++); + color.G = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarLgbrFeature.h b/src/internal/features/DotStarLgbrFeature.h new file mode 100644 index 0000000..0d0958a --- /dev/null +++ b/src/internal/features/DotStarLgbrFeature.h @@ -0,0 +1,69 @@ +/*------------------------------------------------------------------------- +DotStarLgbrFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarLgbrFeature : public DotStar4ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 + *p++ = color.G; + *p++ = color.B; + *p = color.R; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.W = (*p++) & 0x1F; // mask out upper three bits + color.G = *p++; + color.B = *p++; + color.R = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits + color.G = pgm_read_byte(p++); + color.B = pgm_read_byte(p++); + color.R = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarLgrbFeature.h b/src/internal/features/DotStarLgrbFeature.h new file mode 100644 index 0000000..5579e39 --- /dev/null +++ b/src/internal/features/DotStarLgrbFeature.h @@ -0,0 +1,69 @@ +/*------------------------------------------------------------------------- +DotStarLgrbFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarLgrbFeature : public DotStar4ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 + *p++ = color.G; + *p++ = color.R; + *p = color.B; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.W = (*p++) & 0x1F; // mask out upper three bits + color.G = *p++; + color.R = *p++; + color.B = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits + color.G = pgm_read_byte(p++); + color.R = pgm_read_byte(p++); + color.B = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarLrbgFeature.h b/src/internal/features/DotStarLrbgFeature.h new file mode 100644 index 0000000..414f1f3 --- /dev/null +++ b/src/internal/features/DotStarLrbgFeature.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- +DotStarLrbgFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarLrbgFeature : public DotStar4ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 + *p++ = color.R; + *p++ = color.B; + *p = color.G; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.W = (*p++) & 0x1F; // mask out upper three bits + color.R = *p++; + color.B = *p++; + color.G = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits + color.R = pgm_read_byte(p++); + color.B = pgm_read_byte(p++); + color.G = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarLrgbFeature.h b/src/internal/features/DotStarLrgbFeature.h new file mode 100644 index 0000000..bcd95ee --- /dev/null +++ b/src/internal/features/DotStarLrgbFeature.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- +DotStarLrgbFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarLrgbFeature : public DotStar4ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111 + *p++ = color.R; + *p++ = color.G; + *p = color.B; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.W = (*p++) & 0x1F; // mask out upper three bits + color.R = *p++; + color.G = *p++; + color.B = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits + color.R = pgm_read_byte(p++); + color.G = pgm_read_byte(p++); + color.B = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarRbgFeature.h b/src/internal/features/DotStarRbgFeature.h new file mode 100644 index 0000000..239d614 --- /dev/null +++ b/src/internal/features/DotStarRbgFeature.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- +DotStarRbgFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarRbgFeature : public DotStar3ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xff; // upper three bits are always 111 and brightness at max + *p++ = color.R; + *p++ = color.B; + *p = color.G; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + p++; // ignore the first byte + color.R = *p++; + color.B = *p++; + color.G = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + pgm_read_byte(p++); // ignore the first byte + color.R = pgm_read_byte(p++); + color.B = pgm_read_byte(p++); + color.G = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/DotStarRgbFeature.h b/src/internal/features/DotStarRgbFeature.h new file mode 100644 index 0000000..2630f13 --- /dev/null +++ b/src/internal/features/DotStarRgbFeature.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- +DotStarRgbFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class 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 DotStarRgbFeature : public DotStar3ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xff; // upper three bits are always 111 and brightness at max + *p++ = color.R; + *p++ = color.G; + *p = color.B; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + p++; // ignore the first byte + color.R = *p++; + color.G = *p++; + color.B = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + pgm_read_byte(p++); // ignore the first byte + color.R = pgm_read_byte(p++); + color.G = pgm_read_byte(p++); + color.B = pgm_read_byte(p); + + return color; + } + +}; diff --git a/src/internal/features/Lpd6803BrgFeature.h b/src/internal/features/Lpd6803BrgFeature.h new file mode 100644 index 0000000..da60287 --- /dev/null +++ b/src/internal/features/Lpd6803BrgFeature.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------------------- +Lpd6803BrgFeature provides feature class to describe color order and +color depth for NeoPixelBus template class when used with DotStar like chips + +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 Lpd6803BrgFeature : public Neo2ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + uint16_t color555; + + encodePixel(color.B, color.R, color.G, &color555); + *p++ = color555 >> 8; + *p = color555 & 0xff; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + uint16_t color555; + + color555 = ((*p++) << 8); + color555 |= (*p); + + decodePixel(color555, &color.B, &color.R, &color.G); + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + uint16_t color555; + + color555 = (pgm_read_byte(p++) << 8); + color555 |= pgm_read_byte(p); + + decodePixel(color555, &color.B, &color.R, &color.G); + + return color; + } +}; diff --git a/src/internal/features/Lpd6803GbrFeature.h b/src/internal/features/Lpd6803GbrFeature.h new file mode 100644 index 0000000..81e25dc --- /dev/null +++ b/src/internal/features/Lpd6803GbrFeature.h @@ -0,0 +1,73 @@ +/*------------------------------------------------------------------------- +Lpd6803GbrFeature provides feature class to describe color order and +color depth for NeoPixelBus template class when used with DotStar like chips + +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 Lpd6803GbrFeature : public Neo2ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + uint16_t color555; + + encodePixel(color.G, color.B, color.R, &color555); + *p++ = color555 >> 8; + *p = color555 & 0xff; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + uint16_t color555; + + color555 = ((*p++) << 8); + color555 |= (*p); + + decodePixel(color555, &color.G, &color.B, &color.R); + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + uint16_t color555; + + color555 = (pgm_read_byte(p++) << 8); + color555 |= pgm_read_byte(p); + + decodePixel(color555, &color.G, &color.B, &color.R); + + return color; + } +}; + diff --git a/src/internal/features/Lpd6803GrbFeature.h b/src/internal/features/Lpd6803GrbFeature.h new file mode 100644 index 0000000..9799040 --- /dev/null +++ b/src/internal/features/Lpd6803GrbFeature.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------------------- +Lpd6803GrbFeature provides feature class to describe color order and +color depth for NeoPixelBus template class when used with DotStar like chips + +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 Lpd6803GrbFeature : public Neo2ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + uint16_t color555; + + encodePixel(color.G, color.R, color.B, &color555); + *p++ = color555 >> 8; + *p = color555 & 0xff; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + uint16_t color555; + + color555 = ((*p++) << 8); + color555 |= (*p); + + decodePixel(color555, &color.G, &color.R, &color.B); + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + uint16_t color555; + + color555 = (pgm_read_byte(p++) << 8); + color555 |= pgm_read_byte(p); + + decodePixel(color555, &color.G, &color.R, &color.B); + + return color; + } +}; diff --git a/src/internal/features/Lpd6803RgbFeature.h b/src/internal/features/Lpd6803RgbFeature.h new file mode 100644 index 0000000..92bea7e --- /dev/null +++ b/src/internal/features/Lpd6803RgbFeature.h @@ -0,0 +1,73 @@ +/*------------------------------------------------------------------------- +Lpd6803RgbFeature provides feature class to describe color order and +color depth for NeoPixelBus template class when used with DotStar like chips + +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 Lpd6803RgbFeature : public Neo2ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + uint16_t color555; + + encodePixel(color.R, color.G, color.B, &color555); + *p++ = color555 >> 8; + *p = color555 & 0xff; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + uint16_t color555; + + color555 = ((*p++) << 8); + color555 |= (*p); + + decodePixel(color555, &color.R, &color.G, &color.B); + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + uint16_t color555; + + color555 = (pgm_read_byte(p++) << 8); + color555 |= pgm_read_byte(p); + + decodePixel(color555, &color.R, &color.G, &color.B); + + return color; + } +}; + + diff --git a/src/internal/features/Lpd8806BrgFeature.h b/src/internal/features/Lpd8806BrgFeature.h new file mode 100644 index 0000000..4d3f1fb --- /dev/null +++ b/src/internal/features/Lpd8806BrgFeature.h @@ -0,0 +1,66 @@ +/*------------------------------------------------------------------------- +Lpd8806BrgFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class when used with DotStar like chips + +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 Lpd8806BrgFeature : public Neo3ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = (color.B >> 1) | 0x80; + *p++ = (color.R >> 1) | 0x80; + *p = (color.G >> 1) | 0x80; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.B = (*p++) << 1; + color.R = (*p++) << 1; + color.G = (*p) << 1; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.B = (pgm_read_byte(p++)) << 1; + color.R = (pgm_read_byte(p++)) << 1; + color.G = (pgm_read_byte(p)) << 1; + + return color; + } + +}; + diff --git a/src/internal/features/Lpd8806GrbFeature.h b/src/internal/features/Lpd8806GrbFeature.h new file mode 100644 index 0000000..36ffb6c --- /dev/null +++ b/src/internal/features/Lpd8806GrbFeature.h @@ -0,0 +1,65 @@ +/*------------------------------------------------------------------------- +Lpd8806GrbFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class when used with DotStar like chips + +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 Lpd8806GrbFeature : public Neo3ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = (color.G >> 1) | 0x80; + *p++ = (color.R >> 1) | 0x80; + *p = (color.B >> 1) | 0x80; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.G = (*p++) << 1; + color.R = (*p++) << 1; + color.B = (*p) << 1; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.G = (pgm_read_byte(p++)) << 1; + color.R = (pgm_read_byte(p++)) << 1; + color.B = (pgm_read_byte(p)) << 1; + + return color; + } + +}; diff --git a/src/internal/Lpd8806ColorFeatures.h b/src/internal/features/Neo2ByteElements.h similarity index 53% rename from src/internal/Lpd8806ColorFeatures.h rename to src/internal/features/Neo2ByteElements.h index 62142ed..68ba226 100644 --- a/src/internal/Lpd8806ColorFeatures.h +++ b/src/internal/features/Neo2ByteElements.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -Lpd8806ColorFeatures provides feature classes to describe color order and -color depth for NeoPixelBus template class when used with DotStar like chips +Neo2ByteElements provides feature base classes to describe color elements +for NeoPixelBus Color Feature template classes Written by Michael C. Miller. @@ -26,7 +26,81 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class Lpd88063ElementsNoSettings +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; @@ -45,145 +119,4 @@ public: { return pData; } -}; - -class Lpd88063Elements : public Lpd88063ElementsNoSettings -{ -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) - { - uint8_t* pEnd = pPixelDest + (count * PixelSize); - while (pPixelDest < pEnd) - { - *pPixelDest++ = pPixelSrc[0]; - *pPixelDest++ = pPixelSrc[1]; - *pPixelDest++ = pPixelSrc[2]; - } - } - - 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++; - } - } - - 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++); - } - } - - 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; - } - } - - typedef RgbColor ColorObject; -}; - -class Lpd8806BrgFeature : public Lpd88063Elements -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = (color.B >> 1) | 0x80; - *p++ = (color.R >> 1) | 0x80; - *p = (color.G >> 1) | 0x80; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.B = (*p++) << 1; - color.R = (*p++) << 1; - color.G = (*p) << 1; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - color.B = (pgm_read_byte(p++)) << 1; - color.R = (pgm_read_byte(p++)) << 1; - color.G = (pgm_read_byte(p)) << 1; - - return color; - } - -}; - -class Lpd8806GrbFeature : public Lpd88063Elements -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = (color.G >> 1) | 0x80; - *p++ = (color.R >> 1) | 0x80; - *p = (color.B >> 1) | 0x80; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - color.G = (*p++) << 1; - color.R = (*p++) << 1; - color.B = (*p) << 1; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); - - color.G = (pgm_read_byte(p++)) << 1; - color.R = (pgm_read_byte(p++)) << 1; - color.B = (pgm_read_byte(p)) << 1; - - return color; - } - -}; - +}; \ No newline at end of file diff --git a/src/internal/features/Neo3ByteElements.h b/src/internal/features/Neo3ByteElements.h new file mode 100644 index 0000000..a2a9984 --- /dev/null +++ b/src/internal/features/Neo3ByteElements.h @@ -0,0 +1,110 @@ +/*------------------------------------------------------------------------- +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 new file mode 100644 index 0000000..1f78b18 --- /dev/null +++ b/src/internal/features/Neo4ByteElements.h @@ -0,0 +1,125 @@ +/*------------------------------------------------------------------------- +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/Neo6ByteElements.h b/src/internal/features/Neo6ByteElements.h new file mode 100644 index 0000000..6a793fa --- /dev/null +++ b/src/internal/features/Neo6ByteElements.h @@ -0,0 +1,115 @@ +/*------------------------------------------------------------------------- +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 new file mode 100644 index 0000000..041c1cb --- /dev/null +++ b/src/internal/features/Neo8ByteElements.h @@ -0,0 +1,115 @@ +/*------------------------------------------------------------------------- +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 new file mode 100644 index 0000000..7298422 --- /dev/null +++ b/src/internal/features/Neo9ByteElements.h @@ -0,0 +1,106 @@ +/*------------------------------------------------------------------------- +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 new file mode 100644 index 0000000..e4af477 --- /dev/null +++ b/src/internal/features/NeoAbcdefgpsSegmentFeature.h @@ -0,0 +1,70 @@ +/*------------------------------------------------------------------------- +NeoAbcdefgpsSegmentFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class when used with seven segment display + +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 + +// Abcdefgps byte order +class NeoAbcdefgpsSegmentFeature : public Neo9ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count; + for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++) + { + *p++ = color.Segment[iSegment]; + } + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count; + + for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++) + { + color.Segment[iSegment] = *p++; + } + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count; + + for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++) + { + color.Segment[iSegment] = pgm_read_byte(p++); + } + + return color; + } + +}; \ No newline at end of file diff --git a/src/internal/features/NeoBacedfpgsSegmentFeature.h b/src/internal/features/NeoBacedfpgsSegmentFeature.h new file mode 100644 index 0000000..092b94a --- /dev/null +++ b/src/internal/features/NeoBacedfpgsSegmentFeature.h @@ -0,0 +1,91 @@ +/*------------------------------------------------------------------------- +NeoBacedfpgsSegmentFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class when used with seven segment display + +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 + +// BACEDF.G+ byte order +class NeoBacedfpgsSegmentFeature : public Neo9ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + // Segment Digit is Abcdefgps order + *p++ = color.Segment[LedSegment_B]; + *p++ = color.Segment[LedSegment_A]; + *p++ = color.Segment[LedSegment_C]; + + *p++ = color.Segment[LedSegment_E]; + *p++ = color.Segment[LedSegment_D]; + *p++ = color.Segment[LedSegment_F]; + + *p++ = color.Segment[LedSegment_Decimal]; + *p++ = color.Segment[LedSegment_G]; + *p++ = color.Segment[LedSegment_Custom]; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.Segment[LedSegment_B] = *p++; + color.Segment[LedSegment_A] = *p++; + color.Segment[LedSegment_C] = *p++; + + color.Segment[LedSegment_E] = *p++; + color.Segment[LedSegment_D] = *p++; + color.Segment[LedSegment_F] = *p++; + + color.Segment[LedSegment_Decimal] = *p++; + color.Segment[LedSegment_G] = *p++; + color.Segment[LedSegment_Custom] = *p++; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + color.Segment[LedSegment_B] = pgm_read_byte(p++); + color.Segment[LedSegment_A] = pgm_read_byte(p++); + color.Segment[LedSegment_C] = pgm_read_byte(p++); + + color.Segment[LedSegment_E] = pgm_read_byte(p++); + color.Segment[LedSegment_D] = pgm_read_byte(p++); + color.Segment[LedSegment_F] = pgm_read_byte(p++); + + color.Segment[LedSegment_Decimal] = pgm_read_byte(p++); + color.Segment[LedSegment_G] = pgm_read_byte(p++); + color.Segment[LedSegment_Custom] = pgm_read_byte(p++); + + return color; + } + +}; diff --git a/src/internal/features/NeoBgrFeature.h b/src/internal/features/NeoBgrFeature.h new file mode 100644 index 0000000..04ae35d --- /dev/null +++ b/src/internal/features/NeoBgrFeature.h @@ -0,0 +1,66 @@ +/*------------------------------------------------------------------------- +NeoBgrFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class + +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 NeoBgrFeature : public Neo3ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = color.B; + *p++ = color.G; + *p = color.R; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.B = *p++; + color.G = *p++; + color.R = *p; + + return color; + } + + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); + + color.B = pgm_read_byte(p++); + color.G = pgm_read_byte(p++); + color.R = pgm_read_byte(p); + + return color; + } +}; diff --git a/src/internal/features/NeoBrgFeature.h b/src/internal/features/NeoBrgFeature.h new file mode 100644 index 0000000..374b4c6 --- /dev/null +++ b/src/internal/features/NeoBrgFeature.h @@ -0,0 +1,64 @@ +/*------------------------------------------------------------------------- +NeoBrgFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class + +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 NeoBrgFeature : public Neo3ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = color.B; + *p++ = color.R; + *p = color.G; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.B = *p++; + color.R = *p++; + color.G = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); + + color.B = pgm_read_byte(p++); + color.R = pgm_read_byte(p++); + color.G = pgm_read_byte(p); + + return color; + } +}; diff --git a/src/internal/features/NeoGrb48Feature.h b/src/internal/features/NeoGrb48Feature.h new file mode 100644 index 0000000..f53bba2 --- /dev/null +++ b/src/internal/features/NeoGrb48Feature.h @@ -0,0 +1,64 @@ +/*------------------------------------------------------------------------- +NeoGrb48Feature provides feature classes to describe color order and +color depth for NeoPixelBus template class + +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 NeoGrb48Feature : public Neo6ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); + + *p++ = color.G; + *p++ = color.R; + *p = color.B; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); + + color.G = *p++; + color.R = *p++; + color.B = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint16_t* p = reinterpret_cast(getPixelAddress(reinterpret_cast(pPixels), indexPixel)); + + color.G = pgm_read_word(p++); + color.R = pgm_read_word(p++); + color.B = pgm_read_word(p); + + return color; + } +}; diff --git a/src/internal/features/NeoGrbFeature.h b/src/internal/features/NeoGrbFeature.h new file mode 100644 index 0000000..c246e55 --- /dev/null +++ b/src/internal/features/NeoGrbFeature.h @@ -0,0 +1,64 @@ +/*------------------------------------------------------------------------- +NeoGrbFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class + +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 NeoGrbFeature : public Neo3ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = color.G; + *p++ = color.R; + *p = color.B; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.G = *p++; + color.R = *p++; + color.B = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); + + color.G = pgm_read_byte(p++); + color.R = pgm_read_byte(p++); + color.B = pgm_read_byte(p); + + return color; + } +}; \ No newline at end of file diff --git a/src/internal/features/NeoGrbwFeature.h b/src/internal/features/NeoGrbwFeature.h new file mode 100644 index 0000000..e6aea51 --- /dev/null +++ b/src/internal/features/NeoGrbwFeature.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- +NeoGrbwFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class + +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 NeoGrbwFeature : public Neo4ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = color.G; + *p++ = color.R; + *p++ = color.B; + *p = color.W; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.G = *p++; + color.R = *p++; + color.B = *p++; + color.W = *p; + + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); + + color.G = pgm_read_byte(p++); + color.R = pgm_read_byte(p++); + color.B = pgm_read_byte(p++); + color.W = pgm_read_byte(p); + + return color; + } +}; diff --git a/src/internal/features/NeoRbgFeature.h b/src/internal/features/NeoRbgFeature.h new file mode 100644 index 0000000..7fde324 --- /dev/null +++ b/src/internal/features/NeoRbgFeature.h @@ -0,0 +1,66 @@ +/*------------------------------------------------------------------------- +NeoRbgFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class + +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 NeoRbgFeature : public Neo3ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = color.R; + *p++ = color.B; + *p = color.G; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.R = *p++; + color.B = *p++; + color.G = *p; + + return color; + } + + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); + + color.R = pgm_read_byte(p++); + color.B = pgm_read_byte(p++); + color.G = pgm_read_byte(p); + + return color; + } +}; \ No newline at end of file diff --git a/src/internal/features/NeoRgb48Feature.h b/src/internal/features/NeoRgb48Feature.h new file mode 100644 index 0000000..e9c7b63 --- /dev/null +++ b/src/internal/features/NeoRgb48Feature.h @@ -0,0 +1,64 @@ +/*------------------------------------------------------------------------- +NeoRgb48Feature provides feature classes to describe color order and +color depth for NeoPixelBus template class + +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 NeoRgb48Feature : public Neo6ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); + + *p++ = color.R; + *p++ = color.G; + *p = color.B; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); + + color.R = *p++; + color.G = *p++; + color.B = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint16_t* p = reinterpret_cast(getPixelAddress(reinterpret_cast(pPixels), indexPixel)); + + color.R = pgm_read_word(p++); + color.G = pgm_read_word(p++); + color.B = pgm_read_word(p); + + return color; + } +}; diff --git a/src/internal/features/NeoRgbFeature.h b/src/internal/features/NeoRgbFeature.h new file mode 100644 index 0000000..134af52 --- /dev/null +++ b/src/internal/features/NeoRgbFeature.h @@ -0,0 +1,64 @@ +/*------------------------------------------------------------------------- +NeoRgbFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class + +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 NeoRgbFeature : public Neo3ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = color.R; + *p++ = color.G; + *p = color.B; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.R = *p++; + color.G = *p++; + color.B = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); + + color.R = pgm_read_byte(p++); + color.G = pgm_read_byte(p++); + color.B = pgm_read_byte(p); + + return color; + } +}; diff --git a/src/internal/features/NeoRgbw64Feature.h b/src/internal/features/NeoRgbw64Feature.h new file mode 100644 index 0000000..b09369e --- /dev/null +++ b/src/internal/features/NeoRgbw64Feature.h @@ -0,0 +1,68 @@ +/*------------------------------------------------------------------------- +NeoRgbw64Feature provides feature classes to describe color order and +color depth for NeoPixelBus template class + +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 NeoRgbw64Feature : public Neo8ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); + + *p++ = color.R; + *p++ = color.G; + *p++ = color.B; + *p = color.W; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint16_t* p = reinterpret_cast(getPixelAddress(pPixels, indexPixel)); + + color.R = *p++; + color.G = *p++; + color.B = *p++; + color.W = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint16_t* p = reinterpret_cast(getPixelAddress(reinterpret_cast(pPixels), indexPixel)); + + color.R = pgm_read_word(p++); + color.G = pgm_read_word(p++); + color.B = pgm_read_word(p++); + color.W = pgm_read_word(p); + + return color; + } +}; diff --git a/src/internal/features/NeoRgbwFeature.h b/src/internal/features/NeoRgbwFeature.h new file mode 100644 index 0000000..7ab746b --- /dev/null +++ b/src/internal/features/NeoRgbwFeature.h @@ -0,0 +1,67 @@ +/*------------------------------------------------------------------------- +NeoRgbwFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class + +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 NeoRgbwFeature : public Neo4ByteElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = color.R; + *p++ = color.G; + *p++ = color.B; + *p = color.W; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color.R = *p++; + color.G = *p++; + color.B = *p++; + color.W = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(reinterpret_cast(pPixels), indexPixel); + + color.R = pgm_read_byte(p++); + color.G = pgm_read_byte(p++); + color.B = pgm_read_byte(p++); + color.W = pgm_read_byte(p); + + return color; + } +}; diff --git a/src/internal/NeoSm168xxColorFeatures.h b/src/internal/features/NeoSm168xxColorFeatures.h similarity index 100% rename from src/internal/NeoSm168xxColorFeatures.h rename to src/internal/features/NeoSm168xxColorFeatures.h diff --git a/src/internal/NeoTm1814ColorFeatures.h b/src/internal/features/NeoTm1814ColorFeatures.h similarity index 100% rename from src/internal/NeoTm1814ColorFeatures.h rename to src/internal/features/NeoTm1814ColorFeatures.h diff --git a/src/internal/NeoTm1914ColorFeatures.h b/src/internal/features/NeoTm1914ColorFeatures.h similarity index 100% rename from src/internal/NeoTm1914ColorFeatures.h rename to src/internal/features/NeoTm1914ColorFeatures.h diff --git a/src/internal/features/P9813BgrFeature.h b/src/internal/features/P9813BgrFeature.h new file mode 100644 index 0000000..728c5bc --- /dev/null +++ b/src/internal/features/P9813BgrFeature.h @@ -0,0 +1,75 @@ +/*------------------------------------------------------------------------- +P9813BgrFeature provides feature classes to describe color order and +color depth for NeoPixelBus template class when used with P9813s + +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 P9813BgrFeature : public DotStar3ElementsNoSettings +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = 0xC0 | ((~color.B & 0xC0) >> 2) | ((~color.G & 0xC0) >> 4) | ((~color.R & 0xC0) >> 6); + *p++ = color.B; + *p++ = color.G; + *p = color.R; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + p++; // ignore the first byte + color.B = *p++; + color.G = *p++; + color.R = *p; + + return color; + } + + static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel); + + pgm_read_byte(p++); // ignore the first byte + color.B = pgm_read_byte(p++); + color.G = pgm_read_byte(p++); + color.R = pgm_read_byte(p); + + return color; + } + +}; + + + + + +