mirror of
https://github.com/Makuna/NeoPixelBus.git
synced 2025-08-07 04:44:26 +02:00
Merge and Corrections
This commit is contained in:
@@ -67,7 +67,7 @@ static uint32_t getEspCycleCount(void)
|
|||||||
{
|
{
|
||||||
uint32_t ccount;
|
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));
|
__asm__ __volatile__("csrr %0,0x7e2":"=r" (ccount));
|
||||||
//ccount = esp_cpu_get_ccount();
|
//ccount = esp_cpu_get_ccount();
|
||||||
#else
|
#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>
|
template <uint8_t V_IC_1, uint8_t V_IC_2, uint8_t V_IC_3>
|
||||||
class DotStarL4ByteFeature :
|
class DotStarL4ByteFeature :
|
||||||
public NeoByteElements<4, RgbwColor, uint32_t>
|
public NeoElementsBase<4, RgbwColor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void applyPixelColor(uint8_t* pixel, size_t pixelSize, ColorObject color)
|
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>
|
template <uint8_t V_IC_1, uint8_t V_IC_2, uint8_t V_IC_3>
|
||||||
class DotStarL4WordFeature :
|
class DotStarL4WordFeature :
|
||||||
public NeoWordElements<8, Rgbw64Color, uint32_t>
|
public NeoElementsBase<8, Rgbw64Color>
|
||||||
{
|
{
|
||||||
public:
|
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
|
// upper bit is always 1 and three 5 bit brightness
|
||||||
// {1}{5}{5}{5}
|
// {1}{5}{5}{5}
|
||||||
// 1rrr rrgg gggb bbbb
|
// 1rrr rrgg gggb bbbb
|
||||||
*p++ = 0x80 | (brightness << 2) | (brightness > 3);
|
*p++ = 0x80 | (brightness << 2) | (brightness > 3);
|
||||||
*p++ = (brightness << 5) | (brightness);
|
*p++ = (brightness << 5) | (brightness);
|
||||||
|
|
||||||
// due to endianness the byte order must be copied to output
|
// due to endianness the byte order must be copied to output
|
||||||
*p++ = color[V_IC_1] >> 8;
|
*p++ = color[V_IC_1] >> 8;
|
||||||
*p++ = color[V_IC_1] & 0xff;
|
*p++ = color[V_IC_1] & 0xff;
|
||||||
*p++ = color[V_IC_2] >> 8;
|
*p++ = color[V_IC_2] >> 8;
|
||||||
*p++ = color[V_IC_2] & 0xff;
|
*p++ = color[V_IC_2] & 0xff;
|
||||||
*p++ = color[V_IC_3] >> 8;
|
*p++ = color[V_IC_3] >> 8;
|
||||||
*p = color[V_IC_3] & 0xff;
|
*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>
|
template <uint8_t V_IC_1, uint8_t V_IC_2, uint8_t V_IC_3>
|
||||||
class DotStarX4ByteFeature :
|
class DotStarX4ByteFeature :
|
||||||
public NeoByteElements<4, RgbColor, uint32_t>
|
public NeoElementsBase<4, RgbColor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void applyPixelColor(uint8_t* pixel, size_t pixelSize, ColorObject color)
|
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>
|
template <uint8_t V_IC_1, uint8_t V_IC_2, uint8_t V_IC_3>
|
||||||
class DotStarX4WordFeature :
|
class DotStarX4WordFeature :
|
||||||
public NeoWordElements<8, Rgb48Color, uint32_t>
|
public NeoElementsBase<8, Rgb48Color>
|
||||||
{
|
{
|
||||||
public:
|
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; // upper bit is always 1 and three 5 bit brightness at max
|
||||||
*p++ = 0xff; // {1}{5}{5}{5}
|
*p++ = 0xff; // {1}{5}{5}{5}
|
||||||
// due to endianness the byte order must be copied to output
|
// due to endianness the byte order must be copied to output
|
||||||
*p++ = color[V_IC_1] >> 8;
|
*p++ = color[V_IC_1] >> 8;
|
||||||
*p++ = color[V_IC_1] & 0xff;
|
*p++ = color[V_IC_1] & 0xff;
|
||||||
*p++ = color[V_IC_2] >> 8;
|
*p++ = color[V_IC_2] >> 8;
|
||||||
*p++ = color[V_IC_2] & 0xff;
|
*p++ = color[V_IC_2] & 0xff;
|
||||||
*p++ = color[V_IC_3] >> 8;
|
*p++ = color[V_IC_3] >> 8;
|
||||||
*p = color[V_IC_3] & 0xff;
|
*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) :
|
NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize) :
|
||||||
_pin(pin),
|
_pin(pin),
|
||||||
_sizeDataSending(pixelCount* elementSize + settingsSize),
|
_pixelCount(pixelCount),
|
||||||
_pixelCount(pixelCount)
|
_sizeDataSending(pixelCount * elementSize + settingsSize)
|
||||||
{
|
{
|
||||||
construct();
|
construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize, NeoBusChannel channel) :
|
NeoEsp32RmtMethodBase(uint8_t pin, uint16_t pixelCount, size_t elementSize, size_t settingsSize, NeoBusChannel channel) :
|
||||||
_pin(pin),
|
_pin(pin),
|
||||||
_sizeDataSending(pixelCount* elementSize + settingsSize),
|
|
||||||
_pixelCount(pixelCount),
|
_pixelCount(pixelCount),
|
||||||
|
_sizeDataSending(pixelCount * elementSize + settingsSize),
|
||||||
_channel(channel)
|
_channel(channel)
|
||||||
{
|
{
|
||||||
construct();
|
construct();
|
||||||
@@ -686,16 +686,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const uint8_t _pin; // output pin number
|
const uint8_t _pin; // output pin number
|
||||||
const uint16_t _pixelCount; // count of pixels in the strip
|
const uint16_t _pixelCount; // count of pixels in the strip
|
||||||
const size_t _sizeDataSending; // Size of '_data*' buffers
|
const size_t _sizeDataSending; // Size of '_data*' buffers
|
||||||
|
|
||||||
const T_CHANNEL _channel; // holds instance for multi channel support
|
const T_CHANNEL _channel; // holds instance for multi channel support
|
||||||
|
|
||||||
// Holds data stream which include LED color values and other settings as needed
|
// Holds data stream which include LED color values and other settings as needed
|
||||||
uint8_t* _dataSending; // used for async send using RMT
|
uint8_t* _dataSending; // used for async send using RMT
|
||||||
|
|
||||||
|
|
||||||
void construct()
|
void construct()
|
||||||
{
|
{
|
||||||
_dataSending = static_cast<uint8_t*>(malloc(_sizeDataSending));
|
_dataSending = static_cast<uint8_t*>(malloc(_sizeDataSending));
|
||||||
|
@@ -34,19 +34,6 @@ License along with NeoPixel. If not, see
|
|||||||
#include <soc/gpio_struct.h>
|
#include <soc/gpio_struct.h>
|
||||||
#endif
|
#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
|
// Interrupt lock class, used for RAII interrupt disabling
|
||||||
class InterruptLock
|
class InterruptLock
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user