forked from Makuna/NeoPixelBus
Merge and Corrections
This commit is contained in:
@@ -67,7 +67,7 @@ static uint32_t getEspCycleCount(void)
|
||||
{
|
||||
uint32_t ccount;
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2)
|
||||
__asm__ __volatile__("csrr %0,0x7e2":"=r" (ccount));
|
||||
//ccount = esp_cpu_get_ccount();
|
||||
#else
|
||||
|
@@ -28,7 +28,7 @@ License along with NeoPixel. If not, see
|
||||
|
||||
template <uint8_t V_IC_1, uint8_t V_IC_2, uint8_t V_IC_3>
|
||||
class DotStarL4ByteFeature :
|
||||
public NeoByteElements<4, RgbwColor, uint32_t>
|
||||
public NeoElementsBase<4, RgbwColor>
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pixel, size_t pixelSize, ColorObject color)
|
||||
|
@@ -28,62 +28,30 @@ License along with NeoPixel. If not, see
|
||||
|
||||
template <uint8_t V_IC_1, uint8_t V_IC_2, uint8_t V_IC_3>
|
||||
class DotStarL4WordFeature :
|
||||
public NeoWordElements<8, Rgbw64Color, uint32_t>
|
||||
public NeoElementsBase<8, Rgbw64Color>
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
static void applyPixelColor(uint8_t* pixel, size_t pixelSize, ColorObject color)
|
||||
{
|
||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||
if (PixelSize <= pixelSize)
|
||||
{
|
||||
uint8_t* p = pixel;
|
||||
|
||||
uint8_t brightness = (color.W < 31 ? color.W : 31);
|
||||
uint8_t brightness = (color.W < 31 ? color.W : 31);
|
||||
|
||||
// upper bit is always 1 and three 5 bit brightness
|
||||
// {1}{5}{5}{5}
|
||||
// 1rrr rrgg gggb bbbb
|
||||
*p++ = 0x80 | (brightness << 2) | (brightness > 3);
|
||||
*p++ = (brightness << 5) | (brightness);
|
||||
// upper bit is always 1 and three 5 bit brightness
|
||||
// {1}{5}{5}{5}
|
||||
// 1rrr rrgg gggb bbbb
|
||||
*p++ = 0x80 | (brightness << 2) | (brightness > 3);
|
||||
*p++ = (brightness << 5) | (brightness);
|
||||
|
||||
// due to endianness the byte order must be copied to output
|
||||
*p++ = color[V_IC_1] >> 8;
|
||||
*p++ = color[V_IC_1] & 0xff;
|
||||
*p++ = color[V_IC_2] >> 8;
|
||||
*p++ = color[V_IC_2] & 0xff;
|
||||
*p++ = color[V_IC_3] >> 8;
|
||||
*p = color[V_IC_3] & 0xff;
|
||||
// due to endianness the byte order must be copied to output
|
||||
*p++ = color[V_IC_1] >> 8;
|
||||
*p++ = color[V_IC_1] & 0xff;
|
||||
*p++ = color[V_IC_2] >> 8;
|
||||
*p++ = color[V_IC_2] & 0xff;
|
||||
*p++ = color[V_IC_3] >> 8;
|
||||
*p = color[V_IC_3] & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
ColorObject color;
|
||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||
|
||||
p++; // ignore the first byte
|
||||
color.W = (*p++) & 0x1F; // mask out all but lower five bits
|
||||
|
||||
// due to endianness the byte order must be copied to output
|
||||
color[V_IC_1] = (static_cast<uint16_t>(*p++) << 8);
|
||||
color[V_IC_1] |= *p++;
|
||||
color[V_IC_2] = (static_cast<uint16_t>(*p++) << 8);
|
||||
color[V_IC_2] |= *p++;
|
||||
color[V_IC_3] = (static_cast<uint16_t>(*p++) << 8);
|
||||
color[V_IC_3] |= *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));
|
||||
|
||||
// PROGMEM unit of storage expected to be the same size as color element
|
||||
// so no endianness issues to worry about
|
||||
color.W = pgm_read_word(p++) & 0x001F; // mask out all but lower five bits
|
||||
color[V_IC_1] = pgm_read_word(p++);
|
||||
color[V_IC_2] = pgm_read_word(p++);
|
||||
color[V_IC_3] = pgm_read_word(p);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
};
|
||||
|
@@ -28,7 +28,7 @@ License along with NeoPixel. If not, see
|
||||
|
||||
template <uint8_t V_IC_1, uint8_t V_IC_2, uint8_t V_IC_3>
|
||||
class DotStarX4ByteFeature :
|
||||
public NeoByteElements<4, RgbColor, uint32_t>
|
||||
public NeoElementsBase<4, RgbColor>
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pixel, size_t pixelSize, ColorObject color)
|
||||
|
@@ -28,56 +28,24 @@ License along with NeoPixel. If not, see
|
||||
|
||||
template <uint8_t V_IC_1, uint8_t V_IC_2, uint8_t V_IC_3>
|
||||
class DotStarX4WordFeature :
|
||||
public NeoWordElements<8, Rgb48Color, uint32_t>
|
||||
public NeoElementsBase<8, Rgb48Color>
|
||||
{
|
||||
public:
|
||||
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
|
||||
static void applyPixelColor(uint8_t* pixel, uint16_t pixelSize, ColorObject color)
|
||||
{
|
||||
uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||
if (PixelSize <= pixelSize)
|
||||
{
|
||||
uint8_t* p = pixel;
|
||||
|
||||
*p++ = 0xff; // upper bit is always 1 and three 5 bit brightness at max
|
||||
*p++ = 0xff; // {1}{5}{5}{5}
|
||||
// due to endianness the byte order must be copied to output
|
||||
*p++ = color[V_IC_1] >> 8;
|
||||
*p++ = color[V_IC_1] & 0xff;
|
||||
*p++ = color[V_IC_2] >> 8;
|
||||
*p++ = color[V_IC_2] & 0xff;
|
||||
*p++ = color[V_IC_3] >> 8;
|
||||
*p = color[V_IC_3] & 0xff;
|
||||
*p++ = 0xff; // upper bit is always 1 and three 5 bit brightness at max
|
||||
*p++ = 0xff; // {1}{5}{5}{5}
|
||||
// due to endianness the byte order must be copied to output
|
||||
*p++ = color[V_IC_1] >> 8;
|
||||
*p++ = color[V_IC_1] & 0xff;
|
||||
*p++ = color[V_IC_2] >> 8;
|
||||
*p++ = color[V_IC_2] & 0xff;
|
||||
*p++ = color[V_IC_3] >> 8;
|
||||
*p = color[V_IC_3] & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
static ColorObject retrievePixelColor(const uint8_t* pPixels, uint16_t indexPixel)
|
||||
{
|
||||
ColorObject color;
|
||||
const uint8_t* p = getPixelAddress(pPixels, indexPixel);
|
||||
|
||||
p++; // ignore the first two bytes
|
||||
p++;
|
||||
|
||||
// due to endianness the byte order must be copied to output
|
||||
color[V_IC_1] = (static_cast<uint16_t>(*p++) << 8);
|
||||
color[V_IC_1] |= *p++;
|
||||
color[V_IC_2] = (static_cast<uint16_t>(*p++) << 8);
|
||||
color[V_IC_2] |= *p++;
|
||||
color[V_IC_3] = (static_cast<uint16_t>(*p++) << 8);
|
||||
color[V_IC_3] |= *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));
|
||||
|
||||
// PROGMEM unit of storage expected to be the same size as color element
|
||||
// so no endianness issues to worry about
|
||||
p++; // ignore the first word
|
||||
color[V_IC_1] = pgm_read_word(p++);
|
||||
color[V_IC_2] = pgm_read_word(p++);
|
||||
color[V_IC_3] = pgm_read_word(p);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
};
|
||||
|
@@ -566,16 +566,16 @@ public:
|
||||
|
||||
NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) :
|
||||
_pin(pin),
|
||||
_sizeDataSending(pixelCount* elementSize + settingsSize),
|
||||
_pixelCount(pixelCount)
|
||||
_pixelCount(pixelCount),
|
||||
_sizeDataSending(pixelCount * elementSize + settingsSize)
|
||||
{
|
||||
construct();
|
||||
}
|
||||
|
||||
NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize, NeoBusChannel channel) :
|
||||
_pin(pin),
|
||||
_sizeDataSending(pixelCount* elementSize + settingsSize),
|
||||
_pixelCount(pixelCount),
|
||||
_sizeDataSending(pixelCount * elementSize + settingsSize),
|
||||
_channel(channel)
|
||||
{
|
||||
construct();
|
||||
@@ -686,16 +686,15 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const uint8_t _pin; // output pin number
|
||||
const uint16_t _pixelCount; // count of pixels in the strip
|
||||
const size_t _sizeDataSending; // Size of '_data*' buffers
|
||||
const uint8_t _pin; // output pin number
|
||||
const uint16_t _pixelCount; // count of pixels in the strip
|
||||
const size_t _sizeDataSending; // Size of '_data*' buffers
|
||||
|
||||
const T_CHANNEL _channel; // holds instance for multi channel support
|
||||
|
||||
// Holds data stream which include LED color values and other settings as needed
|
||||
uint8_t* _dataSending; // used for async send using RMT
|
||||
|
||||
|
||||
void construct()
|
||||
{
|
||||
_dataSending = static_cast<uint8_t*>(malloc(_sizeDataSending));
|
||||
|
@@ -34,19 +34,6 @@ License along with NeoPixel. If not, see
|
||||
#include <soc/gpio_struct.h>
|
||||
#endif
|
||||
|
||||
static inline uint32_t getCycleCount(void)
|
||||
{
|
||||
uint32_t ccount;
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32H2)
|
||||
__asm__ __volatile__("csrr %0,0x7e2":"=r" (ccount));
|
||||
//ccount = esp_cpu_get_ccount();
|
||||
#else
|
||||
__asm__ __volatile__("rsr %0,ccount":"=a" (ccount));
|
||||
#endif
|
||||
return ccount;
|
||||
}
|
||||
|
||||
// Interrupt lock class, used for RAII interrupt disabling
|
||||
class InterruptLock
|
||||
{
|
||||
|
Reference in New Issue
Block a user