mirror of
https://github.com/Makuna/NeoPixelBus.git
synced 2025-08-07 04:44:26 +02:00
Refactor Feature Elements core (#710)
* refactor byte elements * Word elements * refactor no settings core * refactor 2 byte 555 encoding
This commit is contained in:
@@ -26,14 +26,14 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
// Core Element base classes
|
||||
//
|
||||
#include "features/NeoElementsNoSettings.h"
|
||||
#include "features/NeoByteElements.h"
|
||||
#include "features/Neo2Byte555Elements.h"
|
||||
|
||||
// NeoPixel Features
|
||||
//
|
||||
#include "features/Neo2ByteElements.h"
|
||||
#include "features/Neo3ByteElements.h"
|
||||
#include "features/Neo4ByteElements.h"
|
||||
#include "features/Neo6ByteElements.h"
|
||||
#include "features/Neo6Byte4xxElements.h"
|
||||
#include "features/Neo8ByteElements.h"
|
||||
#include "features/NeoBgrFeature.h"
|
||||
#include "features/NeoBrgFeature.h"
|
||||
#include "features/NeoGrb48Feature.h"
|
||||
@@ -55,8 +55,6 @@ typedef NeoGrb48Feature NeoGrbWs2816Feature;
|
||||
|
||||
// DotStart Features
|
||||
//
|
||||
#include "features/DotStar3Elements.h"
|
||||
#include "features/DotStar4Elements.h"
|
||||
#include "features/DotStarBgrFeature.h"
|
||||
#include "features/DotStarBrgFeature.h"
|
||||
#include "features/DotStarGbrFeature.h"
|
||||
@@ -79,7 +77,6 @@ typedef NeoGrb48Feature NeoGrbWs2816Feature;
|
||||
|
||||
// 7 Segment Features
|
||||
//
|
||||
#include "features/Neo9ByteElements.h"
|
||||
#include "features/NeoAbcdefgpsSegmentFeature.h"
|
||||
#include "features/NeoBacedfpgsSegmentFeature.h"
|
||||
|
||||
|
@@ -34,11 +34,15 @@ template<typename T_BUFFER_METHOD> class NeoBuffer
|
||||
public:
|
||||
NeoBuffer(uint16_t width,
|
||||
uint16_t height,
|
||||
PGM_VOID_P pixels) :
|
||||
PGM_VOID_P pixels = nullptr) :
|
||||
_method(width, height, pixels)
|
||||
{
|
||||
}
|
||||
|
||||
~NeoBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
operator NeoBufferContext<typename T_BUFFER_METHOD::ColorFeature>()
|
||||
{
|
||||
return _method;
|
||||
@@ -64,14 +68,14 @@ public:
|
||||
int16_t y,
|
||||
typename T_BUFFER_METHOD::ColorObject color)
|
||||
{
|
||||
_method.SetPixelColor(pixelIndex(x, y), color);
|
||||
_method.SetPixelColor(PixelIndex(x, y), color);
|
||||
};
|
||||
|
||||
typename T_BUFFER_METHOD::ColorObject GetPixelColor(
|
||||
int16_t x,
|
||||
int16_t y) const
|
||||
{
|
||||
return _method.GetPixelColor(pixelIndex(x, y));
|
||||
return _method.GetPixelColor(PixelIndex(x, y));
|
||||
};
|
||||
|
||||
void ClearTo(typename T_BUFFER_METHOD::ColorObject color)
|
||||
@@ -120,7 +124,7 @@ public:
|
||||
|
||||
if (indexDest < destPixelCount)
|
||||
{
|
||||
const uint8_t* pSrc = T_BUFFER_METHOD::ColorFeature::getPixelAddress(_method.Pixels(), pixelIndex(xSrc + x, ySrc + y));
|
||||
const uint8_t* pSrc = T_BUFFER_METHOD::ColorFeature::getPixelAddress(_method.Pixels(), PixelIndex(xSrc + x, ySrc + y));
|
||||
uint8_t* pDest = T_BUFFER_METHOD::ColorFeature::getPixelAddress(destBuffer.Pixels, indexDest);
|
||||
|
||||
_method.CopyPixels(pDest, pSrc, 1);
|
||||
@@ -155,10 +159,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
T_BUFFER_METHOD _method;
|
||||
|
||||
uint16_t pixelIndex(
|
||||
uint16_t PixelIndex(
|
||||
int16_t x,
|
||||
int16_t y) const
|
||||
{
|
||||
@@ -173,4 +174,7 @@ private:
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
T_BUFFER_METHOD _method;
|
||||
};
|
@@ -29,7 +29,7 @@ License along with NeoPixel. If not, see
|
||||
template<typename T_COLOR_FEATURE> class NeoBufferMethod
|
||||
{
|
||||
public:
|
||||
NeoBufferMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels = NULL) :
|
||||
NeoBufferMethod(uint16_t width, uint16_t height, PGM_VOID_P pixels = nullptr) :
|
||||
_width(width),
|
||||
_height(height)
|
||||
{
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
~NeoBufferMethod()
|
||||
{
|
||||
free(_pixels);
|
||||
_pixels = nullptr;
|
||||
}
|
||||
|
||||
operator NeoBufferContext<T_COLOR_FEATURE>()
|
||||
@@ -143,7 +144,7 @@ public:
|
||||
typedef T_COLOR_FEATURE ColorFeature;
|
||||
|
||||
private:
|
||||
const uint16_t _width;
|
||||
const uint16_t _width;
|
||||
const uint16_t _height;
|
||||
uint8_t* _pixels;
|
||||
};
|
||||
|
@@ -1,117 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
DotStar4Elements provides feature base classes to describe color elements
|
||||
for NeoPixelBus Color Feature template classes when used with DotStars
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
|
||||
class DotStar4Elements
|
||||
{
|
||||
public:
|
||||
static const size_t PixelSize = 4;
|
||||
|
||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = pPixelSrc[0];
|
||||
*pPixelDest++ = pPixelSrc[1];
|
||||
*pPixelDest++ = pPixelSrc[2];
|
||||
*pPixelDest++ = pPixelSrc[3];
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = *pPixelSrc++;
|
||||
*pPixelDest++ = *pPixelSrc++;
|
||||
*pPixelDest++ = *pPixelSrc++;
|
||||
*pPixelDest++ = *pPixelSrc++;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
||||
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
||||
while (pDestBack > pPixelDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
*--pDestBack = *--pSrcBack;
|
||||
*--pDestBack = *--pSrcBack;
|
||||
*--pDestBack = *--pSrcBack;
|
||||
}
|
||||
}
|
||||
|
||||
typedef RgbwColor ColorObject;
|
||||
};
|
||||
|
||||
|
||||
class DotStar4ElementsNoSettings : public DotStar4Elements
|
||||
{
|
||||
public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
static const size_t SettingsSize = 0;
|
||||
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
};
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class DotStarBgrFeature : public DotStar3ElementsNoSettings
|
||||
class DotStarBgrFeature :
|
||||
public NeoByteElements<4, RgbColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class DotStarBrgFeature : public DotStar3ElementsNoSettings
|
||||
class DotStarBrgFeature :
|
||||
public NeoByteElements<4, RgbColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class DotStarGbrFeature : public DotStar3ElementsNoSettings
|
||||
class DotStarGbrFeature :
|
||||
public NeoByteElements<4, RgbColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class DotStarGrbFeature : public DotStar3ElementsNoSettings
|
||||
class DotStarGrbFeature :
|
||||
public NeoByteElements<4, RgbColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class DotStarLbgrFeature : public DotStar4ElementsNoSettings
|
||||
class DotStarLbgrFeature :
|
||||
public NeoByteElements<4, RgbwColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class DotStarLbrgFeature : public DotStar4ElementsNoSettings
|
||||
class DotStarLbrgFeature :
|
||||
public NeoByteElements<4, RgbwColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class DotStarLgbrFeature : public DotStar4ElementsNoSettings
|
||||
class DotStarLgbrFeature :
|
||||
public NeoByteElements<4, RgbwColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class DotStarLgrbFeature : public DotStar4ElementsNoSettings
|
||||
class DotStarLgrbFeature :
|
||||
public NeoByteElements<4, RgbwColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class DotStarLrbgFeature : public DotStar4ElementsNoSettings
|
||||
class DotStarLrbgFeature :
|
||||
public NeoByteElements<4, RgbwColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class DotStarLrgbFeature : public DotStar4ElementsNoSettings
|
||||
class DotStarLrgbFeature :
|
||||
public NeoByteElements<4, RgbwColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class DotStarRbgFeature : public DotStar3ElementsNoSettings
|
||||
class DotStarRbgFeature :
|
||||
public NeoByteElements<4, RgbColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class DotStarRgbFeature : public DotStar3ElementsNoSettings
|
||||
class DotStarRgbFeature :
|
||||
public NeoByteElements<4, RgbColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,10 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class Lpd6803BrgFeature : public Neo2ByteElementsNoSettings
|
||||
class Lpd6803BrgFeature :
|
||||
public NeoByteElements<2, RgbColor, uint16_t>,
|
||||
public NeoElementsNoSettings,
|
||||
public Neo2Byte555Elements
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,10 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class Lpd6803GbrFeature : public Neo2ByteElementsNoSettings
|
||||
class Lpd6803GbrFeature :
|
||||
public NeoByteElements<2, RgbColor, uint16_t>,
|
||||
public NeoElementsNoSettings,
|
||||
public Neo2Byte555Elements
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,10 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class Lpd6803GrbFeature : public Neo2ByteElementsNoSettings
|
||||
class Lpd6803GrbFeature :
|
||||
public NeoByteElements<2, RgbColor, uint16_t>,
|
||||
public NeoElementsNoSettings,
|
||||
public Neo2Byte555Elements
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,10 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class Lpd6803RgbFeature : public Neo2ByteElementsNoSettings
|
||||
class Lpd6803RgbFeature :
|
||||
public NeoByteElements<2, RgbColor, uint16_t>,
|
||||
public NeoElementsNoSettings,
|
||||
public Neo2Byte555Elements
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class Lpd8806BrgFeature : public Neo3ByteElementsNoSettings
|
||||
class Lpd8806BrgFeature :
|
||||
public NeoByteElements<3, RgbColor, uint8_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class Lpd8806GrbFeature : public Neo3ByteElementsNoSettings
|
||||
class Lpd8806GrbFeature :
|
||||
public NeoByteElements<3, RgbColor, uint8_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
46
src/internal/features/Neo2Byte555Elements.h
Normal file
46
src/internal/features/Neo2Byte555Elements.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
Neo2Byte555Elements provides feature base classes to describe color elements
|
||||
with 555 encoding for NeoPixelBus Color Feature template classes
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#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;
|
||||
}
|
||||
};
|
@@ -1,122 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
Neo2ByteElements provides feature base classes to describe color elements
|
||||
for NeoPixelBus Color Feature template classes
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class Neo2ByteElements
|
||||
{
|
||||
public:
|
||||
static const size_t PixelSize = 2; // 1 bit + 555 encoded elements
|
||||
|
||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
for (uint8_t iElement = 0; iElement < PixelSize; iElement++)
|
||||
{
|
||||
*pPixelDest++ = pPixelSrc[iElement];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = *pPixelSrc++;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
||||
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
||||
while (pDestBack > pPixelDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
}
|
||||
}
|
||||
|
||||
typedef RgbColor ColorObject;
|
||||
|
||||
protected:
|
||||
static void encodePixel(uint8_t c1, uint8_t c2, uint8_t c3, uint16_t* color555)
|
||||
{
|
||||
*color555 = (0x8000 |
|
||||
((c1 & 0xf8) << 7) |
|
||||
((c2 & 0xf8) << 2) |
|
||||
((c3 & 0xf8) >> 3));
|
||||
}
|
||||
|
||||
static void decodePixel(uint16_t color555, uint8_t* c1, uint8_t* c2, uint8_t* c3)
|
||||
{
|
||||
*c1 = (color555 >> 7) & 0xf8;
|
||||
*c2 = (color555 >> 2) & 0xf8;
|
||||
*c3 = (color555 << 3) & 0xf8;
|
||||
}
|
||||
};
|
||||
|
||||
class Neo2ByteElementsNoSettings : public Neo2ByteElements
|
||||
{
|
||||
public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
static const size_t SettingsSize = 0;
|
||||
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
};
|
@@ -1,110 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
Neo3ByteElements provides feature base classes to describe color elements
|
||||
for NeoPixelBus Color Feature template classes
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class Neo3ByteElements
|
||||
{
|
||||
public:
|
||||
static const size_t PixelSize = 3;
|
||||
|
||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
const uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
for (uint8_t iElement = 0; iElement < PixelSize; iElement++)
|
||||
{
|
||||
*pPixelDest++ = pPixelSrc[iElement];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
const uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = *pPixelSrc++;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
const uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
const uint8_t* pSrc = reinterpret_cast<const uint8_t*>(pPixelSrc);
|
||||
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
||||
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
||||
|
||||
while (pDestBack > pPixelDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
}
|
||||
}
|
||||
|
||||
typedef RgbColor ColorObject;
|
||||
};
|
||||
|
||||
class Neo3ByteElementsNoSettings : public Neo3ByteElements
|
||||
{
|
||||
public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
static const size_t SettingsSize = 0;
|
||||
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
};
|
@@ -1,125 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
Neo4ByteElements provides feature base classes to describe color elements
|
||||
for NeoPixelBus Color Feature template classes
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class Neo4ByteElementsBase
|
||||
{
|
||||
public:
|
||||
static const size_t PixelSize = 4;
|
||||
|
||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = reinterpret_cast<uint32_t*>(pPixelDest);
|
||||
const uint32_t* pSrc = reinterpret_cast<const uint32_t*>(pPixelSrc);
|
||||
const uint32_t* pEnd = pDest + count; // * PixelSize / sizeof(*pDest);
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = *pSrc;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = reinterpret_cast<uint32_t*>(pPixelDest);
|
||||
const uint32_t* pSrc = reinterpret_cast<const uint32_t*>(pPixelSrc);
|
||||
const uint32_t* pEnd = pDest + count; // * PixelSize / sizeof(*pDest);
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = reinterpret_cast<uint32_t*>(pPixelDest);
|
||||
const uint32_t* pSrc = reinterpret_cast<const uint32_t*>(pPixelSrc);
|
||||
const uint32_t* pEnd = pDest + count; // * PixelSize / sizeof(*pDest);
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = pgm_read_dword(pSrc++);
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = reinterpret_cast<uint32_t*>(pPixelDest);
|
||||
const uint32_t* pSrc = reinterpret_cast<const uint32_t*>(pPixelSrc);
|
||||
uint32_t* pDestBack = pDest + count; // * PixelSize / sizeof(*pDest);
|
||||
const uint32_t* pSrcBack = pSrc + count; // * PixelSize / sizeof(*pSrc);
|
||||
|
||||
while (pDestBack > pDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class Neo4ByteElements : public Neo4ByteElementsBase
|
||||
{
|
||||
public:
|
||||
typedef RgbwColor ColorObject;
|
||||
};
|
||||
|
||||
class Neo4ByteRgbElements : public Neo4ByteElementsBase
|
||||
{
|
||||
public:
|
||||
typedef RgbColor ColorObject;
|
||||
};
|
||||
|
||||
class Neo4ByteElementsNoSettings : public Neo4ByteElements
|
||||
{
|
||||
public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
static const size_t SettingsSize = 0;
|
||||
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
};
|
@@ -1,116 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
Neo6Byte4xxElements provides feature base classes to describe color elements
|
||||
for NeoPixelBus Color Feature template classes. While it takes 6 bytes, it
|
||||
only uses four and ignores the last two
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
|
||||
class Neo6Byte4xxElements
|
||||
{
|
||||
public:
|
||||
static const size_t PixelSize = 6;
|
||||
|
||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint16_t* pDest = reinterpret_cast<uint16_t*>(pPixelDest);
|
||||
const uint16_t* pSrc = reinterpret_cast<const uint16_t*>(pPixelSrc);
|
||||
const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = *pSrc;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint16_t* pDest = reinterpret_cast<uint16_t*>(pPixelDest);
|
||||
const uint16_t* pSrc = reinterpret_cast<const uint16_t*>(pPixelSrc);
|
||||
const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint16_t* pDest = reinterpret_cast<uint16_t*>(pPixelDest);
|
||||
const uint16_t* pSrc = reinterpret_cast<const uint16_t*>(pPixelSrc);
|
||||
const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = pgm_read_word(pSrc++);
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint16_t* pDest = reinterpret_cast<uint16_t*>(pPixelDest);
|
||||
const uint16_t* pSrc = reinterpret_cast<const uint16_t*>(pPixelSrc);
|
||||
uint16_t* pDestBack = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
const uint16_t* pSrcBack = pSrc + (count * PixelSize / sizeof(*pSrc));
|
||||
|
||||
while (pDestBack > pDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
}
|
||||
}
|
||||
|
||||
typedef RgbwColor ColorObject;
|
||||
};
|
||||
|
||||
class Neo6Byte4xxElementsNoSettings : public Neo6Byte4xxElements
|
||||
{
|
||||
public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
static const size_t SettingsSize = 0;
|
||||
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
};
|
@@ -1,115 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
Neo6ByteElements provides feature base classes to describe color elements
|
||||
for NeoPixelBus Color Feature template classes
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
|
||||
class Neo6ByteElements
|
||||
{
|
||||
public:
|
||||
static const size_t PixelSize = 6;
|
||||
|
||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint16_t* pDest = reinterpret_cast<uint16_t*>(pPixelDest);
|
||||
const uint16_t* pSrc = reinterpret_cast<const uint16_t*>(pPixelSrc);
|
||||
const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = *pSrc;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint16_t* pDest = reinterpret_cast<uint16_t*>(pPixelDest);
|
||||
const uint16_t* pSrc = reinterpret_cast<const uint16_t*>(pPixelSrc);
|
||||
const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint16_t* pDest = reinterpret_cast<uint16_t*>(pPixelDest);
|
||||
const uint16_t* pSrc = reinterpret_cast<const uint16_t*>(pPixelSrc);
|
||||
const uint16_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = pgm_read_word(pSrc++);
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint16_t* pDest = reinterpret_cast<uint16_t*>(pPixelDest);
|
||||
const uint16_t* pSrc = reinterpret_cast<const uint16_t*>(pPixelSrc);
|
||||
uint16_t* pDestBack = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
const uint16_t* pSrcBack = pSrc + (count * PixelSize / sizeof(*pSrc));
|
||||
|
||||
while (pDestBack > pDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
}
|
||||
}
|
||||
|
||||
typedef Rgb48Color ColorObject;
|
||||
};
|
||||
|
||||
class Neo6ByteElementsNoSettings : public Neo6ByteElements
|
||||
{
|
||||
public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
static const size_t SettingsSize = 0;
|
||||
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
};
|
@@ -1,115 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
Neo8ByteElements provides feature base classes to describe color elements
|
||||
for NeoPixelBus Color Feature template classes
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
|
||||
class Neo8ByteElements
|
||||
{
|
||||
public:
|
||||
static const size_t PixelSize = 8;
|
||||
|
||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = reinterpret_cast<uint32_t*>(pPixelDest);
|
||||
const uint32_t* pSrc = reinterpret_cast<const uint32_t*>(pPixelSrc);
|
||||
const uint32_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = *pSrc;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = reinterpret_cast<uint32_t*>(pPixelDest);
|
||||
const uint32_t* pSrc = reinterpret_cast<const uint32_t*>(pPixelSrc);
|
||||
const uint32_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = reinterpret_cast<uint32_t*>(pPixelDest);
|
||||
const uint32_t* pSrc = reinterpret_cast<const uint32_t*>(pPixelSrc);
|
||||
const uint32_t* pEnd = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = pgm_read_dword(pSrc++);
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint32_t* pDest = reinterpret_cast<uint32_t*>(pPixelDest);
|
||||
const uint32_t* pSrc = reinterpret_cast<const uint32_t*>(pPixelSrc);
|
||||
uint32_t* pDestBack = pDest + (count * PixelSize / sizeof(*pDest));
|
||||
const uint32_t* pSrcBack = pSrc + (count * PixelSize / sizeof(*pSrc));
|
||||
|
||||
while (pDestBack > pDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
}
|
||||
}
|
||||
|
||||
typedef Rgbw64Color ColorObject;
|
||||
};
|
||||
|
||||
class Neo8ByteElementsNoSettings : public Neo8ByteElements
|
||||
{
|
||||
public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
static const size_t SettingsSize = 0;
|
||||
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
};
|
@@ -1,106 +0,0 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
Neo9ByteElements provides feature base classes to describe color elements
|
||||
for NeoPixelBus Color Feature template classes
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class Neo9ByteElements
|
||||
{
|
||||
public:
|
||||
static const size_t PixelSize = 9; // three 3 element
|
||||
|
||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
for (uint8_t iElement = 0; iElement < PixelSize; iElement++)
|
||||
{
|
||||
*pPixelDest++ = pPixelSrc[iElement];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = *pPixelSrc++;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
||||
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
||||
while (pDestBack > pPixelDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
}
|
||||
}
|
||||
|
||||
typedef SevenSegDigit ColorObject;
|
||||
};
|
||||
|
||||
class Neo9ByteElementsNoSettings : public Neo9ByteElements
|
||||
{
|
||||
public:
|
||||
typedef NeoNoSettings SettingsObject;
|
||||
static const size_t SettingsSize = 0;
|
||||
|
||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||
{
|
||||
}
|
||||
|
||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
|
||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||
{
|
||||
return pData;
|
||||
}
|
||||
};
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
// Abcdefgps byte order
|
||||
class NeoAbcdefgpsSegmentFeature : public Neo9ByteElementsNoSettings
|
||||
class NeoAbcdefgpsSegmentFeature :
|
||||
public NeoByteElements<9, SevenSegDigit, uint8_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
// BACEDF.G+ byte order
|
||||
class NeoBacedfpgsSegmentFeature : public Neo9ByteElementsNoSettings
|
||||
class NeoBacedfpgsSegmentFeature :
|
||||
public NeoByteElements<9, SevenSegDigit, uint8_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class NeoBgrFeature : public Neo3ByteElementsNoSettings
|
||||
class NeoBgrFeature :
|
||||
public NeoByteElements<3, RgbColor, uint8_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class NeoBrgFeature : public Neo3ByteElementsNoSettings
|
||||
class NeoBrgFeature :
|
||||
public NeoByteElements<3, RgbColor, uint8_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
139
src/internal/features/NeoByteElements.h
Normal file
139
src/internal/features/NeoByteElements.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
NeoByteElements provides feature base classes to describe color elements
|
||||
for NeoPixelBus Color Feature template classes
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
I invest time and resources providing this open source code,
|
||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||
|
||||
-------------------------------------------------------------------------
|
||||
This file is part of the Makuna/NeoPixelBus library.
|
||||
|
||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
NeoPixelBus is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// NeoElementsBase contains common methods used by features to map and
|
||||
// copy pixel memory data in native stream format
|
||||
//
|
||||
// V_PIXEL_SIZE - the size in bytes of a pixel in the data stream
|
||||
// T_COLOR_OBJECT - the primary color object used to represent a pixel
|
||||
// T_COPY - (uint8_t/uint16_t/uint32_t) the base type to use when copying/moving
|
||||
template<size_t V_PIXEL_SIZE, typename T_COLOR_OBJECT, typename T_COPY>
|
||||
class NeoElementsBase
|
||||
{
|
||||
public:
|
||||
static const size_t PixelSize = V_PIXEL_SIZE;
|
||||
typedef T_COLOR_OBJECT ColorObject;
|
||||
|
||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
return pPixels + indexPixel * PixelSize;
|
||||
}
|
||||
|
||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
T_COPY* pDest = reinterpret_cast<T_COPY*>(pPixelDest);
|
||||
T_COPY* pEnd = pDest + (count * PixelSize / sizeof(T_COPY));
|
||||
const T_COPY* pEndSrc = reinterpret_cast<const T_COPY*>(pPixelSrc) + PixelSize / sizeof(T_COPY);
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
const T_COPY* pSrc = reinterpret_cast<const T_COPY*>(pPixelSrc);
|
||||
while (pSrc < pEndSrc)
|
||||
{
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
const T_COPY* pSrc = reinterpret_cast<const T_COPY*>(pPixelSrc);
|
||||
T_COPY* pDest = reinterpret_cast<T_COPY*>(pPixelDest);
|
||||
T_COPY* pEnd = pDest + (count * PixelSize / sizeof(T_COPY));
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
}
|
||||
|
||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||
{
|
||||
const T_COPY* pSrc = reinterpret_cast<const T_COPY*>(pPixelSrc);
|
||||
const T_COPY* pSrcBack = pSrc + (count * PixelSize / sizeof(T_COPY));
|
||||
T_COPY* pDest = reinterpret_cast<T_COPY*>(pPixelDest);
|
||||
T_COPY* pDestBack = pDest + (count * PixelSize / sizeof(T_COPY));
|
||||
|
||||
while (pDestBack > pDest)
|
||||
{
|
||||
*--pDestBack = *--pSrcBack;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// NeoByteElements is used for 8bit color element types and less
|
||||
//
|
||||
// V_PIXEL_SIZE - the size in bytes of a pixel in the data stream
|
||||
// T_COLOR_OBJECT - the primary color object used to represent a pixel
|
||||
// T_COPY - (uint8_t/uint16_t/uint32_t) the base type to use when copying/moving
|
||||
template<size_t V_PIXEL_SIZE, typename T_COLOR_OBJECT, typename T_COPY>
|
||||
class NeoByteElements : public NeoElementsBase<V_PIXEL_SIZE, T_COLOR_OBJECT, T_COPY>
|
||||
{
|
||||
public:
|
||||
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint8_t* pEnd = pPixelDest + (count * NeoElementsBase<V_PIXEL_SIZE, T_COLOR_OBJECT, T_COPY>::PixelSize);
|
||||
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
||||
|
||||
while (pPixelDest < pEnd)
|
||||
{
|
||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// NeoWordElements is used for 16bit color element types
|
||||
//
|
||||
// V_PIXEL_SIZE - the size in bytes of a pixel in the data stream
|
||||
// T_COLOR_OBJECT - the primary color object used to represent a pixel
|
||||
// T_COPY - (uint16_t/uint32_t) the base type to use when copying/moving
|
||||
template<size_t V_PIXEL_SIZE, typename T_COLOR_OBJECT, typename T_COPY>
|
||||
class NeoWordElements : public NeoElementsBase<V_PIXEL_SIZE, T_COLOR_OBJECT, T_COPY>
|
||||
{
|
||||
public:
|
||||
|
||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||
{
|
||||
uint16_t* pDest = reinterpret_cast<uint16_t*>(pPixelDest);
|
||||
uint16_t* pEnd = pDest + (count * NeoElementsBase<V_PIXEL_SIZE, T_COLOR_OBJECT, T_COPY>::PixelSize / sizeof(uint16_t));
|
||||
const uint16_t* pSrc = reinterpret_cast<const uint16_t*>(pPixelSrc);
|
||||
|
||||
while (pDest < pEnd)
|
||||
{
|
||||
*pDest++ = pgm_read_word(pSrc++);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
DotStar3Elements provides feature base classes to describe color elements
|
||||
for NeoPixelBus Color Feature template classes when used with DotStars
|
||||
NeoElementsNoSettings provides feature base classes to describe a
|
||||
no settings feature
|
||||
|
||||
Written by Michael C. Miller.
|
||||
|
||||
@@ -26,7 +26,7 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class DotStar3ElementsNoSettings : public Neo4ByteRgbElements
|
||||
class NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
typedef NeoNoSettings SettingsObject;
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class NeoGrb48Feature : public Neo6ByteElementsNoSettings
|
||||
class NeoGrb48Feature :
|
||||
public NeoWordElements<6, Rgb48Color, uint16_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
@@ -48,9 +50,12 @@ public:
|
||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||
|
||||
// due to endianness the byte order must be copied to output
|
||||
color.G = (static_cast<uint16_t>(*p++) << 8) | *p++;
|
||||
color.R = (static_cast<uint16_t>(*p++) << 8) | *p++;
|
||||
color.B = (static_cast<uint16_t>(*p++) << 8) | *p;
|
||||
color.G = (static_cast<uint16_t>(*p++) << 8);
|
||||
color.G |= *p++;
|
||||
color.R = (static_cast<uint16_t>(*p++) << 8);
|
||||
color.R |= *p++;
|
||||
color.B = (static_cast<uint16_t>(*p++) << 8);
|
||||
color.B |= *p;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class NeoGrbFeature : public Neo3ByteElementsNoSettings
|
||||
class NeoGrbFeature :
|
||||
public NeoByteElements<3, RgbColor, uint8_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class NeoGrbwFeature : public Neo4ByteElementsNoSettings
|
||||
class NeoGrbwFeature :
|
||||
public NeoByteElements<4, RgbwColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class NeoRbgFeature : public Neo3ByteElementsNoSettings
|
||||
class NeoRbgFeature :
|
||||
public NeoByteElements<3, RgbColor, uint8_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class NeoRgb48Feature : public Neo6ByteElementsNoSettings
|
||||
class NeoRgb48Feature :
|
||||
public NeoWordElements<6, Rgb48Color, uint16_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
@@ -48,9 +50,12 @@ public:
|
||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||
|
||||
// due to endianness the byte order must be copied to output
|
||||
color.R = (static_cast<uint16_t>(*p++) << 8) | *p++;
|
||||
color.G = (static_cast<uint16_t>(*p++) << 8) | *p++;
|
||||
color.B = (static_cast<uint16_t>(*p++) << 8) | *p;
|
||||
color.R = (static_cast<uint16_t>(*p++) << 8);
|
||||
color.R |= *p++;
|
||||
color.G = (static_cast<uint16_t>(*p++) << 8);
|
||||
color.G |= *p++;
|
||||
color.B = (static_cast<uint16_t>(*p++) << 8);
|
||||
color.B |= *p;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class NeoRgbFeature : public Neo3ByteElementsNoSettings
|
||||
class NeoRgbFeature :
|
||||
public NeoByteElements<3, RgbColor, uint8_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class NeoRgbw64Feature : public Neo8ByteElementsNoSettings
|
||||
class NeoRgbw64Feature :
|
||||
public NeoWordElements<8, Rgbw64Color, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
@@ -51,10 +53,14 @@ public:
|
||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||
|
||||
// due to endianness the byte order must be copied to output
|
||||
color.R = (static_cast<uint16_t>(*p++) << 8) | *p++;
|
||||
color.G = (static_cast<uint16_t>(*p++) << 8) | *p++;
|
||||
color.B = (static_cast<uint16_t>(*p++) << 8) | *p++;
|
||||
color.W = (static_cast<uint16_t>(*p++) << 8) | *p;
|
||||
color.R = (static_cast<uint16_t>(*p++) << 8);
|
||||
color.R |= *p++;
|
||||
color.G = (static_cast<uint16_t>(*p++) << 8);
|
||||
color.G |= *p++;
|
||||
color.B = (static_cast<uint16_t>(*p++) << 8);
|
||||
color.B |= *p++;
|
||||
color.W = (static_cast<uint16_t>(*p++) << 8);
|
||||
color.W |= *p;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class NeoRgbwFeature : public Neo4ByteElementsNoSettings
|
||||
class NeoRgbwFeature :
|
||||
public NeoByteElements<4, RgbwColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -26,7 +26,9 @@ License along with NeoPixel. If not, see
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
class NeoRgbwxxFeature : public Neo6Byte4xxElementsNoSettings
|
||||
class NeoRgbwxxFeature :
|
||||
public NeoByteElements<6, RgbwColor, uint16_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
@@ -199,7 +199,7 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
template<typename T_SETTINGS> class NeoRgbwSm168x4Elements : public Neo4ByteElements
|
||||
template<typename T_SETTINGS> class NeoRgbwSm168x4Elements : public NeoByteElements<4, RgbwColor, uint32_t>
|
||||
{
|
||||
public:
|
||||
typedef T_SETTINGS SettingsObject;
|
||||
@@ -260,7 +260,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T_SETTINGS> class NeoRgbSm168x3Elements : public Neo3ByteElements
|
||||
template<typename T_SETTINGS> class NeoRgbSm168x3Elements : public NeoByteElements<3, RgbColor, uint8_t>
|
||||
{
|
||||
public:
|
||||
typedef T_SETTINGS SettingsObject;
|
||||
|
@@ -25,7 +25,7 @@ License along with NeoPixel. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
-------------------------------------------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
|
||||
class NeoTm1814Settings : public NeoRgbwCurrentSettings
|
||||
{
|
||||
public:
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class Neo4ByteElementsTm1814Settings : public Neo4ByteElements
|
||||
class Neo4ByteElementsTm1814Settings : public NeoByteElements<4, RgbwColor, uint32_t>
|
||||
{
|
||||
private:
|
||||
const static uint16_t EncodeDivisor = 5;
|
||||
|
@@ -44,7 +44,7 @@ public:
|
||||
NeoTm1914_Mode Mode;
|
||||
};
|
||||
|
||||
class Neo3ByteElementsTm1914Settings : public Neo3ByteElements
|
||||
class Neo3ByteElementsTm1914Settings : public NeoByteElements<3, RgbColor, uint8_t>
|
||||
{
|
||||
public:
|
||||
typedef NeoTm1914Settings SettingsObject;
|
||||
|
@@ -27,7 +27,9 @@ License along with NeoPixel. If not, see
|
||||
#pragma once
|
||||
|
||||
|
||||
class P9813BgrFeature : public DotStar3ElementsNoSettings
|
||||
class P9813BgrFeature :
|
||||
public NeoByteElements<4, RgbColor, uint32_t>,
|
||||
public NeoElementsNoSettings
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
|
Reference in New Issue
Block a user