This commit is contained in:
Michael Miller
2024-04-23 08:44:56 -07:00
committed by GitHub
parent b8f33709aa
commit 2e88d03c4e
9 changed files with 384 additions and 19 deletions

View File

@@ -37,8 +37,6 @@ License along with NeoPixel. If not, see
#include "features/Neo3Byte777Feature.h"
#include "features/Neo4ByteFeature.h"
#include "features/Neo5ByteFeature.h"
#include "features/DotStarX4ByteFeature.h"
#include "features/DotStarL4ByteFeature.h"
#include "features/Neo6ByteFeature.h"
#include "features/Neo6xByteFeature.h"
#include "features/Neo6xxByteFeature.h"
@@ -46,6 +44,11 @@ License along with NeoPixel. If not, see
#include "features/Neo4WordFeature.h"
#include "features/Neo5WordFeature.h"
#include "features/DotStarX4ByteFeature.h"
#include "features/DotStarL4ByteFeature.h"
#include "features/DotStarX4WordFeature.h"
#include "features/DotStarL4WordFeature.h"
// NeoPixel Features
//
#include "features/NeoRgbFeatures.h"

View File

@@ -37,6 +37,7 @@ License along with NeoPixel. If not, see
#include "methods/Tlc59711GenericMethod.h"
#include "methods/Sm16716GenericMethod.h"
#include "methods/Mbi6033GenericMethod.h"
#include "methods/Hd108GenericMethod.h"
//Adafruit Pixie via UART, not platform specific
//

View File

