diff --git a/src/internal/NeoColorFeatures.h b/src/internal/NeoColorFeatures.h index 3437eab..b33a170 100644 --- a/src/internal/NeoColorFeatures.h +++ b/src/internal/NeoColorFeatures.h @@ -30,22 +30,28 @@ License along with NeoPixel. If not, see // #include "features/NeoElementsNoSettings.h" #include "features/NeoByteElements.h" -#include "features/Neo2Byte555Elements.h" + +// Core Feature base classes +#include "features/Neo2Byte555Feature.h" +#include "features/Neo3ByteFeature.h" +#include "features/Neo3Byte777Feature.h" +#include "features/Neo4ByteFeature.h" +#include "features/DotStarX4ByteFeature.h" +#include "features/DotStarL4ByteFeature.h" +#include "features/Neo6xByteFeature.h" +#include "features/Neo6xxByteFeature.h" +#include "features/Neo3WordFeature.h" +#include "features/Neo4WordFeature.h" // NeoPixel Features // -#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/NeoRgbwxxFeature.h" -#include "features/NeoGrbcwxFeature.h" +#include "features/NeoRgbFeatures.h" +#include "features/NeoRgbwFeatures.h" +#include "features/NeoRgb48Features.h" +#include "features/NeoRgbw64Features.h" + +#include "features/NeoRgbwxxFeatures.h" +#include "features/NeoRgbcwxFeatures.h" #include "features/NeoSm168xxFeatures.h" #include "features/NeoTm1814Features.h" #include "features/NeoTm1914Features.h" @@ -56,24 +62,11 @@ typedef NeoGrb48Feature NeoGrbWs2816Feature; // DotStart Features // -#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/DotStarRgbFeatures.h" +#include "features/DotStarLrgbFeatures.h" +#include "features/Lpd6803RgbFeatures.h" +#include "features/Lpd8806RgbFeatures.h" + #include "features/P9813BgrFeature.h" // 7 Segment Features diff --git a/src/internal/NeoColors.h b/src/internal/NeoColors.h index 5842209..dd26204 100644 --- a/src/internal/NeoColors.h +++ b/src/internal/NeoColors.h @@ -28,6 +28,7 @@ License along with NeoPixel. If not, see #include "colors/NeoHueBlend.h" +#include "colors/RgbColorIndexes.h" #include "colors/RgbColorBase.h" #include "colors/RgbColor.h" diff --git a/src/internal/NeoSettings.h b/src/internal/NeoSettings.h index c4ececa..3835d6a 100644 --- a/src/internal/NeoSettings.h +++ b/src/internal/NeoSettings.h @@ -39,6 +39,23 @@ public: { } + // ------------------------------------------------------------------------ + // operator [] - readonly + // access elements in order by index rather than member name + // ------------------------------------------------------------------------ + uint16_t operator[](size_t idx) const + { + switch (idx) + { + case 0: + return RedTenthMilliAmpere; + case 1: + return GreenTenthMilliAmpere; + default: + return BlueTenthMilliAmpere; + } + } + const uint16_t RedTenthMilliAmpere; // in 1/10th ma const uint16_t GreenTenthMilliAmpere; // in 1/10th ma const uint16_t BlueTenthMilliAmpere; // in 1/10th ma @@ -55,6 +72,25 @@ public: { } + // ------------------------------------------------------------------------ + // operator [] - readonly + // access elements in order by index rather than member name + // ------------------------------------------------------------------------ + uint16_t operator[](size_t idx) const + { + switch (idx) + { + case 0: + return RedTenthMilliAmpere; + case 1: + return GreenTenthMilliAmpere; + case 2: + return BlueTenthMilliAmpere; + default: + return WhiteTenthMilliAmpere; + } + } + const uint16_t RedTenthMilliAmpere; // in 1/10th ma const uint16_t GreenTenthMilliAmpere; // in 1/10th ma const uint16_t BlueTenthMilliAmpere; // in 1/10th ma @@ -73,6 +109,27 @@ public: { } + // ------------------------------------------------------------------------ + // operator [] - readonly + // access elements in order by index rather than member name + // ------------------------------------------------------------------------ + uint16_t operator[](size_t idx) const + { + switch (idx) + { + case 0: + return RedTenthMilliAmpere; + case 1: + return GreenTenthMilliAmpere; + case 2: + return BlueTenthMilliAmpere; + case 3: + return WarmWhiteTenthMilliAmpere; + default: + return CoolWhiteTenthMilliAmpere; + } + } + const uint16_t RedTenthMilliAmpere; // in 1/10th ma const uint16_t GreenTenthMilliAmpere; // in 1/10th ma const uint16_t BlueTenthMilliAmpere; // in 1/10th ma diff --git a/src/internal/buffers/NeoBufferProgmemMethod.h b/src/internal/buffers/NeoBufferProgmemMethod.h index c46848b..b03b72d 100644 --- a/src/internal/buffers/NeoBufferProgmemMethod.h +++ b/src/internal/buffers/NeoBufferProgmemMethod.h @@ -41,9 +41,9 @@ public: return NeoBufferContext(Pixels(), PixelsSize()); } - uint8_t* Pixels() const + const uint8_t* Pixels() const { - return (uint8_t*)_pixels; + return reinterpret_cast(_pixels); }; size_t PixelsSize() const diff --git a/src/internal/colors/RgbColorIndexes.h b/src/internal/colors/RgbColorIndexes.h new file mode 100644 index 0000000..ea2bac0 --- /dev/null +++ b/src/internal/colors/RgbColorIndexes.h @@ -0,0 +1,35 @@ +/*------------------------------------------------------------------------- +RgbColorIndexes provides constants for color element vector access on + RGB(w) Color Objects + +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 + +const uint8_t ColorIndexR = 0; +const uint8_t ColorIndexG = 1; +const uint8_t ColorIndexB = 2; +const uint8_t ColorIndexW = 3; +const uint8_t ColorIndexWW = 3; // warmer white +const uint8_t ColorIndexCW = 4; // cooler white \ No newline at end of file diff --git a/src/internal/features/DotStarBrgFeature.h b/src/internal/features/DotStarBrgFeature.h deleted file mode 100644 index 9a91e80..0000000 --- a/src/internal/features/DotStarBrgFeature.h +++ /dev/null @@ -1,70 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<4, RgbColor, uint32_t>, - public NeoElementsNoSettings -{ -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 deleted file mode 100644 index de490cb..0000000 --- a/src/internal/features/DotStarGbrFeature.h +++ /dev/null @@ -1,70 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<4, RgbColor, uint32_t>, - public NeoElementsNoSettings -{ -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 deleted file mode 100644 index 54b89bf..0000000 --- a/src/internal/features/DotStarGrbFeature.h +++ /dev/null @@ -1,71 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<4, RgbColor, uint32_t>, - public NeoElementsNoSettings -{ -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/DotStarL4ByteFeature.h similarity index 76% rename from src/internal/features/DotStarLbgrFeature.h rename to src/internal/features/DotStarL4ByteFeature.h index 379e5f0..0e6a0b1 100644 --- a/src/internal/features/DotStarLbgrFeature.h +++ b/src/internal/features/DotStarL4ByteFeature.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -DotStarLbgrFeature provides feature classes to describe color order and -color depth for NeoPixelBus template class when used with DotStars +DotStarL4Feature provides feature base class to describe color order for + 3 color but 4 byte features when used with DotStars, exposing Luminance as W Written by Michael C. Miller. @@ -26,10 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once - -class DotStarLbgrFeature : - public NeoByteElements<4, RgbwColor, uint32_t>, - public NeoElementsNoSettings +template +class DotStarL4Feature : + public NeoByteElements<4, RgbwColor, uint32_t> { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -37,9 +36,9 @@ public: 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; + *p++ = color[V_IC_1]; + *p++ = color[V_IC_2]; + *p = color[V_IC_3]; } static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) @@ -48,9 +47,9 @@ public: 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; + color[V_IC_1] = *p++; + color[V_IC_2] = *p++; + color[V_IC_3] = *p; return color; } @@ -61,9 +60,9 @@ public: 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); + color[V_IC_1] = pgm_read_byte(p++); + color[V_IC_2] = pgm_read_byte(p++); + color[V_IC_3] = pgm_read_byte(p); return color; } diff --git a/src/internal/features/DotStarLbrgFeature.h b/src/internal/features/DotStarLbrgFeature.h deleted file mode 100644 index 17e6e3f..0000000 --- a/src/internal/features/DotStarLbrgFeature.h +++ /dev/null @@ -1,70 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<4, RgbwColor, uint32_t>, - public NeoElementsNoSettings -{ -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 deleted file mode 100644 index 32f6f03..0000000 --- a/src/internal/features/DotStarLgbrFeature.h +++ /dev/null @@ -1,71 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<4, RgbwColor, uint32_t>, - public NeoElementsNoSettings -{ -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 deleted file mode 100644 index d9928ff..0000000 --- a/src/internal/features/DotStarLgrbFeature.h +++ /dev/null @@ -1,71 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<4, RgbwColor, uint32_t>, - public NeoElementsNoSettings -{ -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 deleted file mode 100644 index 45ef231..0000000 --- a/src/internal/features/DotStarLrbgFeature.h +++ /dev/null @@ -1,70 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<4, RgbwColor, uint32_t>, - public NeoElementsNoSettings -{ -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/DotStarLrgbFeatures.h similarity index 53% rename from src/internal/features/DotStarLrgbFeature.h rename to src/internal/features/DotStarLrgbFeatures.h index 4e925b9..17c6d4f 100644 --- a/src/internal/features/DotStarLrgbFeature.h +++ b/src/internal/features/DotStarLrgbFeatures.h @@ -27,44 +27,39 @@ License along with NeoPixel. If not, see #pragma once class DotStarLrgbFeature : - public NeoByteElements<4, RgbwColor, uint32_t>, + public DotStarL4Feature, public NeoElementsNoSettings { -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; - } - }; + +class DotStarLrbgFeature : + public DotStarL4Feature, + public NeoElementsNoSettings +{ +}; + + +class DotStarLgrbFeature : + public DotStarL4Feature, + public NeoElementsNoSettings +{ +}; + +class DotStarLgbrFeature : + public DotStarL4Feature, + public NeoElementsNoSettings +{ +}; + + +class DotStarLbrgFeature : + public DotStarL4Feature, + public NeoElementsNoSettings +{ +}; + +class DotStarLbgrFeature : + public DotStarL4Feature, + public NeoElementsNoSettings +{ +}; \ No newline at end of file diff --git a/src/internal/features/DotStarRgbFeature.h b/src/internal/features/DotStarRgbFeature.h deleted file mode 100644 index 7df17d8..0000000 --- a/src/internal/features/DotStarRgbFeature.h +++ /dev/null @@ -1,70 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<4, RgbColor, uint32_t>, - public NeoElementsNoSettings -{ -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/DotStarRbgFeature.h b/src/internal/features/DotStarRgbFeatures.h similarity index 53% rename from src/internal/features/DotStarRbgFeature.h rename to src/internal/features/DotStarRgbFeatures.h index f0f440b..158e579 100644 --- a/src/internal/features/DotStarRbgFeature.h +++ b/src/internal/features/DotStarRgbFeatures.h @@ -26,45 +26,40 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class DotStarRbgFeature : - public NeoByteElements<4, RgbColor, uint32_t>, +class DotStarRgbFeature : + public DotStarX4Feature, + public NeoElementsNoSettings +{ +}; + +class DotStarRbgFeature : + public DotStarX4Feature, + public NeoElementsNoSettings +{ +}; + + +class DotStarGbrFeature : + public DotStarX4Feature, + public NeoElementsNoSettings +{ +}; + +class DotStarGrbFeature : + public DotStarX4Feature, + public NeoElementsNoSettings +{ +}; + + +class DotStarBrgFeature : + public DotStarX4Feature, + public NeoElementsNoSettings +{ +}; + +class DotStarBgrFeature : + public DotStarX4Feature, public NeoElementsNoSettings { -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/DotStarBgrFeature.h b/src/internal/features/DotStarX4ByteFeature.h similarity index 76% rename from src/internal/features/DotStarBgrFeature.h rename to src/internal/features/DotStarX4ByteFeature.h index 0581907..2d2aeb7 100644 --- a/src/internal/features/DotStarBgrFeature.h +++ b/src/internal/features/DotStarX4ByteFeature.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -DotStarBgrFeature provides feature classes to describe color order and -color depth for NeoPixelBus template class when used with DotStars +DotStarX4Feature provides feature base class to describe color order for + 3 color but 4 byte features when used with DotStars Written by Michael C. Miller. @@ -26,10 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once - -class DotStarBgrFeature : - public NeoByteElements<4, RgbColor, uint32_t>, - public NeoElementsNoSettings +template +class DotStarX4Feature : + public NeoByteElements<4, RgbColor, uint32_t> { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -37,9 +36,9 @@ public: 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; + *p++ = color[V_IC_1]; + *p++ = color[V_IC_2]; + *p = color[V_IC_3]; } static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) @@ -48,9 +47,9 @@ public: const uint8_t* p = getPixelAddress(pPixels, indexPixel); p++; // ignore the first byte - color.B = *p++; - color.G = *p++; - color.R = *p; + color[V_IC_1] = *p++; + color[V_IC_2] = *p++; + color[V_IC_3] = *p; return color; } @@ -61,9 +60,9 @@ public: 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); + color[V_IC_1] = pgm_read_byte(p++); + color[V_IC_2] = pgm_read_byte(p++); + color[V_IC_3] = pgm_read_byte(p); return color; } diff --git a/src/internal/features/Lpd6803BrgFeature.h b/src/internal/features/Lpd6803BrgFeature.h deleted file mode 100644 index b9fa99b..0000000 --- a/src/internal/features/Lpd6803BrgFeature.h +++ /dev/null @@ -1,75 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<2, RgbColor, uint16_t>, - public NeoElementsNoSettings, - public Neo2Byte555Elements -{ -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/Lpd6803GrbFeature.h b/src/internal/features/Lpd6803GrbFeature.h deleted file mode 100644 index 96bb423..0000000 --- a/src/internal/features/Lpd6803GrbFeature.h +++ /dev/null @@ -1,75 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<2, RgbColor, uint16_t>, - public NeoElementsNoSettings, - public Neo2Byte555Elements -{ -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 deleted file mode 100644 index 23668c7..0000000 --- a/src/internal/features/Lpd6803RgbFeature.h +++ /dev/null @@ -1,76 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<2, RgbColor, uint16_t>, - public NeoElementsNoSettings, - public Neo2Byte555Elements -{ -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/Lpd8806GrbFeature.h b/src/internal/features/Lpd6803RgbFeatures.h similarity index 52% rename from src/internal/features/Lpd8806GrbFeature.h rename to src/internal/features/Lpd6803RgbFeatures.h index 7e95713..15e8fa5 100644 --- a/src/internal/features/Lpd8806GrbFeature.h +++ b/src/internal/features/Lpd6803RgbFeatures.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -Lpd8806GrbFeature provides feature classes to describe color order and +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. @@ -26,42 +26,27 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class Lpd8806GrbFeature : - public NeoByteElements<3, RgbColor, uint8_t>, +class Lpd6803RgbFeature : + public Neo2Byte555Feature, + public NeoElementsNoSettings +{ +}; + + +class Lpd6803GrbFeature : + public Neo2Byte555Feature, + public NeoElementsNoSettings +{ +}; + +class Lpd6803GbrFeature : + public Neo2Byte555Feature, + public NeoElementsNoSettings +{ +}; + +class Lpd6803BrgFeature : + public Neo2Byte555Feature, public NeoElementsNoSettings { -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/features/Lpd8806BrgFeature.h b/src/internal/features/Lpd8806BrgFeature.h deleted file mode 100644 index 6852a7e..0000000 --- a/src/internal/features/Lpd8806BrgFeature.h +++ /dev/null @@ -1,68 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<3, RgbColor, uint8_t>, - public NeoElementsNoSettings -{ -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/Neo2Byte555Elements.h b/src/internal/features/Lpd8806RgbFeatures.h similarity index 63% rename from src/internal/features/Neo2Byte555Elements.h rename to src/internal/features/Lpd8806RgbFeatures.h index 9968cae..e800a1f 100644 --- a/src/internal/features/Neo2Byte555Elements.h +++ b/src/internal/features/Lpd8806RgbFeatures.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -Neo2Byte555Elements provides feature base classes to describe color elements -with 555 encoding for NeoPixelBus Color Feature template classes +Lpd8806RgbFeatures 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. @@ -25,22 +25,15 @@ License along with NeoPixel. If not, see . -------------------------------------------------------------------------*/ #pragma once - -class Neo2Byte555Elements -{ -protected: - static void encodePixel(uint8_t c1, uint8_t c2, uint8_t c3, uint16_t* color555) - { - *color555 = (0x8000 | - ((c1 & 0xf8) << 7) | - ((c2 & 0xf8) << 2) | - ((c3 & 0xf8) >> 3)); - } - static void decodePixel(uint16_t color555, uint8_t* c1, uint8_t* c2, uint8_t* c3) - { - *c1 = (color555 >> 7) & 0xf8; - *c2 = (color555 >> 2) & 0xf8; - *c3 = (color555 << 3) & 0xf8; - } +class Lpd8806GrbFeature : + public Neo3Byte777Feature, + public NeoElementsNoSettings +{ +}; + +class Lpd8806BrgFeature : + public Neo3Byte777Feature, + public NeoElementsNoSettings +{ }; \ No newline at end of file diff --git a/src/internal/features/Lpd6803GbrFeature.h b/src/internal/features/Neo2Byte555Feature.h similarity index 69% rename from src/internal/features/Lpd6803GbrFeature.h rename to src/internal/features/Neo2Byte555Feature.h index 9ee4c43..a9fca0d 100644 --- a/src/internal/features/Lpd6803GbrFeature.h +++ b/src/internal/features/Neo2Byte555Feature.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -Lpd6803GbrFeature provides feature class to describe color order and -color depth for NeoPixelBus template class when used with DotStar like chips +Neo2Byte555Feature provides feature base classes to describe color elements +with 555 encoding for NeoPixelBus Color Feature template classes Written by Michael C. Miller. @@ -25,12 +25,10 @@ License along with NeoPixel. If not, see . -------------------------------------------------------------------------*/ #pragma once - - -class Lpd6803GbrFeature : - public NeoByteElements<2, RgbColor, uint16_t>, - public NeoElementsNoSettings, - public Neo2Byte555Elements + +template +class Neo2Byte555Feature : + public NeoByteElements<2, RgbColor, uint16_t> { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -38,7 +36,7 @@ public: uint8_t* p = getPixelAddress(pPixels, indexPixel); uint16_t color555; - encodePixel(color.G, color.B, color.R, &color555); + encodePixel(&color555, color); *p++ = color555 >> 8; *p = color555 & 0xff; } @@ -53,7 +51,7 @@ public: color555 = ((*p++) << 8); color555 |= (*p); - decodePixel(color555, &color.G, &color.B, &color.R); + decodePixel(&color, color555); return color; } @@ -68,9 +66,24 @@ public: color555 = (pgm_read_byte(p++) << 8); color555 |= pgm_read_byte(p); - decodePixel(color555, &color.G, &color.B, &color.R); + decodePixel(&color, color555); return color; } -}; +protected: + static void encodePixel(uint16_t* color555, const ColorObject& color) + { + *color555 = (0x8000 | + ((color[V_IC_1] & 0xf8) << 7) | + ((color[V_IC_2] & 0xf8) << 2) | + ((color[V_IC_3] & 0xf8) >> 3)); + } + + static void decodePixel(ColorObject* color, uint16_t color555) + { + (*color)[V_IC_2] = (color555 >> 2) & 0xf8; + (*color)[V_IC_3] = (color555 << 3) & 0xf8; + (*color)[V_IC_1] = (color555 >> 7) & 0xf8; + } +}; \ No newline at end of file diff --git a/src/internal/features/NeoGrbFeature.h b/src/internal/features/Neo3Byte777Feature.h similarity index 72% rename from src/internal/features/NeoGrbFeature.h rename to src/internal/features/Neo3Byte777Feature.h index a5d971c..1ce7031 100644 --- a/src/internal/features/NeoGrbFeature.h +++ b/src/internal/features/Neo3Byte777Feature.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -NeoGrbFeature provides feature classes to describe color order and -color depth for NeoPixelBus template class +Neo3Byte777Feature provides feature base class to describe color order for + 3 byte features that only support 7 bits per element Written by Michael C. Miller. @@ -26,18 +26,18 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoGrbFeature : - public NeoByteElements<3, RgbColor, uint8_t>, - public NeoElementsNoSettings +template +class Neo3Byte777Feature : + public NeoByteElements<3, RgbColor, uint8_t> { 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[V_IC_1] >> 1) | 0x80; + *p++ = (color[V_IC_2] >> 1) | 0x80; + *p = (color[V_IC_3] >> 1) | 0x80; } static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) @@ -45,21 +45,22 @@ public: ColorObject color; const uint8_t* p = getPixelAddress(pPixels, indexPixel); - color.G = *p++; - color.R = *p++; - color.B = *p; + color[V_IC_1] = (*p++) << 1; + color[V_IC_2] = (*p++) << 1; + color[V_IC_3] = (*p) << 1; 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[V_IC_1] = (pgm_read_byte(p++)) << 1; + color[V_IC_2] = (pgm_read_byte(p++)) << 1; + color[V_IC_3] = (pgm_read_byte(p)) << 1; return color; } diff --git a/src/internal/features/NeoRbgFeature.h b/src/internal/features/Neo3ByteFeature.h similarity index 76% rename from src/internal/features/NeoRbgFeature.h rename to src/internal/features/Neo3ByteFeature.h index a6e5ba3..d6a228f 100644 --- a/src/internal/features/NeoRbgFeature.h +++ b/src/internal/features/Neo3ByteFeature.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -NeoRbgFeature provides feature classes to describe color order and -color depth for NeoPixelBus template class +Neo3ByteFeature provides feature base class to describe color order for + 3 byte features Written by Michael C. Miller. @@ -26,19 +26,18 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once - -class NeoRbgFeature : - public NeoByteElements<3, RgbColor, uint8_t>, - public NeoElementsNoSettings +template +class Neo3ByteFeature : + public NeoByteElements<3, RgbColor, uint8_t> { 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; + *p++ = color[V_IC_1]; + *p++ = color[V_IC_2]; + *p = color[V_IC_3]; } static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) @@ -46,9 +45,9 @@ public: ColorObject color; const uint8_t* p = getPixelAddress(pPixels, indexPixel); - color.R = *p++; - color.B = *p++; - color.G = *p; + color[V_IC_1] = *p++; + color[V_IC_2] = *p++; + color[V_IC_3] = *p; return color; } @@ -59,9 +58,9 @@ public: 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); + color[V_IC_1] = pgm_read_byte(p++); + color[V_IC_2] = pgm_read_byte(p++); + color[V_IC_3] = pgm_read_byte(p); return color; } diff --git a/src/internal/features/NeoGrb48Feature.h b/src/internal/features/Neo3WordFeature.h similarity index 70% rename from src/internal/features/NeoGrb48Feature.h rename to src/internal/features/Neo3WordFeature.h index 2b39f10..4d74092 100644 --- a/src/internal/features/NeoGrb48Feature.h +++ b/src/internal/features/Neo3WordFeature.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -NeoGrb48Feature provides feature classes to describe color order and -color depth for NeoPixelBus template class +Neo3WordFeature provides feature base class to describe color order for + 3 Word features Written by Michael C. Miller. @@ -26,9 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoGrb48Feature : - public NeoWordElements<6, Rgb48Color, uint16_t>, - public NeoElementsNoSettings +template +class Neo3WordFeature : + public NeoWordElements<6, Rgb48Color, uint16_t> { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -36,12 +36,12 @@ public: uint8_t* p = getPixelAddress(pPixels, indexPixel); // due to endianness the byte order must be copied to output - *p++ = color.G >> 8; - *p++ = color.G & 0xff; - *p++ = color.R >> 8; - *p++ = color.R & 0xff; - *p++ = color.B >> 8; - *p = color.B & 0xff; + *p++ = color[V_IC_1] >> 8; + *p++ = color[V_IC_1] & 0xff; + *p++ = color[V_IC_2] >> 8; + *p++ = color[V_IC_2] & 0xff; + *p++ = color[V_IC_3] >> 8; + *p = color[V_IC_3] & 0xff; } static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) @@ -50,12 +50,12 @@ public: const uint8_t* p = getPixelAddress(pPixels, indexPixel); // due to endianness the byte order must be copied to output - color.G = (static_cast(*p++) << 8); - color.G |= *p++; - color.R = (static_cast(*p++) << 8); - color.R |= *p++; - color.B = (static_cast(*p++) << 8); - color.B |= *p; + color[V_IC_1] = (static_cast(*p++) << 8); + color[V_IC_1] |= *p++; + color[V_IC_2] = (static_cast(*p++) << 8); + color[V_IC_2] |= *p++; + color[V_IC_3] = (static_cast(*p++) << 8); + color[V_IC_3] |= *p; return color; } @@ -67,10 +67,11 @@ public: // PROGMEM unit of storage expected to be the same size as color element // so no endianness issues to worry about - color.G = pgm_read_word(p++); - color.R = pgm_read_word(p++); - color.B = pgm_read_word(p); + color[V_IC_1] = pgm_read_word(p++); + color[V_IC_2] = pgm_read_word(p++); + color[V_IC_3] = pgm_read_word(p); return color; } -}; + + }; \ No newline at end of file diff --git a/src/internal/features/NeoBrgFeature.h b/src/internal/features/Neo4ByteFeature.h similarity index 71% rename from src/internal/features/NeoBrgFeature.h rename to src/internal/features/Neo4ByteFeature.h index 09f2db1..eea734c 100644 --- a/src/internal/features/NeoBrgFeature.h +++ b/src/internal/features/Neo4ByteFeature.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -NeoBrgFeature provides feature classes to describe color order and -color depth for NeoPixelBus template class +Neo4ByteFeature provides feature base class to describe color order for + 6 byte features that only use the first 5 bytes Written by Michael C. Miller. @@ -26,18 +26,19 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoBrgFeature : - public NeoByteElements<3, RgbColor, uint8_t>, - public NeoElementsNoSettings +template +class Neo4ByteFeature : + public NeoByteElements<4, RgbwColor, uint32_t> { 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; + *p++ = color[V_IC_1]; + *p++ = color[V_IC_2]; + *p++ = color[V_IC_3]; + *p = color[V_IC_4]; } static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) @@ -45,9 +46,10 @@ public: ColorObject color; const uint8_t* p = getPixelAddress(pPixels, indexPixel); - color.B = *p++; - color.R = *p++; - color.G = *p; + color[V_IC_1] = *p++; + color[V_IC_2] = *p++; + color[V_IC_3] = *p++; + color[V_IC_4] = *p; return color; } @@ -57,10 +59,11 @@ public: 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); + 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); return color; } -}; +}; \ No newline at end of file diff --git a/src/internal/features/NeoRgbw64Feature.h b/src/internal/features/Neo4WordFeature.h similarity index 65% rename from src/internal/features/NeoRgbw64Feature.h rename to src/internal/features/Neo4WordFeature.h index 305917c..fe3d3ad 100644 --- a/src/internal/features/NeoRgbw64Feature.h +++ b/src/internal/features/Neo4WordFeature.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -NeoRgbw64Feature provides feature classes to describe color order and -color depth for NeoPixelBus template class +Neo4WordFeature provides feature base class to describe color order for + 4 Word features Written by Michael C. Miller. @@ -26,10 +26,9 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once - -class NeoRgbw64Feature : - public NeoWordElements<8, Rgbw64Color, uint32_t>, - public NeoElementsNoSettings +template +class Neo4WordFeature : + public NeoWordElements<8, Rgbw64Color, uint32_t> { public: static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) @@ -37,14 +36,14 @@ public: uint8_t* p = getPixelAddress(pPixels, indexPixel); // due to endianness the byte order must be copied to output - *p++ = color.R >> 8; - *p++ = color.R & 0xff; - *p++ = color.G >> 8; - *p++ = color.G & 0xff; - *p++ = color.B >> 8; - *p++ = color.B & 0xff; - *p++ = color.W >> 8; - *p = color.W & 0xff; + *p++ = color[V_IC_1] >> 8; + *p++ = color[V_IC_1] & 0xff; + *p++ = color[V_IC_2] >> 8; + *p++ = color[V_IC_2] & 0xff; + *p++ = color[V_IC_3] >> 8; + *p++ = color[V_IC_3] & 0xff; + *p++ = color[V_IC_4] >> 8; + *p = color[V_IC_4] & 0xff; } static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) @@ -53,14 +52,14 @@ public: const uint8_t* p = getPixelAddress(pPixels, indexPixel); // due to endianness the byte order must be copied to output - color.R = (static_cast(*p++) << 8); - color.R |= *p++; - color.G = (static_cast(*p++) << 8); - color.G |= *p++; - color.B = (static_cast(*p++) << 8); - color.B |= *p++; - color.W = (static_cast(*p++) << 8); - color.W |= *p; + color[V_IC_1] = (static_cast(*p++) << 8); + color[V_IC_1] |= *p++; + color[V_IC_2] = (static_cast(*p++) << 8); + color[V_IC_2] |= *p++; + color[V_IC_3] = (static_cast(*p++) << 8); + color[V_IC_3] |= *p++; + color[V_IC_4] = (static_cast(*p++) << 8); + color[V_IC_4] |= *p; return color; } @@ -72,11 +71,12 @@ public: // PROGMEM unit of storage expected to be the same size as color element // so no endianness issues to worry about - color.R = pgm_read_word(p++); - color.G = pgm_read_word(p++); - color.B = pgm_read_word(p++); - color.W = pgm_read_word(p); + color[V_IC_1] = pgm_read_word(p++); + color[V_IC_2] = pgm_read_word(p++); + color[V_IC_3] = pgm_read_word(p++); + color[V_IC_4] = pgm_read_word(p); return color; } -}; + + }; \ No newline at end of file diff --git a/src/internal/features/NeoGrbcwxFeature.h b/src/internal/features/Neo6xByteFeature.h similarity index 66% rename from src/internal/features/NeoGrbcwxFeature.h rename to src/internal/features/Neo6xByteFeature.h index 09cf910..9b732c6 100644 --- a/src/internal/features/NeoGrbcwxFeature.h +++ b/src/internal/features/Neo6xByteFeature.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -NeoGrbcwxFeature provides feature classes to describe color order and -color depth for NeoPixelBus template class +Neo6xByteFeature provides feature base class to describe color order for + 6 byte features that only use the first 5 bytes Written by Michael C. Miller. @@ -26,20 +26,21 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoGrbcwxFeature : - public NeoByteElements<6, RgbwwColor, uint16_t>, - public NeoElementsNoSettings +template +class Neo6xByteFeature : + public NeoByteElements<6, RgbwwColor, uint16_t> { 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.CW; - *p++ = color.WW; + *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]; + *p = 0x00; // X } @@ -48,11 +49,12 @@ public: ColorObject color; const uint8_t* p = getPixelAddress(pPixels, indexPixel); - color.G = *p++; - color.R = *p++; - color.B = *p++; - color.CW = *p++; - color.WW = *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] = *p; + // ignore the x return color; } @@ -62,12 +64,13 @@ public: 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.CW = pgm_read_byte(p++); - color.WW = pgm_read_byte(p); + 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); + // ignore the x return color; } -}; +}; \ No newline at end of file diff --git a/src/internal/features/NeoRgbwxxFeature.h b/src/internal/features/Neo6xxByteFeature.h similarity index 71% rename from src/internal/features/NeoRgbwxxFeature.h rename to src/internal/features/Neo6xxByteFeature.h index 07813b9..6b5bdec 100644 --- a/src/internal/features/NeoRgbwxxFeature.h +++ b/src/internal/features/Neo6xxByteFeature.h @@ -1,6 +1,6 @@ /*------------------------------------------------------------------------- -NeoRgbwxxFeature provides feature classes to describe color order and -color depth for NeoPixelBus template class +Neo6xxByteFeature provides feature base class to describe color order for + 6 byte features that only use the first 4 bytes Written by Michael C. Miller. @@ -26,22 +26,22 @@ License along with NeoPixel. If not, see -------------------------------------------------------------------------*/ #pragma once -class NeoRgbwxxFeature : - public NeoByteElements<6, RgbwColor, uint16_t>, - public NeoElementsNoSettings +template +class Neo6xxByteFeature : + public NeoByteElements<6, RgbwColor, uint16_t> { 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; + *p++ = color[V_IC_1]; + *p++ = color[V_IC_2]; + *p++ = color[V_IC_3]; + *p++ = color[V_IC_4]; // zero the xx, this maybe unnecessary though, but its thorough - *p++ = 0; - *p = 0; + *p++ = 0x00; + *p = 0x00; // X } static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) @@ -49,10 +49,10 @@ public: ColorObject color; const uint8_t* p = getPixelAddress(pPixels, indexPixel); - color.R = *p++; - color.G = *p++; - color.B = *p++; - color.W = *p; + color[V_IC_1] = *p++; + color[V_IC_2] = *p++; + color[V_IC_3] = *p++; + color[V_IC_4] = *p; // ignore the xx return color; @@ -63,12 +63,11 @@ public: 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); + 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); // ignore the xx - return color; } -}; +}; \ No newline at end of file diff --git a/src/internal/features/NeoByteElements.h b/src/internal/features/NeoByteElements.h index 23f3405..3075bdc 100644 --- a/src/internal/features/NeoByteElements.h +++ b/src/internal/features/NeoByteElements.h @@ -104,7 +104,7 @@ public: static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count) { uint8_t* pEnd = pPixelDest + (count * NeoElementsBase::PixelSize); - const uint8_t* pSrc = (const uint8_t*)pPixelSrc; + const uint8_t* pSrc = reinterpret_cast(pPixelSrc); while (pPixelDest < pEnd) { diff --git a/src/internal/features/NeoGrbwFeature.h b/src/internal/features/NeoGrbwFeature.h deleted file mode 100644 index 342f28c..0000000 --- a/src/internal/features/NeoGrbwFeature.h +++ /dev/null @@ -1,70 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoByteElements<4, RgbwColor, uint32_t>, - public NeoElementsNoSettings -{ -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/NeoRgb48Feature.h b/src/internal/features/NeoRgb48Feature.h deleted file mode 100644 index 369f428..0000000 --- a/src/internal/features/NeoRgb48Feature.h +++ /dev/null @@ -1,76 +0,0 @@ -/*------------------------------------------------------------------------- -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 NeoWordElements<6, Rgb48Color, uint16_t>, - public NeoElementsNoSettings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - // due to endianness the byte order must be copied to output - *p++ = color.R >> 8; - *p++ = color.R & 0xff; - *p++ = color.G >> 8; - *p++ = color.G & 0xff; - *p++ = color.B >> 8; - *p = color.B & 0xff; - } - - static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint8_t* p = getPixelAddress(pPixels, indexPixel); - - // due to endianness the byte order must be copied to output - color.R = (static_cast(*p++) << 8); - color.R |= *p++; - color.G = (static_cast(*p++) << 8); - color.G |= *p++; - color.B = (static_cast(*p++) << 8); - color.B |= *p; - - return color; - } - - static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel) - { - ColorObject color; - const uint16_t* p = reinterpret_cast(getPixelAddress(reinterpret_cast(pPixels), indexPixel)); - - // PROGMEM unit of storage expected to be the same size as color element - // so no endianness issues to worry about - 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/NeoRgb48Features.h b/src/internal/features/NeoRgb48Features.h new file mode 100644 index 0000000..c9a2165 --- /dev/null +++ b/src/internal/features/NeoRgb48Features.h @@ -0,0 +1,63 @@ +/*------------------------------------------------------------------------- +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 Neo3WordFeature, + public NeoElementsNoSettings +{ +}; + +class NeoRbg48Feature : + public Neo3WordFeature, + public NeoElementsNoSettings +{ +}; + +class NeoGrb48Feature : + public Neo3WordFeature, + public NeoElementsNoSettings +{ +}; + +class NeoGbr48Feature : + public Neo3WordFeature, + public NeoElementsNoSettings +{ +}; + +class NeoBgr48Feature : + public Neo3WordFeature, + public NeoElementsNoSettings +{ +}; + +class NeoBrg48Feature : + public Neo3WordFeature, + public NeoElementsNoSettings +{ +}; diff --git a/src/internal/features/NeoRgbFeature.h b/src/internal/features/NeoRgbFeatures.h similarity index 57% rename from src/internal/features/NeoRgbFeature.h rename to src/internal/features/NeoRgbFeatures.h index b47f476..ec4cb06 100644 --- a/src/internal/features/NeoRgbFeature.h +++ b/src/internal/features/NeoRgbFeatures.h @@ -27,40 +27,38 @@ License along with NeoPixel. If not, see #pragma once class NeoRgbFeature : - public NeoByteElements<3, RgbColor, uint8_t>, + public Neo3ByteFeature, public NeoElementsNoSettings { -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 NeoRbgFeature : + public Neo3ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoGbrFeature : + public Neo3ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoGrbFeature : + public Neo3ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoBgrFeature : + public Neo3ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoBrgFeature : + public Neo3ByteFeature, + public NeoElementsNoSettings +{ +}; + diff --git a/src/internal/features/NeoRgbcwxFeatures.h b/src/internal/features/NeoRgbcwxFeatures.h new file mode 100644 index 0000000..42f475c --- /dev/null +++ b/src/internal/features/NeoRgbcwxFeatures.h @@ -0,0 +1,33 @@ +/*------------------------------------------------------------------------- +NeoRgbcwxFeature 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 NeoGrbcwxFeature : + public Neo6xByteFeature, + public NeoElementsNoSettings +{ +}; diff --git a/src/internal/features/NeoBgrFeature.h b/src/internal/features/NeoRgbw64Features.h similarity index 53% rename from src/internal/features/NeoBgrFeature.h rename to src/internal/features/NeoRgbw64Features.h index 3d03efc..b04e76f 100644 --- a/src/internal/features/NeoBgrFeature.h +++ b/src/internal/features/NeoRgbw64Features.h @@ -1,5 +1,5 @@ /*------------------------------------------------------------------------- -NeoBgrFeature provides feature classes to describe color order and +NeoRgbw64Feature provides feature classes to describe color order and color depth for NeoPixelBus template class Written by Michael C. Miller. @@ -27,42 +27,40 @@ License along with NeoPixel. If not, see #pragma once -class NeoBgrFeature : - public NeoByteElements<3, RgbColor, uint8_t>, +class NeoRgbw64Feature : + public Neo4WordFeature, public NeoElementsNoSettings { -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 NeoRbgw64Feature : + public Neo4WordFeature, + public NeoElementsNoSettings +{ +}; + +class NeoGbrw64Feature : + public Neo4WordFeature, + public NeoElementsNoSettings +{ +}; + +class NeoGrbw64Feature : + public Neo4WordFeature, + public NeoElementsNoSettings +{ +}; + +class NeoBgrw64Feature : + public Neo4WordFeature, + public NeoElementsNoSettings +{ +}; + +class NeoBrgw64Feature : + public Neo4WordFeature, + public NeoElementsNoSettings +{ +}; + + diff --git a/src/internal/features/NeoRgbwFeature.h b/src/internal/features/NeoRgbwFeatures.h similarity index 55% rename from src/internal/features/NeoRgbwFeature.h rename to src/internal/features/NeoRgbwFeatures.h index a883ace..9d92a59 100644 --- a/src/internal/features/NeoRgbwFeature.h +++ b/src/internal/features/NeoRgbwFeatures.h @@ -27,43 +27,37 @@ License along with NeoPixel. If not, see #pragma once class NeoRgbwFeature : - public NeoByteElements<4, RgbwColor, uint32_t>, + public Neo4ByteFeature, public NeoElementsNoSettings { -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 NeoRbgwFeature : + public Neo4ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoGbrwFeature : + public Neo4ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoGrbwFeature : + public Neo4ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoBgrwFeature : + public Neo4ByteFeature, + public NeoElementsNoSettings +{ +}; + +class NeoBrgwFeature : + public Neo4ByteFeature, + public NeoElementsNoSettings +{ +}; \ No newline at end of file diff --git a/src/internal/features/NeoRgbwxxFeatures.h b/src/internal/features/NeoRgbwxxFeatures.h new file mode 100644 index 0000000..c27af05 --- /dev/null +++ b/src/internal/features/NeoRgbwxxFeatures.h @@ -0,0 +1,33 @@ +/*------------------------------------------------------------------------- +NeoRgbwxxFeatures 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 NeoRgbwxxFeature : + public Neo6xxByteFeature, + public NeoElementsNoSettings +{ +}; diff --git a/src/internal/features/NeoSm168xxFeatures.h b/src/internal/features/NeoSm168xxFeatures.h index 67d8eac..03663d9 100644 --- a/src/internal/features/NeoSm168xxFeatures.h +++ b/src/internal/features/NeoSm168xxFeatures.h @@ -50,11 +50,29 @@ public: GreenGain(greenGain & 0x0f), BlueGain(blueGain & 0x0f) {} + // ------------------------------------------------------------------------ + // operator [] - readonly + // access elements in order by index rather than member name + // ------------------------------------------------------------------------ + uint8_t operator[](size_t idx) const + { + switch (idx) + { + case 0: + return RedGain; + case 1: + return GreenGain; + default: + return BlueGain; + } + } + const uint8_t RedGain : 4; const uint8_t GreenGain : 4; const uint8_t BlueGain : 4; }; +template class NeoSm16803pbSettings : public NeoSm168x3SettingsBase { public: @@ -71,8 +89,8 @@ public: void Encode(uint8_t* encoded) const { // 0RGB 4 bits each - encoded[0] = RedGain; - encoded[1] = GreenGain << 4 | BlueGain; + *encoded++ = operator[](V_IC_1); + *encoded = operator[](V_IC_2) << 4 | operator[](V_IC_3); } protected: @@ -81,6 +99,7 @@ protected: 110, 133, 145, 156, 168, 179, 190}; }; +template class NeoSm16823eSettings : public NeoSm168x3SettingsBase { public: @@ -98,8 +117,8 @@ public: void Encode(uint8_t* encoded) const { // RGB0 4 bits each - encoded[0] = RedGain << 4 | GreenGain; - encoded[1] = BlueGain << 4; + *encoded++ = operator[](V_IC_1) << 4 | operator[](V_IC_2); + *encoded = operator[](V_IC_3) << 4; } protected: @@ -131,12 +150,32 @@ public: BlueGain(blueGain & 0x0f), WhiteGain(whiteGain & 0x0f) {} + // ------------------------------------------------------------------------ + // operator [] - readonly + // access elements in order by index rather than member name + // ------------------------------------------------------------------------ + uint8_t operator[](size_t idx) const + { + switch (idx) + { + case 0: + return RedGain; + case 1: + return GreenGain; + case 2: + return BlueGain; + default: + return WhiteGain; + } + } + const uint8_t RedGain : 4; const uint8_t GreenGain : 4; const uint8_t BlueGain : 4; const uint8_t WhiteGain : 4; }; +template class NeoSm16804ebSettings : public NeoSm168x4SettingsBase { public: @@ -155,8 +194,8 @@ public: void Encode(uint8_t* encoded) const { // RGBW 4 bits each - encoded[0] = RedGain << 4 | GreenGain; - encoded[1] = BlueGain << 4 | WhiteGain; + *encoded++ = operator[](V_IC_1) << 4 | operator[](V_IC_2); + *encoded = operator[](V_IC_3) << 4 | operator[](V_IC_4); } protected: @@ -165,6 +204,7 @@ protected: 110, 133, 145, 156, 168, 179, 190 }; }; +template class NeoSm16824eSettings : public NeoSm168x4SettingsBase { public: @@ -184,8 +224,8 @@ public: void Encode(uint8_t* encoded) const { // RGBW 4 bits each - encoded[0] = RedGain << 4 | GreenGain; - encoded[1] = BlueGain << 4 | WhiteGain; + *encoded++ = operator[](V_IC_1) << 4 | operator[](V_IC_2); + *encoded = operator[](V_IC_3) << 4 | operator[](V_IC_4); } protected: @@ -199,7 +239,10 @@ protected: }; -template class NeoRgbwSm168x4Elements : public NeoByteElements<4, RgbwColor, uint32_t> +// CAUTION: Make sure ColorIndex order for Neo4ByteFeature matches T_SETTINGS +template +class NeoRgbwSm168x4Elements : + public Neo4ByteFeature { public: typedef T_SETTINGS SettingsObject; @@ -222,45 +265,11 @@ public: { return pData; } - - 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((const uint8_t*)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; - } }; -template class NeoRgbSm168x3Elements : public NeoByteElements<3, RgbColor, uint8_t> +// CAUTION: Make sure ColorIndex order for Neo3ByteFeature matches T_SETTINGS +template class NeoRgbSm168x3Elements : + public Neo3ByteFeature { public: typedef T_SETTINGS SettingsObject; @@ -283,44 +292,11 @@ public: { return pData; } - - 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((const uint8_t*)pPixels, indexPixel); - - color.R = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.B = pgm_read_byte(p); - - return color; - } }; -typedef NeoRgbSm168x3Elements NeoRgbSm16803pbFeature; -typedef NeoRgbSm168x3Elements NeoRgbSm16823eFeature; -typedef NeoRgbwSm168x4Elements NeoRgbwSm16804ebFeature; -typedef NeoRgbwSm168x4Elements NeoRgbwSm16824eFeature; +typedef NeoRgbSm168x3Elements> NeoRgbSm16803pbFeature; +typedef NeoRgbSm168x3Elements> NeoRgbSm16823eFeature; +typedef NeoRgbwSm168x4Elements> NeoRgbwSm16804ebFeature; +typedef NeoRgbwSm168x4Elements> NeoRgbwSm16824eFeature; diff --git a/src/internal/features/NeoTm1814Features.h b/src/internal/features/NeoTm1814Features.h index dc9921e..851466a 100644 --- a/src/internal/features/NeoTm1814Features.h +++ b/src/internal/features/NeoTm1814Features.h @@ -51,7 +51,8 @@ public: } }; -class Neo4ByteElementsTm1814Settings : public NeoByteElements<4, RgbwColor, uint32_t> +template +class NeoElementsTm1814Settings { private: const static uint16_t EncodeDivisor = 5; @@ -66,10 +67,10 @@ public: uint8_t* pSet = pData; // C1 - *pSet++ = (SettingsObject::LimitCurrent(settings.WhiteTenthMilliAmpere) - SettingsObject::MinCurrent) / EncodeDivisor; - *pSet++ = (SettingsObject::LimitCurrent(settings.RedTenthMilliAmpere) - SettingsObject::MinCurrent) / EncodeDivisor; - *pSet++ = (SettingsObject::LimitCurrent(settings.GreenTenthMilliAmpere) - SettingsObject::MinCurrent) / EncodeDivisor; - *pSet++ = (SettingsObject::LimitCurrent(settings.BlueTenthMilliAmpere) - SettingsObject::MinCurrent) / EncodeDivisor; + *pSet++ = (SettingsObject::LimitCurrent(settings[V_IC_1]) - SettingsObject::MinCurrent) / EncodeDivisor; + *pSet++ = (SettingsObject::LimitCurrent(settings[V_IC_2]) - SettingsObject::MinCurrent) / EncodeDivisor; + *pSet++ = (SettingsObject::LimitCurrent(settings[V_IC_3]) - SettingsObject::MinCurrent) / EncodeDivisor; + *pSet++ = (SettingsObject::LimitCurrent(settings[V_IC_4]) - SettingsObject::MinCurrent) / EncodeDivisor; uint8_t* pC1 = pData; @@ -94,44 +95,9 @@ public: }; -class NeoWrgbTm1814Feature : public Neo4ByteElementsTm1814Settings -{ -public: - static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color) - { - uint8_t* p = getPixelAddress(pPixels, indexPixel); - - *p++ = color.W; - *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++; - 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++); - color.R = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.B = pgm_read_byte(p); - - return color; - } - +class NeoWrgbTm1814Feature : + public Neo4ByteFeature, + public NeoElementsTm1814Settings +{ }; diff --git a/src/internal/features/NeoTm1914Features.h b/src/internal/features/NeoTm1914Features.h index 350ca3e..b07a13e 100644 --- a/src/internal/features/NeoTm1914Features.h +++ b/src/internal/features/NeoTm1914Features.h @@ -44,7 +44,7 @@ public: NeoTm1914_Mode Mode; }; -class Neo3ByteElementsTm1914Settings : public NeoByteElements<3, RgbColor, uint8_t> +class Neo3ByteElementsTm1914Settings { public: typedef NeoTm1914Settings SettingsObject; @@ -99,79 +99,15 @@ public: }; -class NeoRgbTm1914Feature : public Neo3ByteElementsTm1914Settings +class NeoRgbTm1914Feature : + public Neo3ByteFeature, + public Neo3ByteElementsTm1914Settings { -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((const uint8_t*)pPixels, indexPixel); - - color.R = pgm_read_byte(p++); - color.G = pgm_read_byte(p++); - color.B = pgm_read_byte(p); - - return color; - } - }; -class NeoGrbTm1914Feature : public Neo3ByteElementsTm1914Settings +class NeoGrbTm1914Feature : + public Neo3ByteFeature, + public Neo3ByteElementsTm1914Settings { -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((const uint8_t*)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/methods/NeoEsp8266UartMethod.h b/src/internal/methods/NeoEsp8266UartMethod.h index 3dd30a1..cdeae07 100644 --- a/src/internal/methods/NeoEsp8266UartMethod.h +++ b/src/internal/methods/NeoEsp8266UartMethod.h @@ -367,7 +367,7 @@ public: : T_BASE(pixelCount, elementSize, settingsSize) { } - NeoEsp8266UartMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) + NeoEsp8266UartMethodBase([[maybe_unused]] uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) : T_BASE(pixelCount, elementSize, settingsSize) { }