3#ifndef __INC_CHIPSETS_H
4#define __INC_CHIPSETS_H
17#ifdef FASTLED_FORCE_NAMESPACE
18#define FASTLED_CLOCKLESS_CONTROLLER fl::ClocklessController
20#define FASTLED_CLOCKLESS_CONTROLLER ClocklessController
23#ifndef FASTLED_CLOCKLESS_USES_NANOSECONDS
24 #if defined(FASTLED_TEENSY4)
25 #define FASTLED_CLOCKLESS_USES_NANOSECONDS 1
30 #define FASTLED_CLOCKLESS_USES_NANOSECONDS 1
32 #define FASTLED_CLOCKLESS_USES_NANOSECONDS 0
35 #define FASTLED_CLOCKLESS_USES_NANOSECONDS 0
44#ifdef FASTLED_LED_OVERCLOCK
45#warning "FASTLED_LED_OVERCLOCK has been changed to FASTLED_OVERCLOCK. Please update your code."
46#define FASTLED_OVERCLOCK FASTLED_LED_OVERCLOCK
49#ifndef FASTLED_OVERCLOCK
50#define FASTLED_OVERCLOCK 1.0
52#ifndef FASTLED_OVERCLOCK_SUPPRESS_WARNING
53#warning "FASTLED_OVERCLOCK is now active, #define FASTLED_OVERCLOCK_SUPPRESS_WARNING to disable this warning"
59#include "platforms/chipsets_specialized_ws2812.h"
74#if defined(SoftwareSerial_h) || defined(__SoftwareSerial_h)
75#include <SoftwareSerial.h>
84template<fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
86 SoftwareSerial Serial;
90 PixieController() : Serial(-1,
DATA_PIN) {}
102 while(pixels.
has(1)) {
139 CONTROLLER::MASK_VALUE> {
152 ControllerBaseT::show(data, nLeds,
brightness);
158 static const int LANES = CONTROLLER::LANES_VALUE;
159 static const uint32_t
MASK = CONTROLLER::MASK_VALUE;
162 static_assert(
RGB == CONTROLLER::RGB_ORDER_VALUE,
"The delegated controller MUST NOT do reordering");
182 while (pixels.
has(1)) {
225 for (uint32_t i = 0; i < new_size; i++) {
254template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, u
int32_t SPI_SPEED = DATA_RATE_MHZ(12) >
263 SPI* pSPI =
static_cast<SPI*
>(context);
281 mSPI.template writePixels<0, LPD8806_ADJUST, RGB_ORDER>(pixels, &
mSPI);
297template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, u
int32_t SPI_SPEED = DATA_RATE_MHZ(1)>
317 mSPI.template writePixels<0, DATA_NOP, RGB_ORDER>(pixels, NULL);
324template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, u
int32_t SPI_SPEED = DATA_RATE_MHZ(25)>
335template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, u
int32_t SPI_SPEED = DATA_RATE_MHZ(12)>
341 void endBoundary(
int nLeds) {
int nDWords = (nLeds/32);
do {
mSPI.writeByte(0xFF);
mSPI.writeByte(0x00);
mSPI.writeByte(0x00);
mSPI.writeByte(0x00); }
while(nDWords--); }
356 while(pixels.
has(1)) {
361 mSPI.writeByte((command >> 8) & 0xFF);
363 mSPI.writeByte(command & 0xFF);
396 uint32_t START_FRAME = 0x00000000,
397 uint32_t END_FRAME = 0xFF000000
404 mSPI.writeWord(START_FRAME >> 16);
405 mSPI.writeWord(START_FRAME & 0xFFFF);
408 int nDWords = (nLeds/32);
422#ifdef FASTLED_SPI_BYTE_ONLY
428 fl::u16 b = 0xE000 | (
brightness << 8) | (fl::u16)b0;
437#ifdef FASTLED_SPI_BYTE_ONLY
441 mSPI.writeWord(fl::u16(b1) << 8 | b2);
455 switch (GAMMA_CORRECTION_MODE) {
472#if FASTLED_HD_COLOR_MIXING
474 pixels.getHdScale(out_s0, out_s1, out_s2, &
brightness);
476 static fl::u16 map(fl::u16
x, fl::u16 in_min, fl::u16 in_max, fl::u16 out_min, fl::u16 out_max) {
477 const fl::u16 run = in_max - in_min;
478 const fl::u16 rise = out_max - out_min;
479 const fl::u16 delta =
x - in_min;
480 return (delta * rise) / run + out_min;
484 fl::u16 bri = Math::map(
brightness, 0, 255, 0, 31);
489 *out_brightness =
static_cast<fl::u8>(bri);
494#if FASTLED_USE_GLOBAL_BRIGHTNESS == 1
496 const fl::u16 maxBrightness = 0x1F;
497 fl::u16
brightness = ((((fl::u16)
MAX(
MAX(s0, s1), s2) + 1) * maxBrightness - 1) >> 8) + 1;
514 fl::u8 s0, s1, s2, global_brightness;
517 while (pixels.
has(1)) {
520 writeLed(global_brightness, c0, c1, c2);
533 while (pixels.
has(1)) {
568 fl::kFiveBitGammaCorrectionMode_BitShift,
569 uint32_t(0x00000000),
570 uint32_t(0x00000000)> {
592 fl::kFiveBitGammaCorrectionMode_Null,
614 fl::kFiveBitGammaCorrectionMode_BitShift,
633 fl::kFiveBitGammaCorrectionMode_Null,
664template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, u
int32_t SPI_SPEED = DATA_RATE_MHZ(10)>
673 mSPI.writeByte(top);
mSPI.writeByte(b);
mSPI.writeByte(g);
mSPI.writeByte(r);
689 while(pixels.
has(1)) {
714template <fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, u
int32_t SPI_SPEED = DATA_RATE_MHZ(16)>
722 mSPI.template writeBit<0>(0);
726 mSPI.template writeBit<0>(0);
747 mSPI.template writePixels<FLAG_START_BIT, DATA_NOP, RGB_ORDER>(pixels, NULL);
761#ifdef FASTLED_HAS_CLOCKLESS
786#if !defined(CLOCKLESS_FREQUENCY)
787 #define CLOCKLESS_FREQUENCY F_CPU
792#if defined(__LGT8F__) || (CLOCKLESS_FREQUENCY == 8000000 || CLOCKLESS_FREQUENCY == 16000000 || CLOCKLESS_FREQUENCY == 24000000) || defined(FASTLED_DOXYGEN)
796#define FMUL (CLOCKLESS_FREQUENCY/8000000)
800template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
805template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
810template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
813#if !FASTLED_WS2812_HAS_SPECIAL_DRIVER
817template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
823template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
828template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
833template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
838template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
843template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
848template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
853template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
858template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
863template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
868template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
873template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
878template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
883template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
888template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
893template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
898template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
903template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
908template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
913template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
917template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
922template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
935#ifndef FASTLED_OVERCLOCK_WS2812
936#define FASTLED_OVERCLOCK_WS2812 FASTLED_OVERCLOCK
939#ifndef FASTLED_OVERCLOCK_WS2811
940#define FASTLED_OVERCLOCK_WS2811 FASTLED_OVERCLOCK
943#ifndef FASTLED_OVERCLOCK_WS2813
944#define FASTLED_OVERCLOCK_WS2813 FASTLED_OVERCLOCK
947#ifndef FASTLED_OVERCLOCK_WS2815
948#define FASTLED_OVERCLOCK_WS2815 FASTLED_OVERCLOCK
951#ifndef FASTLED_OVERCLOCK_SK6822
952#define FASTLED_OVERCLOCK_SK6822 FASTLED_OVERCLOCK
955#ifndef FASTLED_OVERCLOCK_SK6812
956#define FASTLED_OVERCLOCK_SK6812 FASTLED_OVERCLOCK
961#if FASTLED_CLOCKLESS_USES_NANOSECONDS
965#define C_NS(_NS) (((_NS * ((CLOCKLESS_FREQUENCY / 1000000L)) + 999)) / 1000)
971#define C_NS_WS2812(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_WS2812)))
972#define C_NS_WS2811(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_WS2811)))
973#define C_NS_WS2813(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_WS2813)))
974#define C_NS_WS2815(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_WS2815)))
975#define C_NS_SK6822(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_SK6822)))
976#define C_NS_SK6812(_NS) (C_NS(int(_NS / FASTLED_OVERCLOCK_SK6812)))
1009template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1013template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1017template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1021template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1025template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1029template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1033template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1037template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1041template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1045template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1048#ifndef FASTLED_WS2812_T1
1049#define FASTLED_WS2812_T1 250
1052#ifndef FASTLED_WS2812_T2
1053#define FASTLED_WS2812_T2 625
1056#ifndef FASTLED_WS2812_T3
1057#define FASTLED_WS2812_T3 375
1062#if !FASTLED_WS2812_HAS_SPECIAL_DRIVER
1063template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1066 C_NS_WS2812(FASTLED_WS2812_T1),
1067 C_NS_WS2812(FASTLED_WS2812_T2),
1068 C_NS_WS2812(FASTLED_WS2812_T3),
1073template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1076template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1080template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1083template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1086template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1087class TM1829Controller1600Khz :
public FASTLED_CLOCKLESS_CONTROLLER<DATA_PIN, C_NS(100), C_NS(300), C_NS(200), RGB_ORDER, 0, true, 500> {};
1089template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1092template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1096template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1099template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1102template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1105template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1109template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1120template <fl::u8 DATA_PIN, EOrder RGB_ORDER = RGB>
1129template <fl::u8 DATA_PIN, EOrder RGB_ORDER = GRB>
1132 WS2812Controller800Khz<DATA_PIN, RGB>::LANES_VALUE,
1133 WS2812Controller800Khz<DATA_PIN, RGB>::MASK_VALUE> {
1148 ControllerBaseT::show(data, nLeds,
brightness);
1153 static const int LANES = ControllerT::LANES_VALUE;
1154 static const uint32_t
MASK = ControllerT::MASK_VALUE;
1180 size_t out_index = 0;
1181 while (pixels.
has(1)) {
1187 fl::u8 b0_lo = s0 & 0xFF;
1189 fl::u8 b1_lo = s1 & 0xFF;
1191 fl::u8 b2_lo = s2 & 0xFF;
1193 mData[out_index] =
CRGB(b0_hi, b0_lo, b1_hi);
1194 mData[out_index + 1] =
CRGB(b1_lo, b2_hi, b2_lo);
1207#ifdef BOUNCE_SUBCLASS
1222 int size_16bit = 2 * size_8bit;
1225 CRGB *new_leds =
new CRGB[size_16bit];
UISlider brightness("Brightness", 128, 0, 255, 1)
#define FASTLED_CLOCKLESS_CONTROLLER
void showPixelsGammaBitShift(PixelController< RGB_ORDER > &pixels)
virtual void init() override
Initialize the LED controller.
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
virtual void showPixels(PixelController< RGB_ORDER > &pixels) override
Send the LED data to the strip.
void showPixelsDefault(PixelController< RGB_ORDER > &pixels)
FASTLED_FORCE_INLINE void writeLed(fl::u8 brightness, fl::u8 b0, fl::u8 b1, fl::u8 b2)
static void getGlobalBrightnessAndScalingFactors(PixelController< RGB_ORDER > &pixels, fl::u8 *out_s0, fl::u8 *out_s1, fl::u8 *out_s2, fl::u8 *out_brightness)
FASTLED_FORCE_INLINE void write2Bytes(fl::u8 b1, fl::u8 b2)
void endBoundary(int nLeds)
APA102ControllerHD()=default
APA102ControllerHD(const APA102ControllerHD &)=delete
static void writeBytesValueRaw(uint8_t value, int len)
Write multiple bytes of the given value over SPI, without selecting the interface.
virtual int size()
How many LEDs does this controller manage?
CLEDController & setRgbw(const Rgbw &arg=RgbwDefault::value())
virtual void init()=0
Initialize the LED controller.
void mark()
Reset the timestamp that marks the start of the wait period.
void wait()
Blocking delay until WAIT time since mark() has passed.
Class to ensure that a minimum amount of time has kicked since the last time run - and delay if not e...
virtual void showPixels(PixelController< RGB_ORDER, LANES, MASK > &pixels)=0
Send the LED data to the strip.
Template extension of the CLEDController class.
DP1903 controller class @ 400 KHz.
DP1903 controller class @ 800 KHz.
GW6205 controller class @ 400 KHz.
UCS1904 controller class @ 800 KHz.
HD107 is just the APA102 with a default 40Mhz clock rate.
HD107HD is just the APA102HD with a default 40Mhz clock rate.
LPD1886 controller class.
LPD1886 controller class.
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
virtual void init()
Initialize the LED controller.
void endBoundary(int nLeds)
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
static FASTLED_FORCE_INLINE fl::u8 adjust(FASTLED_REGISTER fl::u8 data)
static FASTLED_FORCE_INLINE void postBlock(int len, void *context=NULL)
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
virtual void init()
Initialize the LED controller.
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
FASTLED_FORCE_INLINE void writeLed(fl::u8 r, fl::u8 g, fl::u8 b)
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
virtual void init()
Initialize the LED controller.
void callEndShowLeds(void *data)
void callShow(CRGB *data, int nLeds, fl::u8 brightness)
void * callBeginShowLeds(int size)
virtual void * beginShowLeds(int size) override
void init() override
Initialize the LED controller.
virtual void endShowLeds(void *data) override
~RGBWEmulatedController()
virtual void showPixels(PixelController< RGB_ORDER, LANES, MASK > &pixels) override
Send the LED data to the strip.
void ensureBuffer(int32_t num_leds)
RGBWEmulatedController(const Rgbw &rgbw=RgbwDefault())
static const uint32_t MASK
CONTROLLER ControllerBaseT
SM16703 controller class.
virtual void init()
Initialize the LED controller.
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
SM16824E controller class.
UCS1903B controller class.
UCS1903 controller class @ 400 KHz.
UCS1904 controller class.
UCS2903 controller class.
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
virtual void init()
Initialize the controller.
CMinWait< 1000 > mWaitDelay
WS2811 controller class @ 400 KHz.
WS2811 controller class @ 800 KHz.
WS2812 controller class @ 800 KHz.
WS2815 controller class @ 400 KHz.
void * callBeginShowLeds(int size)
void callShow(CRGB *data, int nLeds, fl::u8 brightness)
void callEndShowLeds(void *data)
static const uint32_t MASK
void ensureBuffer(int size_8bit)
virtual void * beginShowLeds(int size) override
virtual void showPixels(PixelController< RGB_ORDER, LANES, MASK > &pixels) override
Send the LED data to the strip.
void init() override
Initialize the LED controller.
WS2812Controller800Khz< DATA_PIN, RGB > ControllerBaseT
virtual void endShowLeds(void *data) override
Defines the red, green, and blue (RGB) pixel struct.
#define DISABLE_DITHER
Disable dithering.
@ GRB
Green, Red, Blue (0102)
@ RGB
Red, Green, Blue (0012)
Defines color channel ordering enumerations.
#define DATA_RATE_MHZ(X)
Convert data rate from megahertz (MHz) to clock cycles per bit.
Declares functions for five-bit gamma correction.
#define FASTLED_FORCE_INLINE
#define FASTLED_NAMESPACE_END
#define FASTLED_NAMESPACE_BEGIN
Implements the FastLED namespace macros.
FiveBitGammaCorrectionMode
@ kFiveBitGammaCorrectionMode_Null
@ kFiveBitGammaCorrectionMode_BitShift
To * bit_cast_ptr(void *storage) noexcept
Non-templated low level pixel data writing class.
Includes defintions for RGB and HSV pixels.
#define FASTLED_REGISTER
Helper macro to replace the deprecated 'register' keyword if we're using modern C++ where it's been r...
Representation of an RGB pixel (Red, Green, Blue)
FASTLED_FORCE_INLINE void loadAndScale_WS2816_HD(uint16_t *s0_out, uint16_t *s1_out, uint16_t *s2_out)
FASTLED_FORCE_INLINE void loadAndScale_APA102_HD(uint8_t *b0_out, uint8_t *b1_out, uint8_t *b2_out, uint8_t *brightness_out)
FASTLED_FORCE_INLINE uint8_t loadAndScale1(int lane, uint8_t scale)
non-template alias of loadAndScale<1>()
FASTLED_FORCE_INLINE uint8_t loadAndScale2(int lane, uint8_t scale)
non-template alias of loadAndScale<2>()
FASTLED_FORCE_INLINE void loadAndScaleRGB(uint8_t *b0_out, uint8_t *b1_out, uint8_t *b2_out)
FASTLED_FORCE_INLINE uint8_t loadAndScale0(int lane, uint8_t scale)
non-template alias of loadAndScale<0>()
FASTLED_FORCE_INLINE int size()
Get the length of the LED strip.
FASTLED_FORCE_INLINE void loadAndScaleRGBW(Rgbw rgbw, uint8_t *b0_out, uint8_t *b1_out, uint8_t *b2_out, uint8_t *b3_out)
FASTLED_FORCE_INLINE void advanceData()
Advance the data pointer forward, adjust position counter.
FASTLED_FORCE_INLINE bool has(int n)
Do we have n pixels left to process?
FASTLED_FORCE_INLINE void stepDithering()
Step the dithering forward.
static uint32_t size_as_rgb(uint32_t num_of_rgbw_pixels)