forked from Makuna/NeoPixelBus
Color and Init (#425)
This commit is contained in:
@@ -29,6 +29,7 @@ DotStarLbgrFeature KEYWORD1
|
||||
Lpd6803GrbFeature KEYWORD1
|
||||
Lpd6803GbrFeature KEYWORD1
|
||||
Lpd6803BrgFeature KEYWORD1
|
||||
Lpd6803RgbFeature KEYWORD1
|
||||
Lpd8806GrbFeature KEYWORD1
|
||||
Lpd8806BrgFeature KEYWORD1
|
||||
P9813BgrFeature KEYWORD1
|
||||
|
@@ -103,10 +103,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
typedef RgbColor ColorObject;
|
||||
|
||||
|
||||
protected:
|
||||
static void encodePixel(uint8_t c1, uint8_t c2, uint8_t c3, uint16_t* color555)
|
||||
{
|
||||
*color555 = (0x8000 |
|
||||
@@ -121,6 +117,9 @@ protected:
|
||||
*c2 = (color555 >> 2) & 0xf8;
|
||||
*c3 = (color555 << 3) & 0xf8;
|
||||
}
|
||||
|
||||
|
||||
typedef RgbColor ColorObject;
|
||||
};
|
||||
|
||||
class Lpd6803BrgFeature : public Lpd68033Elements
|
||||
@@ -255,3 +254,48 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -43,7 +43,17 @@ public:
|
||||
_wire(pinClock, pinData)
|
||||
{
|
||||
_data = static_cast<uint8_t*>(malloc(_sizeData));
|
||||
memset(_data, 0, _sizeData);
|
||||
|
||||
// requires specific memory init
|
||||
memset(_data, 0, _sizeData); // is not good enough
|
||||
uint16_t* pPixel = reinterpret_cast<uint16_t*>(_data + settingsSize);
|
||||
uint16_t* pPixelEnd = pPixel + (_sizeData / elementSize);
|
||||
|
||||
while (pPixel < pPixelEnd)
|
||||
{
|
||||
Lpd68033Elements::encodePixel(0, 0, 0, pPixel);
|
||||
pPixel++;
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny)
|
||||
|
Reference in New Issue
Block a user