forked from Makuna/NeoPixelBus
refactor color features (#661)
* dotstars * SevenSegment * featured all moved * cleanup
This commit is contained in:
@@ -50,14 +50,6 @@ License along with NeoPixel. If not, see
|
|||||||
#include "internal/SegmentDigit.h"
|
#include "internal/SegmentDigit.h"
|
||||||
|
|
||||||
#include "internal/NeoColorFeatures.h"
|
#include "internal/NeoColorFeatures.h"
|
||||||
#include "internal/NeoTm1814ColorFeatures.h"
|
|
||||||
#include "internal/NeoTm1914ColorFeatures.h"
|
|
||||||
#include "internal/NeoSm168xxColorFeatures.h"
|
|
||||||
#include "internal/DotStarColorFeatures.h"
|
|
||||||
#include "internal/Lpd8806ColorFeatures.h"
|
|
||||||
#include "internal/Lpd6803ColorFeatures.h"
|
|
||||||
#include "internal/P9813ColorFeatures.h"
|
|
||||||
#include "internal/NeoSegmentFeatures.h"
|
|
||||||
|
|
||||||
#include "internal/Layouts.h"
|
#include "internal/Layouts.h"
|
||||||
#include "internal/NeoTopology.h"
|
#include "internal/NeoTopology.h"
|
||||||
|
@@ -1,698 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
DotStarColorFeatures provides feature classes to describe color order and
|
|
||||||
color depth for NeoPixelBus template class when used with DotStars
|
|
||||||
|
|
||||||
Written by Michael C. Miller.
|
|
||||||
|
|
||||||
I invest time and resources providing this open source code,
|
|
||||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
|
||||||
This file is part of the Makuna/NeoPixelBus library.
|
|
||||||
|
|
||||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser General Public License as
|
|
||||||
published by the Free Software Foundation, either version 3 of
|
|
||||||
the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
NeoPixelBus is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with NeoPixel. If not, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
-------------------------------------------------------------------------*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
class DotStar3Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const size_t PixelSize = 4; // still requires 4 to be sent
|
|
||||||
|
|
||||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = pPixelSrc[0];
|
|
||||||
*pPixelDest++ = pPixelSrc[1];
|
|
||||||
*pPixelDest++ = pPixelSrc[2];
|
|
||||||
*pPixelDest++ = pPixelSrc[3];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
|
||||||
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
|
||||||
while (pDestBack > pPixelDest)
|
|
||||||
{
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef RgbColor ColorObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DotStar4Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const size_t PixelSize = 4;
|
|
||||||
|
|
||||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = pPixelSrc[0];
|
|
||||||
*pPixelDest++ = pPixelSrc[1];
|
|
||||||
*pPixelDest++ = pPixelSrc[2];
|
|
||||||
*pPixelDest++ = pPixelSrc[3];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
|
||||||
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
|
||||||
while (pDestBack > pPixelDest)
|
|
||||||
{
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef RgbwColor ColorObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class DotStar3ElementsNoSettings : public DotStar3Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef NeoNoSettings SettingsObject;
|
|
||||||
static const size_t SettingsSize = 0;
|
|
||||||
|
|
||||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class DotStar4ElementsNoSettings : public DotStar4Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef NeoNoSettings SettingsObject;
|
|
||||||
static const size_t SettingsSize = 0;
|
|
||||||
|
|
||||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class DotStarBgrFeature : public DotStar3ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
|
||||||
*p++ = color.B;
|
|
||||||
*p++ = color.G;
|
|
||||||
*p = color.R;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
p++; // ignore the first byte
|
|
||||||
color.B = *p++;
|
|
||||||
color.G = *p++;
|
|
||||||
color.R = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
pgm_read_byte(p++); // ignore the first byte
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class DotStarLbgrFeature : public DotStar4ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
|
||||||
*p++ = color.B;
|
|
||||||
*p++ = color.G;
|
|
||||||
*p = color.R;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = (*p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.B = *p++;
|
|
||||||
color.G = *p++;
|
|
||||||
color.R = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class DotStarGrbFeature : public DotStar3ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
|
||||||
*p++ = color.G;
|
|
||||||
*p++ = color.R;
|
|
||||||
*p = color.B;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
p++; // ignore the first byte
|
|
||||||
color.G = *p++;
|
|
||||||
color.R = *p++;
|
|
||||||
color.B = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
pgm_read_byte(p++); // ignore the first byte
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.B = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class DotStarLgrbFeature : public DotStar4ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
|
||||||
*p++ = color.G;
|
|
||||||
*p++ = color.R;
|
|
||||||
*p = color.B;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = (*p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.G = *p++;
|
|
||||||
color.R = *p++;
|
|
||||||
color.B = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.B = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/* RGB Feature -- Some APA102s ship in RGB order */
|
|
||||||
class DotStarRgbFeature : public DotStar3ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
|
||||||
*p++ = color.R;
|
|
||||||
*p++ = color.G;
|
|
||||||
*p = color.B;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
p++; // ignore the first byte
|
|
||||||
color.R = *p++;
|
|
||||||
color.G = *p++;
|
|
||||||
color.B = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
pgm_read_byte(p++); // ignore the first byte
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.B = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class DotStarLrgbFeature : public DotStar4ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
|
||||||
*p++ = color.R;
|
|
||||||
*p++ = color.G;
|
|
||||||
*p = color.B;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = (*p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.R = *p++;
|
|
||||||
color.G = *p++;
|
|
||||||
color.B = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.B = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
/* RBG Feature -- Some APA102s ship in RBG order */
|
|
||||||
class DotStarRbgFeature : public DotStar3ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
|
||||||
*p++ = color.R;
|
|
||||||
*p++ = color.B;
|
|
||||||
*p = color.G;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
p++; // ignore the first byte
|
|
||||||
color.R = *p++;
|
|
||||||
color.B = *p++;
|
|
||||||
color.G = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
pgm_read_byte(p++); // ignore the first byte
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class DotStarLrbgFeature : public DotStar4ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
|
||||||
*p++ = color.R;
|
|
||||||
*p++ = color.B;
|
|
||||||
*p = color.G;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = (*p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.R = *p++;
|
|
||||||
color.B = *p++;
|
|
||||||
color.G = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/* GBR Feature -- Some APA102s ship in GBR order */
|
|
||||||
class DotStarGbrFeature : public DotStar3ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
|
||||||
*p++ = color.G;
|
|
||||||
*p++ = color.B;
|
|
||||||
*p = color.R;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
p++; // ignore the first byte
|
|
||||||
color.G = *p++;
|
|
||||||
color.B = *p++;
|
|
||||||
color.R = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
pgm_read_byte(p++); // ignore the first byte
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class DotStarLgbrFeature : public DotStar4ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
|
||||||
*p++ = color.G;
|
|
||||||
*p++ = color.B;
|
|
||||||
*p = color.R;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = (*p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.G = *p++;
|
|
||||||
color.B = *p++;
|
|
||||||
color.R = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
/* BRG Feature -- Some APA102s ship in BRG order */
|
|
||||||
class DotStarBrgFeature : public DotStar3ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
|
||||||
*p++ = color.B;
|
|
||||||
*p++ = color.R;
|
|
||||||
*p = color.G;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
p++; // ignore the first byte
|
|
||||||
color.B = *p++;
|
|
||||||
color.R = *p++;
|
|
||||||
color.G = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
pgm_read_byte(p++); // ignore the first byte
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class DotStarLbrgFeature : public DotStar4ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
|
||||||
*p++ = color.B;
|
|
||||||
*p++ = color.R;
|
|
||||||
*p = color.G;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = (*p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.B = *p++;
|
|
||||||
color.R = *p++;
|
|
||||||
color.G = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
@@ -1,301 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
Lpd6803ColorFeatures provides feature classes to describe color order and
|
|
||||||
color depth for NeoPixelBus template class when used with DotStar like chips
|
|
||||||
|
|
||||||
Written by Michael C. Miller.
|
|
||||||
|
|
||||||
I invest time and resources providing this open source code,
|
|
||||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
|
||||||
This file is part of the Makuna/NeoPixelBus library.
|
|
||||||
|
|
||||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser General Public License as
|
|
||||||
published by the Free Software Foundation, either version 3 of
|
|
||||||
the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
NeoPixelBus is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with NeoPixel. If not, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
-------------------------------------------------------------------------*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
class Lpd68033ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef NeoNoSettings SettingsObject;
|
|
||||||
static const size_t SettingsSize = 0;
|
|
||||||
|
|
||||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Lpd68033Elements : public Lpd68033ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const size_t PixelSize = 2; // 1 bit + 555 encoded elements
|
|
||||||
|
|
||||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = pPixelSrc[0];
|
|
||||||
*pPixelDest++ = pPixelSrc[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
|
||||||
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
|
||||||
while (pDestBack > pPixelDest)
|
|
||||||
{
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef RgbColor ColorObject;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static void encodePixel(uint8_t c1, uint8_t c2, uint8_t c3, uint16_t* color555)
|
|
||||||
{
|
|
||||||
*color555 = (0x8000 |
|
|
||||||
((c1 & 0xf8) << 7) |
|
|
||||||
((c2 & 0xf8) << 2) |
|
|
||||||
((c3 & 0xf8) >> 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void decodePixel(uint16_t color555, uint8_t* c1, uint8_t* c2, uint8_t* c3)
|
|
||||||
{
|
|
||||||
*c1 = (color555 >> 7) & 0xf8;
|
|
||||||
*c2 = (color555 >> 2) & 0xf8;
|
|
||||||
*c3 = (color555 << 3) & 0xf8;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Lpd6803BrgFeature : public Lpd68033Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
encodePixel(color.B, color.R, color.G, &color555);
|
|
||||||
*p++ = color555 >> 8;
|
|
||||||
*p = color555 & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
color555 = ((*p++) << 8);
|
|
||||||
color555 |= (*p);
|
|
||||||
|
|
||||||
decodePixel(color555, &color.B, &color.R, &color.G);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
color555 = (pgm_read_byte(p++) << 8);
|
|
||||||
color555 |= pgm_read_byte(p);
|
|
||||||
|
|
||||||
decodePixel(color555, &color.B, &color.R, &color.G);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Lpd6803GrbFeature : public Lpd68033Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
encodePixel(color.G, color.R, color.B, &color555);
|
|
||||||
*p++ = color555 >> 8;
|
|
||||||
*p = color555 & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
color555 = ((*p++) << 8);
|
|
||||||
color555 |= (*p);
|
|
||||||
|
|
||||||
decodePixel(color555, &color.G, &color.R, &color.B);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
color555 = (pgm_read_byte(p++) << 8);
|
|
||||||
color555 |= pgm_read_byte(p);
|
|
||||||
|
|
||||||
decodePixel(color555, &color.G, &color.R, &color.B);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Lpd6803GbrFeature : public Lpd68033Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
encodePixel(color.G, color.B, color.R, &color555);
|
|
||||||
*p++ = color555 >> 8;
|
|
||||||
*p = color555 & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
color555 = ((*p++) << 8);
|
|
||||||
color555 |= (*p);
|
|
||||||
|
|
||||||
decodePixel(color555, &color.G, &color.B, &color.R);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
color555 = (pgm_read_byte(p++) << 8);
|
|
||||||
color555 |= pgm_read_byte(p);
|
|
||||||
|
|
||||||
decodePixel(color555, &color.G, &color.B, &color.R);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Lpd6803RgbFeature : public Lpd68033Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
encodePixel(color.R, color.G, color.B, &color555);
|
|
||||||
*p++ = color555 >> 8;
|
|
||||||
*p = color555 & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
color555 = ((*p++) << 8);
|
|
||||||
color555 |= (*p);
|
|
||||||
|
|
||||||
decodePixel(color555, &color.R, &color.G, &color.B);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
uint16_t color555;
|
|
||||||
|
|
||||||
color555 = (pgm_read_byte(p++) << 8);
|
|
||||||
color555 |= pgm_read_byte(p);
|
|
||||||
|
|
||||||
decodePixel(color555, &color.R, &color.G, &color.B);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@@ -1,5 +1,5 @@
|
|||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
NeoColorFeatures provides feature classes to describe color order and
|
NeoColorFeatures includes all the feature classes that describe color order and
|
||||||
color depth for NeoPixelBus template class
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
Written by Michael C. Miller.
|
Written by Michael C. Miller.
|
||||||
@@ -26,734 +26,59 @@ License along with NeoPixel. If not, see
|
|||||||
-------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class Neo3ByteElements
|
// NeoPixel Features
|
||||||
{
|
//
|
||||||
public:
|
#include "features/Neo2ByteElements.h"
|
||||||
static const size_t PixelSize = 3;
|
#include "features/Neo3ByteElements.h"
|
||||||
|
#include "features/Neo4ByteElements.h"
|
||||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
#include "features/Neo6ByteElements.h"
|
||||||
{
|
#include "features/Neo8ByteElements.h"
|
||||||
return pPixels + indexPixel * PixelSize;
|
#include "features/NeoBgrFeature.h"
|
||||||
}
|
#include "features/NeoBrgFeature.h"
|
||||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
#include "features/NeoGrb48Feature.h"
|
||||||
{
|
#include "features/NeoGrbFeature.h"
|
||||||
return pPixels + indexPixel * PixelSize;
|
#include "features/NeoGrbwFeature.h"
|
||||||
}
|
#include "features/NeoRbgFeature.h"
|
||||||
|
#include "features/NeoRgb48Feature.h"
|
||||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
#include "features/NeoRgbFeature.h"
|
||||||
{
|
#include "features/NeoRgbw64Feature.h"
|
||||||
const uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
#include "features/NeoRgbwFeature.h"
|
||||||
|
#include "features/NeoSm168xxColorFeatures.h"
|
||||||
while (pPixelDest < pEnd)
|
#include "features/NeoTm1814ColorFeatures.h"
|
||||||
{
|
#include "features/NeoTm1914ColorFeatures.h"
|
||||||
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 Neo4ByteElements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const size_t PixelSize = 4;
|
|
||||||
|
|
||||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint32_t* pDest = reinterpret_cast<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 RgbwColor ColorObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Neo6ByteElements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const size_t PixelSize = 6;
|
|
||||||
|
|
||||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint16_t* pDest = reinterpret_cast<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 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 Neo3ByteElementsNoSettings : public Neo3ByteElements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef NeoNoSettings SettingsObject;
|
|
||||||
static const size_t SettingsSize = 0;
|
|
||||||
|
|
||||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Neo4ByteElementsNoSettings : public Neo4ByteElements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef NeoNoSettings SettingsObject;
|
|
||||||
static const size_t SettingsSize = 0;
|
|
||||||
|
|
||||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Neo6ByteElementsNoSettings : public Neo6ByteElements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef NeoNoSettings SettingsObject;
|
|
||||||
static const size_t SettingsSize = 0;
|
|
||||||
|
|
||||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Neo8ByteElementsNoSettings : public Neo8ByteElements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef NeoNoSettings SettingsObject;
|
|
||||||
static const size_t SettingsSize = 0;
|
|
||||||
|
|
||||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NeoGrbFeature : public Neo3ByteElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = color.G;
|
|
||||||
*p++ = color.R;
|
|
||||||
*p = color.B;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.G = *p++;
|
|
||||||
color.R = *p++;
|
|
||||||
color.B = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(reinterpret_cast<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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NeoGrbwFeature : public Neo4ByteElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = color.G;
|
|
||||||
*p++ = color.R;
|
|
||||||
*p++ = color.B;
|
|
||||||
*p = color.W;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.G = *p++;
|
|
||||||
color.R = *p++;
|
|
||||||
color.B = *p++;
|
|
||||||
color.W = *p;
|
|
||||||
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel);
|
|
||||||
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.W = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NeoRgbwFeature : public Neo4ByteElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = color.R;
|
|
||||||
*p++ = color.G;
|
|
||||||
*p++ = color.B;
|
|
||||||
*p = color.W;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.R = *p++;
|
|
||||||
color.G = *p++;
|
|
||||||
color.B = *p++;
|
|
||||||
color.W = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(reinterpret_cast<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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NeoRgbFeature : public Neo3ByteElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = color.R;
|
|
||||||
*p++ = color.G;
|
|
||||||
*p = color.B;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.R = *p++;
|
|
||||||
color.G = *p++;
|
|
||||||
color.B = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(reinterpret_cast<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 NeoBrgFeature : public Neo3ByteElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = color.B;
|
|
||||||
*p++ = color.R;
|
|
||||||
*p = color.G;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.B = *p++;
|
|
||||||
color.R = *p++;
|
|
||||||
color.G = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel);
|
|
||||||
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NeoRbgFeature : public Neo3ByteElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = color.R;
|
|
||||||
*p++ = color.B;
|
|
||||||
*p = color.G;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.R = *p++;
|
|
||||||
color.B = *p++;
|
|
||||||
color.G = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel);
|
|
||||||
|
|
||||||
color.R = pgm_read_byte(p++);
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NeoBgrFeature : public Neo3ByteElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = color.B;
|
|
||||||
*p++ = color.G;
|
|
||||||
*p = color.R;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.B = *p++;
|
|
||||||
color.G = *p++;
|
|
||||||
color.R = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel);
|
|
||||||
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NeoRgbw64Feature : public Neo8ByteElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint16_t* p = reinterpret_cast<uint16_t *>(getPixelAddress(pPixels, indexPixel));
|
|
||||||
|
|
||||||
*p++ = color.R;
|
|
||||||
*p++ = color.G;
|
|
||||||
*p++ = color.B;
|
|
||||||
*p = color.W;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
|
||||||
|
|
||||||
color.R = *p++;
|
|
||||||
color.G = *p++;
|
|
||||||
color.B = *p++;
|
|
||||||
color.W = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel));
|
|
||||||
|
|
||||||
color.R = pgm_read_word(p++);
|
|
||||||
color.G = pgm_read_word(p++);
|
|
||||||
color.B = pgm_read_word(p++);
|
|
||||||
color.W = pgm_read_word(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NeoRgb48Feature : public Neo6ByteElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint16_t* p = reinterpret_cast<uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
|
||||||
|
|
||||||
*p++ = color.R;
|
|
||||||
*p++ = color.G;
|
|
||||||
*p = color.B;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
|
||||||
|
|
||||||
color.R = *p++;
|
|
||||||
color.G = *p++;
|
|
||||||
color.B = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel));
|
|
||||||
|
|
||||||
color.R = pgm_read_word(p++);
|
|
||||||
color.G = pgm_read_word(p++);
|
|
||||||
color.B = pgm_read_word(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef NeoRgb48Feature NeoRgbUcs8903Feature;
|
typedef NeoRgb48Feature NeoRgbUcs8903Feature;
|
||||||
typedef NeoRgbw64Feature NeoRgbwUcs8904Feature;
|
typedef NeoRgbw64Feature NeoRgbwUcs8904Feature;
|
||||||
|
|
||||||
|
|
||||||
class NeoGrb48Feature : public Neo6ByteElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint16_t* p = reinterpret_cast<uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
|
||||||
|
|
||||||
*p++ = color.G;
|
|
||||||
*p++ = color.R;
|
|
||||||
*p = color.B;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
|
||||||
|
|
||||||
color.G = *p++;
|
|
||||||
color.R = *p++;
|
|
||||||
color.B = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel));
|
|
||||||
|
|
||||||
color.G = pgm_read_word(p++);
|
|
||||||
color.R = pgm_read_word(p++);
|
|
||||||
color.B = pgm_read_word(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef NeoGrb48Feature NeoGrbWs2816Feature;
|
typedef NeoGrb48Feature NeoGrbWs2816Feature;
|
||||||
|
|
||||||
|
// DotStart Features
|
||||||
|
//
|
||||||
|
#include "features/DotStar3Elements.h"
|
||||||
|
#include "features/DotStar4Elements.h"
|
||||||
|
#include "features/DotStarBgrFeature.h"
|
||||||
|
#include "features/DotStarBrgFeature.h"
|
||||||
|
#include "features/DotStarGbrFeature.h"
|
||||||
|
#include "features/DotStarGrbFeature.h"
|
||||||
|
#include "features/DotStarLbgrFeature.h"
|
||||||
|
#include "features/DotStarLbrgFeature.h"
|
||||||
|
#include "features/DotStarLgbrFeature.h"
|
||||||
|
#include "features/DotStarLgrbFeature.h"
|
||||||
|
#include "features/DotStarLrbgFeature.h"
|
||||||
|
#include "features/DotStarLrgbFeature.h"
|
||||||
|
#include "features/DotStarRbgFeature.h"
|
||||||
|
#include "features/DotStarRgbFeature.h"
|
||||||
|
#include "features/Lpd8806BrgFeature.h"
|
||||||
|
#include "features/Lpd8806GrbFeature.h"
|
||||||
|
#include "features/Lpd6803BrgFeature.h"
|
||||||
|
#include "features/Lpd6803GrbFeature.h"
|
||||||
|
#include "features/Lpd6803GbrFeature.h"
|
||||||
|
#include "features/Lpd6803RgbFeature.h"
|
||||||
|
#include "features/P9813BgrFeature.h"
|
||||||
|
|
||||||
|
// 7 Segment Features
|
||||||
|
//
|
||||||
|
#include "features/Neo9ByteElements.h"
|
||||||
|
#include "features/NeoAbcdefgpsSegmentFeature.h"
|
||||||
|
#include "features/NeoBacedfpgsSegmentFeature.h"
|
||||||
|
|
||||||
|
typedef NeoAbcdefgpsSegmentFeature SevenSegmentFeature; // Abcdefg order is default
|
||||||
|
@@ -1,216 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
NeoSegmentFeatures provides feature classes to describe seven segment display
|
|
||||||
elements for NeoPixelBus template class
|
|
||||||
|
|
||||||
Written by Michael C. Miller.
|
|
||||||
|
|
||||||
I invest time and resources providing this open source code,
|
|
||||||
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
|
||||||
This file is part of the Makuna/NeoPixelBus library.
|
|
||||||
|
|
||||||
NeoPixelBus is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Lesser General Public License as
|
|
||||||
published by the Free Software Foundation, either version 3 of
|
|
||||||
the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
NeoPixelBus is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with NeoPixel. If not, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
-------------------------------------------------------------------------*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
class Neo9Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const size_t PixelSize = 9; // three 3 element
|
|
||||||
|
|
||||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
for (uint8_t iElement = 0; iElement < PixelSize; iElement++)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = pPixelSrc[iElement];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
|
||||||
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
|
||||||
while (pDestBack > pPixelDest)
|
|
||||||
{
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef SevenSegDigit ColorObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Neo9ElementsNoSettings : public Neo9Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef NeoNoSettings SettingsObject;
|
|
||||||
static const size_t SettingsSize = 0;
|
|
||||||
|
|
||||||
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
|
||||||
{
|
|
||||||
return pData;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Abcdefgps byte order
|
|
||||||
class NeoAbcdefgSegmentFeature : public Neo9ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count;
|
|
||||||
for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++)
|
|
||||||
{
|
|
||||||
*p++ = color.Segment[iSegment];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count;
|
|
||||||
|
|
||||||
for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++)
|
|
||||||
{
|
|
||||||
color.Segment[iSegment] = *p++;
|
|
||||||
}
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count;
|
|
||||||
|
|
||||||
for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++)
|
|
||||||
{
|
|
||||||
color.Segment[iSegment] = pgm_read_byte(p++);
|
|
||||||
}
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// BACEDF.G+ byte order
|
|
||||||
class NeoBacedfpgsSegmentFeature : public Neo9ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
// Segment Digit is Abcdefgps order
|
|
||||||
*p++ = color.Segment[LedSegment_B];
|
|
||||||
*p++ = color.Segment[LedSegment_A];
|
|
||||||
*p++ = color.Segment[LedSegment_C];
|
|
||||||
|
|
||||||
*p++ = color.Segment[LedSegment_E];
|
|
||||||
*p++ = color.Segment[LedSegment_D];
|
|
||||||
*p++ = color.Segment[LedSegment_F];
|
|
||||||
|
|
||||||
*p++ = color.Segment[LedSegment_Decimal];
|
|
||||||
*p++ = color.Segment[LedSegment_G];
|
|
||||||
*p++ = color.Segment[LedSegment_Custom];
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.Segment[LedSegment_B] = *p++;
|
|
||||||
color.Segment[LedSegment_A] = *p++;
|
|
||||||
color.Segment[LedSegment_C] = *p++;
|
|
||||||
|
|
||||||
color.Segment[LedSegment_E] = *p++;
|
|
||||||
color.Segment[LedSegment_D] = *p++;
|
|
||||||
color.Segment[LedSegment_F] = *p++;
|
|
||||||
|
|
||||||
color.Segment[LedSegment_Decimal] = *p++;
|
|
||||||
color.Segment[LedSegment_G] = *p++;
|
|
||||||
color.Segment[LedSegment_Custom] = *p++;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.Segment[LedSegment_B] = pgm_read_byte(p++);
|
|
||||||
color.Segment[LedSegment_A] = pgm_read_byte(p++);
|
|
||||||
color.Segment[LedSegment_C] = pgm_read_byte(p++);
|
|
||||||
|
|
||||||
color.Segment[LedSegment_E] = pgm_read_byte(p++);
|
|
||||||
color.Segment[LedSegment_D] = pgm_read_byte(p++);
|
|
||||||
color.Segment[LedSegment_F] = pgm_read_byte(p++);
|
|
||||||
|
|
||||||
color.Segment[LedSegment_Decimal] = pgm_read_byte(p++);
|
|
||||||
color.Segment[LedSegment_G] = pgm_read_byte(p++);
|
|
||||||
color.Segment[LedSegment_Custom] = pgm_read_byte(p++);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef NeoBacedfpgsSegmentFeature SevenSegmentFeature; // Abcdefg order is default
|
|
48
src/internal/features/DotStar3Elements.h
Normal file
48
src/internal/features/DotStar3Elements.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStar3Elements provides feature base classes to describe color elements
|
||||||
|
for NeoPixelBus Color Feature template classes when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class DotStar3ElementsNoSettings : public Neo4ByteRgbElements
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef NeoNoSettings SettingsObject;
|
||||||
|
static const size_t SettingsSize = 0;
|
||||||
|
|
||||||
|
static void applySettings([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData, [[maybe_unused]] const SettingsObject& settings)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t* pixels([[maybe_unused]] uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||||
|
{
|
||||||
|
return pData;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const uint8_t* pixels([[maybe_unused]] const uint8_t* pData, [[maybe_unused]] size_t sizeData)
|
||||||
|
{
|
||||||
|
return pData;
|
||||||
|
}
|
||||||
|
};
|
@@ -1,6 +1,6 @@
|
|||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
P9813ColorFeatures provides feature classes to describe color order and
|
DotStar4Elements provides feature base classes to describe color elements
|
||||||
color depth for NeoPixelBus template class when used with P9813s
|
for NeoPixelBus Color Feature template classes when used with DotStars
|
||||||
|
|
||||||
Written by Michael C. Miller.
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
@@ -26,10 +26,11 @@ License along with NeoPixel. If not, see
|
|||||||
-------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class P98133Elements
|
|
||||||
|
class DotStar4Elements
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const size_t PixelSize = 4; // still requires 4 to be sent
|
static const size_t PixelSize = 4;
|
||||||
|
|
||||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||||
{
|
{
|
||||||
@@ -90,10 +91,11 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef RgbColor ColorObject;
|
typedef RgbwColor ColorObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
class P98133ElementsNoSettings : public P98133Elements
|
|
||||||
|
class DotStar4ElementsNoSettings : public DotStar4Elements
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef NeoNoSettings SettingsObject;
|
typedef NeoNoSettings SettingsObject;
|
||||||
@@ -112,51 +114,4 @@ public:
|
|||||||
{
|
{
|
||||||
return pData;
|
return pData;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class P9813BgrFeature : public P98133ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = 0xC0 | ((~color.B & 0xC0) >> 2) | ((~color.G & 0xC0) >> 4) | ((~color.R & 0xC0) >> 6);
|
|
||||||
*p++ = color.B;
|
|
||||||
*p++ = color.G;
|
|
||||||
*p = color.R;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
p++; // ignore the first byte
|
|
||||||
color.B = *p++;
|
|
||||||
color.G = *p++;
|
|
||||||
color.R = *p;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
pgm_read_byte(p++); // ignore the first byte
|
|
||||||
color.B = pgm_read_byte(p++);
|
|
||||||
color.G = pgm_read_byte(p++);
|
|
||||||
color.R = pgm_read_byte(p);
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
69
src/internal/features/DotStarBgrFeature.h
Normal file
69
src/internal/features/DotStarBgrFeature.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarBgrFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class DotStarBgrFeature : public DotStar3ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
||||||
|
*p++ = color.B;
|
||||||
|
*p++ = color.G;
|
||||||
|
*p = color.R;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
p++; // ignore the first byte
|
||||||
|
color.B = *p++;
|
||||||
|
color.G = *p++;
|
||||||
|
color.R = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
pgm_read_byte(p++); // ignore the first byte
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
68
src/internal/features/DotStarBrgFeature.h
Normal file
68
src/internal/features/DotStarBrgFeature.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarBrgFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class DotStarBrgFeature : public DotStar3ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
||||||
|
*p++ = color.B;
|
||||||
|
*p++ = color.R;
|
||||||
|
*p = color.G;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
p++; // ignore the first byte
|
||||||
|
color.B = *p++;
|
||||||
|
color.R = *p++;
|
||||||
|
color.G = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
pgm_read_byte(p++); // ignore the first byte
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
68
src/internal/features/DotStarGbrFeature.h
Normal file
68
src/internal/features/DotStarGbrFeature.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarGbrFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class DotStarGbrFeature : public DotStar3ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
||||||
|
*p++ = color.G;
|
||||||
|
*p++ = color.B;
|
||||||
|
*p = color.R;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
p++; // ignore the first byte
|
||||||
|
color.G = *p++;
|
||||||
|
color.B = *p++;
|
||||||
|
color.R = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
pgm_read_byte(p++); // ignore the first byte
|
||||||
|
color.G = pgm_read_byte(p++);
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
69
src/internal/features/DotStarGrbFeature.h
Normal file
69
src/internal/features/DotStarGrbFeature.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarGrbFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class DotStarGrbFeature : public DotStar3ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
||||||
|
*p++ = color.G;
|
||||||
|
*p++ = color.R;
|
||||||
|
*p = color.B;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
p++; // ignore the first byte
|
||||||
|
color.G = *p++;
|
||||||
|
color.R = *p++;
|
||||||
|
color.B = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
pgm_read_byte(p++); // ignore the first byte
|
||||||
|
color.G = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p++);
|
||||||
|
color.B = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
69
src/internal/features/DotStarLbgrFeature.h
Normal file
69
src/internal/features/DotStarLbgrFeature.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarLbgrFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class DotStarLbgrFeature : public DotStar4ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
||||||
|
*p++ = color.B;
|
||||||
|
*p++ = color.G;
|
||||||
|
*p = color.R;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = (*p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.B = *p++;
|
||||||
|
color.G = *p++;
|
||||||
|
color.R = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
68
src/internal/features/DotStarLbrgFeature.h
Normal file
68
src/internal/features/DotStarLbrgFeature.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarLbrgFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class DotStarLbrgFeature : public DotStar4ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
||||||
|
*p++ = color.B;
|
||||||
|
*p++ = color.R;
|
||||||
|
*p = color.G;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = (*p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.B = *p++;
|
||||||
|
color.R = *p++;
|
||||||
|
color.G = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
69
src/internal/features/DotStarLgbrFeature.h
Normal file
69
src/internal/features/DotStarLgbrFeature.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarLgbrFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class DotStarLgbrFeature : public DotStar4ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
||||||
|
*p++ = color.G;
|
||||||
|
*p++ = color.B;
|
||||||
|
*p = color.R;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = (*p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.G = *p++;
|
||||||
|
color.B = *p++;
|
||||||
|
color.R = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.G = pgm_read_byte(p++);
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
69
src/internal/features/DotStarLgrbFeature.h
Normal file
69
src/internal/features/DotStarLgrbFeature.h
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarLgrbFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class DotStarLgrbFeature : public DotStar4ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
||||||
|
*p++ = color.G;
|
||||||
|
*p++ = color.R;
|
||||||
|
*p = color.B;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = (*p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.G = *p++;
|
||||||
|
color.R = *p++;
|
||||||
|
color.B = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.G = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p++);
|
||||||
|
color.B = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
68
src/internal/features/DotStarLrbgFeature.h
Normal file
68
src/internal/features/DotStarLrbgFeature.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarLrbgFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class DotStarLrbgFeature : public DotStar4ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
||||||
|
*p++ = color.R;
|
||||||
|
*p++ = color.B;
|
||||||
|
*p = color.G;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = (*p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.R = *p++;
|
||||||
|
color.B = *p++;
|
||||||
|
color.G = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.R = pgm_read_byte(p++);
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
68
src/internal/features/DotStarLrgbFeature.h
Normal file
68
src/internal/features/DotStarLrgbFeature.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarLrgbFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class DotStarLrgbFeature : public DotStar4ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xE0 | (color.W < 31 ? color.W : 31); // upper three bits are always 111
|
||||||
|
*p++ = color.R;
|
||||||
|
*p++ = color.G;
|
||||||
|
*p = color.B;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = (*p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.R = *p++;
|
||||||
|
color.G = *p++;
|
||||||
|
color.B = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.W = pgm_read_byte(p++) & 0x1F; // mask out upper three bits
|
||||||
|
color.R = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p++);
|
||||||
|
color.B = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
68
src/internal/features/DotStarRbgFeature.h
Normal file
68
src/internal/features/DotStarRbgFeature.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarRbgFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class DotStarRbgFeature : public DotStar3ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
||||||
|
*p++ = color.R;
|
||||||
|
*p++ = color.B;
|
||||||
|
*p = color.G;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
p++; // ignore the first byte
|
||||||
|
color.R = *p++;
|
||||||
|
color.B = *p++;
|
||||||
|
color.G = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
pgm_read_byte(p++); // ignore the first byte
|
||||||
|
color.R = pgm_read_byte(p++);
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
68
src/internal/features/DotStarRgbFeature.h
Normal file
68
src/internal/features/DotStarRgbFeature.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
DotStarRgbFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStars
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class DotStarRgbFeature : public DotStar3ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xff; // upper three bits are always 111 and brightness at max
|
||||||
|
*p++ = color.R;
|
||||||
|
*p++ = color.G;
|
||||||
|
*p = color.B;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
p++; // ignore the first byte
|
||||||
|
color.R = *p++;
|
||||||
|
color.G = *p++;
|
||||||
|
color.B = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
pgm_read_byte(p++); // ignore the first byte
|
||||||
|
color.R = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p++);
|
||||||
|
color.B = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
72
src/internal/features/Lpd6803BrgFeature.h
Normal file
72
src/internal/features/Lpd6803BrgFeature.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Lpd6803BrgFeature provides feature class to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStar like chips
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class Lpd6803BrgFeature : public Neo2ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
encodePixel(color.B, color.R, color.G, &color555);
|
||||||
|
*p++ = color555 >> 8;
|
||||||
|
*p = color555 & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
color555 = ((*p++) << 8);
|
||||||
|
color555 |= (*p);
|
||||||
|
|
||||||
|
decodePixel(color555, &color.B, &color.R, &color.G);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
color555 = (pgm_read_byte(p++) << 8);
|
||||||
|
color555 |= pgm_read_byte(p);
|
||||||
|
|
||||||
|
decodePixel(color555, &color.B, &color.R, &color.G);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
};
|
73
src/internal/features/Lpd6803GbrFeature.h
Normal file
73
src/internal/features/Lpd6803GbrFeature.h
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Lpd6803GbrFeature provides feature class to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStar like chips
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class Lpd6803GbrFeature : public Neo2ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
encodePixel(color.G, color.B, color.R, &color555);
|
||||||
|
*p++ = color555 >> 8;
|
||||||
|
*p = color555 & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
color555 = ((*p++) << 8);
|
||||||
|
color555 |= (*p);
|
||||||
|
|
||||||
|
decodePixel(color555, &color.G, &color.B, &color.R);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
color555 = (pgm_read_byte(p++) << 8);
|
||||||
|
color555 |= pgm_read_byte(p);
|
||||||
|
|
||||||
|
decodePixel(color555, &color.G, &color.B, &color.R);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
72
src/internal/features/Lpd6803GrbFeature.h
Normal file
72
src/internal/features/Lpd6803GrbFeature.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Lpd6803GrbFeature provides feature class to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStar like chips
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class Lpd6803GrbFeature : public Neo2ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
encodePixel(color.G, color.R, color.B, &color555);
|
||||||
|
*p++ = color555 >> 8;
|
||||||
|
*p = color555 & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
color555 = ((*p++) << 8);
|
||||||
|
color555 |= (*p);
|
||||||
|
|
||||||
|
decodePixel(color555, &color.G, &color.R, &color.B);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
color555 = (pgm_read_byte(p++) << 8);
|
||||||
|
color555 |= pgm_read_byte(p);
|
||||||
|
|
||||||
|
decodePixel(color555, &color.G, &color.R, &color.B);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
};
|
73
src/internal/features/Lpd6803RgbFeature.h
Normal file
73
src/internal/features/Lpd6803RgbFeature.h
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Lpd6803RgbFeature provides feature class to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStar like chips
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class Lpd6803RgbFeature : public Neo2ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
encodePixel(color.R, color.G, color.B, &color555);
|
||||||
|
*p++ = color555 >> 8;
|
||||||
|
*p = color555 & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
color555 = ((*p++) << 8);
|
||||||
|
color555 |= (*p);
|
||||||
|
|
||||||
|
decodePixel(color555, &color.R, &color.G, &color.B);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
uint16_t color555;
|
||||||
|
|
||||||
|
color555 = (pgm_read_byte(p++) << 8);
|
||||||
|
color555 |= pgm_read_byte(p);
|
||||||
|
|
||||||
|
decodePixel(color555, &color.R, &color.G, &color.B);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
66
src/internal/features/Lpd8806BrgFeature.h
Normal file
66
src/internal/features/Lpd8806BrgFeature.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Lpd8806BrgFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStar like chips
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class Lpd8806BrgFeature : public Neo3ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = (color.B >> 1) | 0x80;
|
||||||
|
*p++ = (color.R >> 1) | 0x80;
|
||||||
|
*p = (color.G >> 1) | 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.B = (*p++) << 1;
|
||||||
|
color.R = (*p++) << 1;
|
||||||
|
color.G = (*p) << 1;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.B = (pgm_read_byte(p++)) << 1;
|
||||||
|
color.R = (pgm_read_byte(p++)) << 1;
|
||||||
|
color.G = (pgm_read_byte(p)) << 1;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
65
src/internal/features/Lpd8806GrbFeature.h
Normal file
65
src/internal/features/Lpd8806GrbFeature.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Lpd8806GrbFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with DotStar like chips
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class Lpd8806GrbFeature : public Neo3ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = (color.G >> 1) | 0x80;
|
||||||
|
*p++ = (color.R >> 1) | 0x80;
|
||||||
|
*p = (color.B >> 1) | 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.G = (*p++) << 1;
|
||||||
|
color.R = (*p++) << 1;
|
||||||
|
color.B = (*p) << 1;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.G = (pgm_read_byte(p++)) << 1;
|
||||||
|
color.R = (pgm_read_byte(p++)) << 1;
|
||||||
|
color.B = (pgm_read_byte(p)) << 1;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
@@ -1,6 +1,6 @@
|
|||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
Lpd8806ColorFeatures provides feature classes to describe color order and
|
Neo2ByteElements provides feature base classes to describe color elements
|
||||||
color depth for NeoPixelBus template class when used with DotStar like chips
|
for NeoPixelBus Color Feature template classes
|
||||||
|
|
||||||
Written by Michael C. Miller.
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
@@ -26,7 +26,81 @@ License along with NeoPixel. If not, see
|
|||||||
-------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class Lpd88063ElementsNoSettings
|
class Neo2ByteElements
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const size_t PixelSize = 2; // 1 bit + 555 encoded elements
|
||||||
|
|
||||||
|
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
return pPixels + indexPixel * PixelSize;
|
||||||
|
}
|
||||||
|
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
return pPixels + indexPixel * PixelSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||||
|
{
|
||||||
|
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||||
|
while (pPixelDest < pEnd)
|
||||||
|
{
|
||||||
|
for (uint8_t iElement = 0; iElement < PixelSize; iElement++)
|
||||||
|
{
|
||||||
|
*pPixelDest++ = pPixelSrc[iElement];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||||
|
{
|
||||||
|
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||||
|
while (pPixelDest < pEnd)
|
||||||
|
{
|
||||||
|
*pPixelDest++ = *pPixelSrc++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
||||||
|
{
|
||||||
|
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
||||||
|
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
||||||
|
while (pPixelDest < pEnd)
|
||||||
|
{
|
||||||
|
*pPixelDest++ = pgm_read_byte(pSrc++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
||||||
|
{
|
||||||
|
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
||||||
|
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
||||||
|
while (pDestBack > pPixelDest)
|
||||||
|
{
|
||||||
|
*--pDestBack = *--pSrcBack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef RgbColor ColorObject;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void encodePixel(uint8_t c1, uint8_t c2, uint8_t c3, uint16_t* color555)
|
||||||
|
{
|
||||||
|
*color555 = (0x8000 |
|
||||||
|
((c1 & 0xf8) << 7) |
|
||||||
|
((c2 & 0xf8) << 2) |
|
||||||
|
((c3 & 0xf8) >> 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void decodePixel(uint16_t color555, uint8_t* c1, uint8_t* c2, uint8_t* c3)
|
||||||
|
{
|
||||||
|
*c1 = (color555 >> 7) & 0xf8;
|
||||||
|
*c2 = (color555 >> 2) & 0xf8;
|
||||||
|
*c3 = (color555 << 3) & 0xf8;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Neo2ByteElementsNoSettings : public Neo2ByteElements
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef NeoNoSettings SettingsObject;
|
typedef NeoNoSettings SettingsObject;
|
||||||
@@ -45,145 +119,4 @@ public:
|
|||||||
{
|
{
|
||||||
return pData;
|
return pData;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Lpd88063Elements : public Lpd88063ElementsNoSettings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const size_t PixelSize = 3;
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t* getPixelAddress(uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
static const uint8_t* getPixelAddress(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
return pPixels + indexPixel * PixelSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void replicatePixel(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = pPixelSrc[0];
|
|
||||||
*pPixelDest++ = pPixelSrc[1];
|
|
||||||
*pPixelDest++ = pPixelSrc[2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsInc(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
*pPixelDest++ = *pPixelSrc++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsInc_P(uint8_t* pPixelDest, PGM_VOID_P pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pEnd = pPixelDest + (count * PixelSize);
|
|
||||||
const uint8_t* pSrc = (const uint8_t*)pPixelSrc;
|
|
||||||
while (pPixelDest < pEnd)
|
|
||||||
{
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
*pPixelDest++ = pgm_read_byte(pSrc++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void movePixelsDec(uint8_t* pPixelDest, const uint8_t* pPixelSrc, uint16_t count)
|
|
||||||
{
|
|
||||||
uint8_t* pDestBack = pPixelDest + (count * PixelSize);
|
|
||||||
const uint8_t* pSrcBack = pPixelSrc + (count * PixelSize);
|
|
||||||
while (pDestBack > pPixelDest)
|
|
||||||
{
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
*--pDestBack = *--pSrcBack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef RgbColor ColorObject;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Lpd8806BrgFeature : public Lpd88063Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = (color.B >> 1) | 0x80;
|
|
||||||
*p++ = (color.R >> 1) | 0x80;
|
|
||||||
*p = (color.G >> 1) | 0x80;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.B = (*p++) << 1;
|
|
||||||
color.R = (*p++) << 1;
|
|
||||||
color.G = (*p) << 1;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.B = (pgm_read_byte(p++)) << 1;
|
|
||||||
color.R = (pgm_read_byte(p++)) << 1;
|
|
||||||
color.G = (pgm_read_byte(p)) << 1;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class Lpd8806GrbFeature : public Lpd88063Elements
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
|
||||||
{
|
|
||||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
*p++ = (color.G >> 1) | 0x80;
|
|
||||||
*p++ = (color.R >> 1) | 0x80;
|
|
||||||
*p = (color.B >> 1) | 0x80;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.G = (*p++) << 1;
|
|
||||||
color.R = (*p++) << 1;
|
|
||||||
color.B = (*p) << 1;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
|
||||||
{
|
|
||||||
ColorObject color;
|
|
||||||
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
|
||||||
|
|
||||||
color.G = (pgm_read_byte(p++)) << 1;
|
|
||||||
color.R = (pgm_read_byte(p++)) << 1;
|
|
||||||
color.B = (pgm_read_byte(p)) << 1;
|
|
||||||
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
110
src/internal/features/Neo3ByteElements.h
Normal file
110
src/internal/features/Neo3ByteElements.h
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Neo3ByteElements provides feature base classes to describe color elements
|
||||||
|
for NeoPixelBus Color Feature template classes
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<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;
|
||||||
|
}
|
||||||
|
};
|
125
src/internal/features/Neo4ByteElements.h
Normal file
125
src/internal/features/Neo4ByteElements.h
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Neo4ByteElements provides feature base classes to describe color elements
|
||||||
|
for NeoPixelBus Color Feature template classes
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<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;
|
||||||
|
}
|
||||||
|
};
|
115
src/internal/features/Neo6ByteElements.h
Normal file
115
src/internal/features/Neo6ByteElements.h
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Neo6ByteElements provides feature base classes to describe color elements
|
||||||
|
for NeoPixelBus Color Feature template classes
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<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;
|
||||||
|
}
|
||||||
|
};
|
115
src/internal/features/Neo8ByteElements.h
Normal file
115
src/internal/features/Neo8ByteElements.h
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Neo8ByteElements provides feature base classes to describe color elements
|
||||||
|
for NeoPixelBus Color Feature template classes
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<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;
|
||||||
|
}
|
||||||
|
};
|
106
src/internal/features/Neo9ByteElements.h
Normal file
106
src/internal/features/Neo9ByteElements.h
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
Neo9ByteElements provides feature base classes to describe color elements
|
||||||
|
for NeoPixelBus Color Feature template classes
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<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;
|
||||||
|
}
|
||||||
|
};
|
70
src/internal/features/NeoAbcdefgpsSegmentFeature.h
Normal file
70
src/internal/features/NeoAbcdefgpsSegmentFeature.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoAbcdefgpsSegmentFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with seven segment display
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Abcdefgps byte order
|
||||||
|
class NeoAbcdefgpsSegmentFeature : public Neo9ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count;
|
||||||
|
for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++)
|
||||||
|
{
|
||||||
|
*p++ = color.Segment[iSegment];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count;
|
||||||
|
|
||||||
|
for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++)
|
||||||
|
{
|
||||||
|
color.Segment[iSegment] = *p++;
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
uint8_t commonSize = (PixelSize < color.Count) ? PixelSize : color.Count;
|
||||||
|
|
||||||
|
for (uint8_t iSegment = 0; iSegment < commonSize; iSegment++)
|
||||||
|
{
|
||||||
|
color.Segment[iSegment] = pgm_read_byte(p++);
|
||||||
|
}
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
91
src/internal/features/NeoBacedfpgsSegmentFeature.h
Normal file
91
src/internal/features/NeoBacedfpgsSegmentFeature.h
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoBacedfpgsSegmentFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with seven segment display
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// BACEDF.G+ byte order
|
||||||
|
class NeoBacedfpgsSegmentFeature : public Neo9ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
// Segment Digit is Abcdefgps order
|
||||||
|
*p++ = color.Segment[LedSegment_B];
|
||||||
|
*p++ = color.Segment[LedSegment_A];
|
||||||
|
*p++ = color.Segment[LedSegment_C];
|
||||||
|
|
||||||
|
*p++ = color.Segment[LedSegment_E];
|
||||||
|
*p++ = color.Segment[LedSegment_D];
|
||||||
|
*p++ = color.Segment[LedSegment_F];
|
||||||
|
|
||||||
|
*p++ = color.Segment[LedSegment_Decimal];
|
||||||
|
*p++ = color.Segment[LedSegment_G];
|
||||||
|
*p++ = color.Segment[LedSegment_Custom];
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.Segment[LedSegment_B] = *p++;
|
||||||
|
color.Segment[LedSegment_A] = *p++;
|
||||||
|
color.Segment[LedSegment_C] = *p++;
|
||||||
|
|
||||||
|
color.Segment[LedSegment_E] = *p++;
|
||||||
|
color.Segment[LedSegment_D] = *p++;
|
||||||
|
color.Segment[LedSegment_F] = *p++;
|
||||||
|
|
||||||
|
color.Segment[LedSegment_Decimal] = *p++;
|
||||||
|
color.Segment[LedSegment_G] = *p++;
|
||||||
|
color.Segment[LedSegment_Custom] = *p++;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.Segment[LedSegment_B] = pgm_read_byte(p++);
|
||||||
|
color.Segment[LedSegment_A] = pgm_read_byte(p++);
|
||||||
|
color.Segment[LedSegment_C] = pgm_read_byte(p++);
|
||||||
|
|
||||||
|
color.Segment[LedSegment_E] = pgm_read_byte(p++);
|
||||||
|
color.Segment[LedSegment_D] = pgm_read_byte(p++);
|
||||||
|
color.Segment[LedSegment_F] = pgm_read_byte(p++);
|
||||||
|
|
||||||
|
color.Segment[LedSegment_Decimal] = pgm_read_byte(p++);
|
||||||
|
color.Segment[LedSegment_G] = pgm_read_byte(p++);
|
||||||
|
color.Segment[LedSegment_Custom] = pgm_read_byte(p++);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
66
src/internal/features/NeoBgrFeature.h
Normal file
66
src/internal/features/NeoBgrFeature.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoBgrFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class NeoBgrFeature : public Neo3ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = color.B;
|
||||||
|
*p++ = color.G;
|
||||||
|
*p = color.R;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.B = *p++;
|
||||||
|
color.G = *p++;
|
||||||
|
color.R = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel);
|
||||||
|
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
};
|
64
src/internal/features/NeoBrgFeature.h
Normal file
64
src/internal/features/NeoBrgFeature.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoBrgFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class NeoBrgFeature : public Neo3ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = color.B;
|
||||||
|
*p++ = color.R;
|
||||||
|
*p = color.G;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.B = *p++;
|
||||||
|
color.R = *p++;
|
||||||
|
color.G = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel);
|
||||||
|
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
};
|
64
src/internal/features/NeoGrb48Feature.h
Normal file
64
src/internal/features/NeoGrb48Feature.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoGrb48Feature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class NeoGrb48Feature : public Neo6ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint16_t* p = reinterpret_cast<uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
||||||
|
|
||||||
|
*p++ = color.G;
|
||||||
|
*p++ = color.R;
|
||||||
|
*p = color.B;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
||||||
|
|
||||||
|
color.G = *p++;
|
||||||
|
color.R = *p++;
|
||||||
|
color.B = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel));
|
||||||
|
|
||||||
|
color.G = pgm_read_word(p++);
|
||||||
|
color.R = pgm_read_word(p++);
|
||||||
|
color.B = pgm_read_word(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
};
|
64
src/internal/features/NeoGrbFeature.h
Normal file
64
src/internal/features/NeoGrbFeature.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoGrbFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class NeoGrbFeature : public Neo3ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = color.G;
|
||||||
|
*p++ = color.R;
|
||||||
|
*p = color.B;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.G = *p++;
|
||||||
|
color.R = *p++;
|
||||||
|
color.B = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(reinterpret_cast<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;
|
||||||
|
}
|
||||||
|
};
|
68
src/internal/features/NeoGrbwFeature.h
Normal file
68
src/internal/features/NeoGrbwFeature.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoGrbwFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class NeoGrbwFeature : public Neo4ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = color.G;
|
||||||
|
*p++ = color.R;
|
||||||
|
*p++ = color.B;
|
||||||
|
*p = color.W;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.G = *p++;
|
||||||
|
color.R = *p++;
|
||||||
|
color.B = *p++;
|
||||||
|
color.W = *p;
|
||||||
|
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(reinterpret_cast<const uint8_t*>(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;
|
||||||
|
}
|
||||||
|
};
|
66
src/internal/features/NeoRbgFeature.h
Normal file
66
src/internal/features/NeoRbgFeature.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoRbgFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class NeoRbgFeature : public Neo3ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = color.R;
|
||||||
|
*p++ = color.B;
|
||||||
|
*p = color.G;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.R = *p++;
|
||||||
|
color.B = *p++;
|
||||||
|
color.G = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel);
|
||||||
|
|
||||||
|
color.R = pgm_read_byte(p++);
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
};
|
64
src/internal/features/NeoRgb48Feature.h
Normal file
64
src/internal/features/NeoRgb48Feature.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoRgb48Feature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class NeoRgb48Feature : public Neo6ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint16_t* p = reinterpret_cast<uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
||||||
|
|
||||||
|
*p++ = color.R;
|
||||||
|
*p++ = color.G;
|
||||||
|
*p = color.B;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
||||||
|
|
||||||
|
color.R = *p++;
|
||||||
|
color.G = *p++;
|
||||||
|
color.B = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel));
|
||||||
|
|
||||||
|
color.R = pgm_read_word(p++);
|
||||||
|
color.G = pgm_read_word(p++);
|
||||||
|
color.B = pgm_read_word(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
};
|
64
src/internal/features/NeoRgbFeature.h
Normal file
64
src/internal/features/NeoRgbFeature.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoRgbFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class NeoRgbFeature : public Neo3ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = color.R;
|
||||||
|
*p++ = color.G;
|
||||||
|
*p = color.B;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.R = *p++;
|
||||||
|
color.G = *p++;
|
||||||
|
color.B = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(reinterpret_cast<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;
|
||||||
|
}
|
||||||
|
};
|
68
src/internal/features/NeoRgbw64Feature.h
Normal file
68
src/internal/features/NeoRgbw64Feature.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoRgbw64Feature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class NeoRgbw64Feature : public Neo8ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint16_t* p = reinterpret_cast<uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
||||||
|
|
||||||
|
*p++ = color.R;
|
||||||
|
*p++ = color.G;
|
||||||
|
*p++ = color.B;
|
||||||
|
*p = color.W;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(pPixels, indexPixel));
|
||||||
|
|
||||||
|
color.R = *p++;
|
||||||
|
color.G = *p++;
|
||||||
|
color.B = *p++;
|
||||||
|
color.W = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint16_t* p = reinterpret_cast<const uint16_t*>(getPixelAddress(reinterpret_cast<const uint8_t*>(pPixels), indexPixel));
|
||||||
|
|
||||||
|
color.R = pgm_read_word(p++);
|
||||||
|
color.G = pgm_read_word(p++);
|
||||||
|
color.B = pgm_read_word(p++);
|
||||||
|
color.W = pgm_read_word(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
};
|
67
src/internal/features/NeoRgbwFeature.h
Normal file
67
src/internal/features/NeoRgbwFeature.h
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
NeoRgbwFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class NeoRgbwFeature : public Neo4ByteElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = color.R;
|
||||||
|
*p++ = color.G;
|
||||||
|
*p++ = color.B;
|
||||||
|
*p = color.W;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
color.R = *p++;
|
||||||
|
color.G = *p++;
|
||||||
|
color.B = *p++;
|
||||||
|
color.W = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(reinterpret_cast<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;
|
||||||
|
}
|
||||||
|
};
|
75
src/internal/features/P9813BgrFeature.h
Normal file
75
src/internal/features/P9813BgrFeature.h
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
P9813BgrFeature provides feature classes to describe color order and
|
||||||
|
color depth for NeoPixelBus template class when used with P9813s
|
||||||
|
|
||||||
|
Written by Michael C. Miller.
|
||||||
|
|
||||||
|
I invest time and resources providing this open source code,
|
||||||
|
please support me by dontating (see https://github.com/Makuna/NeoPixelBus)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------
|
||||||
|
This file is part of the Makuna/NeoPixelBus library.
|
||||||
|
|
||||||
|
NeoPixelBus is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
NeoPixelBus is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with NeoPixel. If not, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
-------------------------------------------------------------------------*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
class P9813BgrFeature : public DotStar3ElementsNoSettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||||
|
{
|
||||||
|
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
*p++ = 0xC0 | ((~color.B & 0xC0) >> 2) | ((~color.G & 0xC0) >> 4) | ((~color.R & 0xC0) >> 6);
|
||||||
|
*p++ = color.B;
|
||||||
|
*p++ = color.G;
|
||||||
|
*p = color.R;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||||
|
|
||||||
|
p++; // ignore the first byte
|
||||||
|
color.B = *p++;
|
||||||
|
color.G = *p++;
|
||||||
|
color.R = *p;
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ColorObject retrievePixelColor_P(PGM_VOID_P pPixels, uint16_t indexPixel)
|
||||||
|
{
|
||||||
|
ColorObject color;
|
||||||
|
const uint8_t* p = getPixelAddress((const uint8_t*)pPixels, indexPixel);
|
||||||
|
|
||||||
|
pgm_read_byte(p++); // ignore the first byte
|
||||||
|
color.B = pgm_read_byte(p++);
|
||||||
|
color.G = pgm_read_byte(p++);
|
||||||
|
color.R = pgm_read_byte(p);
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user