@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------
DotStarL4Feature provides feature base class to describe color order for
DotStarL4ByteFeature provides feature base class to describe color order for
3 color but 4 byte features when used with DotStars, exposing Luminance as W
Written by Michael C. Miller.
@@ -27,7 +27,7 @@ License along with NeoPixel. If not, see
#pragma once
template <uint8_t V_IC_1, uint8_t V_IC_2, uint8_t V_IC_3>
class DotStarL4Feature :
class DotStarL4ByteFeature :
public NeoByteElements<4, RgbwColor, uint32_t>
{
public:

View File

@@ -0,0 +1,89 @@
/*-------------------------------------------------------------------------
DotStarL4WordFeature provides feature base class to describe color order for
3 color but 4 byte features when used with DotStars, exposing Luminance as W
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
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:
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
{
uint8_t* p = getPixelAddress(pPixels, indexPixel);
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);
// 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;
}
};

View File

@@ -26,40 +26,51 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/
#pragma once
// Byte features
class DotStarLrgbFeature :
public DotStarL4Feature<ColorIndexR, ColorIndexG, ColorIndexB>,
public DotStarL4ByteFeature<ColorIndexR, ColorIndexG, ColorIndexB>,
public NeoElementsNoSettings
{
};
class DotStarLrbgFeature :
public DotStarL4Feature<ColorIndexR, ColorIndexB, ColorIndexG>,
public DotStarL4ByteFeature<ColorIndexR, ColorIndexB, ColorIndexG>,
public NeoElementsNoSettings
{
};
class DotStarLgrbFeature :
public DotStarL4Feature<ColorIndexG, ColorIndexR, ColorIndexB>,
public DotStarL4ByteFeature<ColorIndexG, ColorIndexR, ColorIndexB>,
public NeoElementsNoSettings
{
};
class DotStarLgbrFeature :
public DotStarL4Feature<ColorIndexG, ColorIndexB, ColorIndexR>,
public DotStarL4ByteFeature<ColorIndexG, ColorIndexB, ColorIndexR>,
public NeoElementsNoSettings
{
};
class DotStarLbrgFeature :
public DotStarL4Feature<ColorIndexB, ColorIndexR, ColorIndexG>,
public DotStarL4ByteFeature<ColorIndexB, ColorIndexR, ColorIndexG>,
public NeoElementsNoSettings
{
};
class DotStarLbgrFeature :
public DotStarL4Feature<ColorIndexB, ColorIndexG, ColorIndexR>,
public DotStarL4ByteFeature<ColorIndexB, ColorIndexG, ColorIndexR>,
public NeoElementsNoSettings
{
};
};
// Word features
class DotStarLbgr64Feature :
public DotStarL4WordFeature<ColorIndexB, ColorIndexG, ColorIndexR>,
public NeoElementsNoSettings
{
};
typedef DotStarLbgr64Feature Hd108LbgrFeature;

View File

@@ -26,40 +26,52 @@ License along with NeoPixel. If not, see
-------------------------------------------------------------------------*/
#pragma once
// Byte features
class DotStarRgbFeature :
public DotStarX4Feature<ColorIndexR, ColorIndexG, ColorIndexB>,
public DotStarX4ByteFeature<ColorIndexR, ColorIndexG, ColorIndexB>,
public NeoElementsNoSettings
{
};
class DotStarRbgFeature :
public DotStarX4Feature<ColorIndexR, ColorIndexB, ColorIndexG>,
public DotStarX4ByteFeature<ColorIndexR, ColorIndexB, ColorIndexG>,
public NeoElementsNoSettings
{
};
class DotStarGbrFeature :
public DotStarX4Feature<ColorIndexG, ColorIndexB, ColorIndexR>,
public DotStarX4ByteFeature<ColorIndexG, ColorIndexB, ColorIndexR>,
public NeoElementsNoSettings
{
};
class DotStarGrbFeature :
public DotStarX4Feature<ColorIndexG, ColorIndexR, ColorIndexB>,
public DotStarX4ByteFeature<ColorIndexG, ColorIndexR, ColorIndexB>,
public NeoElementsNoSettings
{
};
class DotStarBrgFeature :
public DotStarX4Feature<ColorIndexB, ColorIndexR, ColorIndexG>,
public DotStarX4ByteFeature<ColorIndexB, ColorIndexR, ColorIndexG>,
public NeoElementsNoSettings
{
};
class DotStarBgrFeature :
public DotStarX4Feature<ColorIndexB, ColorIndexG, ColorIndexR>,
public DotStarX4ByteFeature<ColorIndexB, ColorIndexG, ColorIndexR>,
public NeoElementsNoSettings
{
};
// Word features
class DotStarBgr48Feature :
public DotStarX4WordFeature<ColorIndexB, ColorIndexG, ColorIndexR>,
public NeoElementsNoSettings
{
};
typedef DotStarBgr48Feature Hd108BgrFeature;

View File

@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------
DotStarX4Feature provides feature base class to describe color order for
DotStarX4ByteFeature provides feature base class to describe color order for
3 color but 4 byte features when used with DotStars
Written by Michael C. Miller.
@@ -27,7 +27,7 @@ License along with NeoPixel. If not, see
#pragma once
template <uint8_t V_IC_1, uint8_t V_IC_2, uint8_t V_IC_3>
class DotStarX4Feature :
class DotStarX4ByteFeature :
public NeoByteElements<4, RgbColor, uint32_t>
{
public:

View File

@@ -0,0 +1,83 @@
/*-------------------------------------------------------------------------
DotStarX4WordFeature provides feature base class to describe color order for
3 color but 4 byte features 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
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:
static void applyPixelColor(uint8_t* pPixels, uint16_t indexPixel, ColorObject color)
{
uint8_t* p = getPixelAddress(pPixels, indexPixel);
*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;
}
};

View File

@@ -0,0 +1,166 @@
/*-------------------------------------------------------------------------
NeoPixel library helper functions for HD108 using general Pins.
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
// must also check for arm due to Teensy incorrectly having ARDUINO_ARCH_AVR set
#if defined(ARDUINO_ARCH_AVR) && !defined(__arm__)
#include "TwoWireBitBangImpleAvr.h"
#else
#include "TwoWireBitBangImple.h"
#endif
template<typename T_TWOWIRE> class Hd108MethodBase
{
public:
typedef typename T_TWOWIRE::SettingsObject SettingsObject;
Hd108MethodBase(uint8_t pinClock, uint8_t pinData, uint16_t pixelCount, size_t elementSize, size_t settingsSize) :
_sizeData(pixelCount * elementSize + settingsSize),
_wire(pinClock, pinData)
{
_data = static_cast<uint8_t*>(malloc(_sizeData));
// data cleared later in Begin()
}
#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny)
Hd108MethodBase(uint16_t pixelCount, size_t elementSize, size_t settingsSize) :
Hd108MethodBase(SCK, MOSI, pixelCount, elementSize, settingsSize)
{
}
#endif
~Hd108MethodBase()
{
free(_data);
}
bool IsReadyToUpdate() const
{
return true; // dot stars don't have a required delay
}
#if defined(ARDUINO_ARCH_ESP32)
void Initialize(int8_t sck, int8_t miso, int8_t mosi, int8_t ss)
{
_wire.begin(sck, miso, mosi, ss);
}
#endif
void Initialize()
{
_wire.begin();
}
void Update(bool)
{
const uint8_t startFrame[4] = { 0x00 };
const uint8_t endFrame[4] = { 0xff };
_wire.beginTransaction();
// start frame
_wire.transmitBytes(startFrame, sizeof(startFrame));
// data
_wire.transmitBytes(_data, _sizeData);
// end frame
_wire.transmitBytes(endFrame, sizeof(endFrame));
_wire.endTransaction();
}
bool AlwaysUpdate()
{
// this method requires update to be called only if changes to buffer
return false;
}
uint8_t* getData() const
{
return _data;
};
size_t getDataSize() const
{
return _sizeData;
};
void applySettings([[maybe_unused]] const SettingsObject& settings)
{
_wire.applySettings(settings);
}
private:
const size_t _sizeData; // Size of '_data' buffer below
T_TWOWIRE _wire;
uint8_t* _data; // Holds LED color values
};
typedef Hd108MethodBase<TwoWireBitBangImple> Hd108Method;
#if !defined(__AVR_ATtiny85__) && !defined(ARDUINO_attiny)
#include "TwoWireSpiImple.h"
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed40Mhz>> Hd108Spi40MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed20Mhz>> Hd108Spi20MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed10Mhz>> Hd108Spi10MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed5Mhz>> Hd108Spi5MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed2Mhz>> Hd108Spi2MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed1Mhz>> Hd108Spi1MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed500Khz>> Hd108Spi500KhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeedHz>> Hd108SpiHzMethod;
typedef Hd108Spi10MhzMethod Hd108SpiMethod;
#endif
#if defined(ARDUINO_ARCH_ESP32)
// Give option to use Vspi alias of Spi class if wanting to specify which SPI peripheral is used on the ESP32
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed40Mhz>> Hd108Esp32Vspi40MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed20Mhz>> Hd108Esp32Vspi20MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed10Mhz>> Hd108Esp32Vspi10MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed5Mhz>> Hd108Esp32Vspi5MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed2Mhz>> Hd108Esp32Vspi2MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed1Mhz>> Hd108Esp32Vspi1MhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeed500Khz>> Hd108Esp32Vspi500KhzMethod;
typedef Hd108MethodBase<TwoWireSpiImple<SpiSpeedHz>> Hd108Esp32VspiHzMethod;
typedef Hd108Spi10MhzMethod Hd108Esp32VspiMethod;
#include "TwoWireHspiImple.h"
typedef Hd108MethodBase<TwoWireHspiImple<SpiSpeed40Mhz>> Hd108Esp32Hspi40MhzMethod;
typedef Hd108MethodBase<TwoWireHspiImple<SpiSpeed20Mhz>> Hd108Esp32Hspi20MhzMethod;
typedef Hd108MethodBase<TwoWireHspiImple<SpiSpeed10Mhz>> Hd108Esp32Hspi10MhzMethod;
typedef Hd108MethodBase<TwoWireHspiImple<SpiSpeed5Mhz>> Hd108Esp32Hspi5MhzMethod;
typedef Hd108MethodBase<TwoWireHspiImple<SpiSpeed2Mhz>> Hd108Esp32Hspi2MhzMethod;
typedef Hd108MethodBase<TwoWireHspiImple<SpiSpeed1Mhz>> Hd108Esp32Hspi1MhzMethod;
typedef Hd108MethodBase<TwoWireHspiImple<SpiSpeed500Khz>> Hd108Esp32Hspi500KhzMethod;
typedef Hd108MethodBase<TwoWireHspiImple<SpiSpeedHz>> Hd108Esp32HspiHzMethod;
typedef Hd108Esp32Hspi10MhzMethod Hd108Esp32HspiMethod;
#endif