From 0320ae01f978928d5b4d84168a3ff0b9c5ccc7d4 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Wed, 7 Feb 2024 16:55:32 -0800 Subject: [PATCH] FiveByteFeature (#765) --- src/internal/NeoColorFeatures.h | 2 + src/internal/features/Neo5ByteFeature.h | 72 ++++++++++++++++++++++++ src/internal/features/NeoRgbwwFeatures.h | 51 +++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 src/internal/features/Neo5ByteFeature.h create mode 100644 src/internal/features/NeoRgbwwFeatures.h diff --git a/src/internal/NeoColorFeatures.h b/src/internal/NeoColorFeatures.h index d7cc9fe..c5d8e65 100644 --- a/src/internal/NeoColorFeatures.h +++ b/src/internal/NeoColorFeatures.h @@ -36,6 +36,7 @@ License along with NeoPixel. If not, see #include "features/Neo3ByteFeature.h" #include "features/Neo3Byte777Feature.h" #include "features/Neo4ByteFeature.h" +#include "features/Neo5ByteFeature.h" #include "features/DotStarX4ByteFeature.h" #include "features/DotStarL4ByteFeature.h" #include "features/Neo6ByteFeature.h" @@ -49,6 +50,7 @@ License along with NeoPixel. If not, see // #include "features/NeoRgbFeatures.h" #include "features/NeoRgbwFeatures.h" +#include "features/NeoRgbwwFeatures.h" #include "features/NeoRgb48Features.h" #include "features/NeoRgbw64Features.h" diff --git a/src/internal/features/Neo5ByteFeature.h b/src/internal/features/Neo5ByteFeature.h new file mode 100644 index 0000000..98b47cf --- /dev/null +++ b/src/internal/features/Neo5ByteFeature.h @@ -0,0 +1,72 @@ +/*------------------------------------------------------------------------- +Neo5ByteFeature provides feature base class to describe color order for + 5 byte features that all 5 bytes are used + +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 + +template +class Neo5ByteFeature : + public NeoByteElements<5, RgbwwColor, uint8_t> +{ +public: + static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) + { + uint8_t* p = getPixelAddress(pPixels, indexPixel); + + *p++ = color[V_IC_1]; + *p++ = color[V_IC_2]; + *p++ = color[V_IC_3]; + *p++ = color[V_IC_4]; + *p = color[V_IC_5]; + } + + static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) + { + ColorObject color; + const uint8_t* p = getPixelAddress(pPixels, indexPixel); + + color[V_IC_1] = *p++; + color[V_IC_2] = *p++; + color[V_IC_3] = *p++; + color[V_IC_4] = *p++; + color[V_IC_5] = *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[V_IC_1] = pgm_read_byte(p++); + color[V_IC_2] = pgm_read_byte(p++); + color[V_IC_3] = pgm_read_byte(p++); + color[V_IC_4] = pgm_read_byte(p++); + color[V_IC_5] = pgm_read_byte(p); + + return color; + } +}; \ No newline at end of file diff --git a/src/internal/features/NeoRgbwwFeatures.h b/src/internal/features/NeoRgbwwFeatures.h new file mode 100644 index 0000000..81fd586 --- /dev/null +++ b/src/internal/features/NeoRgbwwFeatures.h @@ -0,0 +1,51 @@ +/*------------------------------------------------------------------------- +NeoRgbwwFeature 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 NeoGrbwwFeature : + public Neo5ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoGbrwwFeature : + public Neo5ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoRgbwwFeature : + public Neo5ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoRbgwwFeature : + public Neo5ByteFeature, + public NeoElementsNoSettings +{ +};