1 #ifndef __INC_FASTSPI_LED2_H
2 #define __INC_FASTSPI_LED2_H
10 #define FASTLED_VERSION 3001001
11 #ifndef FASTLED_INTERNAL
12 #warning FastLED version 3.001.001 (Not really a warning, just telling you here.)
15 #ifndef __PROG_TYPES_COMPAT__
16 #define __PROG_TYPES_COMPAT__
20 #include<SmartMatrix.h>
33 #include "cpp_compat.h"
36 #include "led_sysdefs.h"
41 #include "fastspi_types.h"
44 #include "platforms.h"
48 #include "pixeltypes.h"
55 #include "power_mgt.h"
60 FASTLED_NAMESPACE_BEGIN
74 enum ESM { SMART_MATRIX };
75 enum OWS2811 { OCTOWS2811,OCTOWS2811_400 };
81 #ifdef FASTLED_HAS_CLOCKLESS
112 enum EBlockChipsets {
113 #ifdef PORTA_FIRST_PIN
119 #ifdef PORTB_FIRST_PIN
125 #ifdef PORTC_FIRST_PIN
131 #ifdef PORTD_FIRST_PIN
145 #if defined(LIB8_ATTINY)
146 #define NUM_CONTROLLERS 2
148 #define NUM_CONTROLLERS 8
151 typedef uint8_t (*power_func)(uint8_t scale, uint32_t data);
161 uint32_t m_nMinMicros;
162 uint32_t m_nPowerData;
163 power_func m_pPowerFunc;
184 template<ESPIChipsets CHIPSET, u
int8_t DATA_PIN, u
int8_t CLOCK_PIN, EOrder RGB_ORDER, u
int8_t SPI_DATA_RATE >
CLEDController &
addLeds(
struct CRGB *data,
int nLedsOrOffset,
int nLedsIfOffset = 0) {
215 template<ESPIChipsets CHIPSET, u
int8_t DATA_PIN, u
int8_t CLOCK_PIN >
static CLEDController &
addLeds(
struct CRGB *data,
int nLedsOrOffset,
int nLedsIfOffset = 0) {
228 template<ESPIChipsets CHIPSET, u
int8_t DATA_PIN, u
int8_t CLOCK_PIN, EOrder RGB_ORDER >
static CLEDController &
addLeds(
struct CRGB *data,
int nLedsOrOffset,
int nLedsIfOffset = 0) {
242 template<ESPIChipsets CHIPSET>
static CLEDController &
addLeds(
struct CRGB *data,
int nLedsOrOffset,
int nLedsIfOffset = 0) {
243 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB>(data, nLedsOrOffset, nLedsIfOffset);
246 template<ESPIChipsets CHIPSET, EOrder RGB_ORDER>
static CLEDController &
addLeds(
struct CRGB *data,
int nLedsOrOffset,
int nLedsIfOffset = 0) {
247 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER>(data, nLedsOrOffset, nLedsIfOffset);
250 template<ESPIChipsets CHIPSET, EOrder RGB_ORDER, u
int8_t SPI_DATA_RATE>
static CLEDController &
addLeds(
struct CRGB *data,
int nLedsOrOffset,
int nLedsIfOffset = 0) {
251 return addLeds<CHIPSET, SPI_DATA, SPI_CLOCK, RGB_ORDER, SPI_DATA_RATE>(data, nLedsOrOffset, nLedsIfOffset);
257 #ifdef FASTLED_HAS_CLOCKLESS
260 template<
template<u
int8_t DATA_PIN, EOrder RGB_ORDER>
class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER>
278 static CHIPSET<DATA_PIN, RGB_ORDER> c;
279 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
282 template<
template<u
int8_t DATA_PIN, EOrder RGB_ORDER>
class CHIPSET, uint8_t DATA_PIN>
284 static CHIPSET<DATA_PIN, RGB> c;
285 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
288 template<
template<u
int8_t DATA_PIN>
class CHIPSET, uint8_t DATA_PIN>
290 static CHIPSET<DATA_PIN> c;
291 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
294 #ifdef FASTSPI_USE_DMX_SIMPLE
295 template<EClocklessChipsets CHIPSET, u
int8_t DATA_PIN, EOrder RGB_ORDER=RGB>
299 case DMX: {
static DMXController<DATA_PIN> controller;
return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
308 template<
template<EOrder RGB_ORDER>
class CHIPSET, EOrder RGB_ORDER>
326 static CHIPSET<RGB_ORDER> c;
327 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
330 template<
template<EOrder RGB_ORDER>
class CHIPSET>
332 static CHIPSET<RGB> c;
333 return addLeds(&c, data, nLedsOrOffset, nLedsIfOffset);
336 #ifdef USE_OCTOWS2811
337 template<OWS2811 CHIPSET, EOrder RGB_ORDER>
341 case OCTOWS2811: {
static COctoWS2811Controller<RGB_ORDER> controller;
return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
342 case OCTOWS2811_400: {
static COctoWS2811Controller<RGB_ORDER,true> controller;
return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
346 template<OWS2811 CHIPSET>
349 return addLeds<CHIPSET,GRB>(data,nLedsOrOffset,nLedsIfOffset);
355 template<ESM CHIPSET>
359 case SMART_MATRIX: {
static CSmartMatrixController controller;
return addLeds(&controller, data, nLedsOrOffset, nLedsIfOffset); }
366 #ifdef FASTLED_HAS_BLOCKLESS
370 template<EBlockChipsets CHIPSET,
int NUM_LANES, EOrder RGB_ORDER>
389 #ifdef PORTA_FIRST_PIN
390 case WS2811_PORTA:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
391 case WS2811_400_PORTA:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
392 case TM1803_PORTA:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
393 case UCS1903_PORTA:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTA_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
395 #ifdef PORTB_FIRST_PIN
396 case WS2811_PORTB:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
397 case WS2811_400_PORTB:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
398 case TM1803_PORTB:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
399 case UCS1903_PORTB:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTB_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
401 #ifdef PORTC_FIRST_PIN
402 case WS2811_PORTC:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
403 case WS2811_400_PORTC:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
404 case TM1803_PORTC:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
405 case UCS1903_PORTC:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTC_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
407 #ifdef PORTD_FIRST_PIN
408 case WS2811_PORTD:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
409 case WS2811_400_PORTD:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
410 case TM1803_PORTD:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
411 case UCS1903_PORTD:
return addLeds(
new InlineBlockClocklessController<NUM_LANES, PORTD_FIRST_PIN, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
414 case WS2811_PORTDC:
return addLeds(
new SixteenWayInlineBlockClocklessController<NUM_LANES,NS(320), NS(320), NS(640), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
415 case WS2811_400_PORTDC:
return addLeds(
new SixteenWayInlineBlockClocklessController<NUM_LANES,NS(800), NS(800), NS(900), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
416 case TM1803_PORTDC:
return addLeds(
new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(700), NS(1100), NS(700), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
417 case UCS1903_PORTDC:
return addLeds(
new SixteenWayInlineBlockClocklessController<NUM_LANES, NS(500), NS(1500), NS(500), RGB_ORDER>(), data, nLedsOrOffset, nLedsIfOffset);
422 template<EBlockChipsets CHIPSET,
int NUM_LANES>
424 return addLeds<CHIPSET,NUM_LANES,GRB>(data,nLedsOrOffset,nLedsIfOffset);
448 void show(uint8_t scale);
455 void clear(
boolean writeData =
false);
473 void delay(
unsigned long ms);
488 void setDither(uint8_t ditherMode = BINARY_DITHER);
519 int size() {
return (*
this)[0].size(); }
526 #define FastSPI_LED FastLED
527 #define FastSPI_LED2 FastLED
535 #ifndef HAS_HARDWARE_PIN_SUPPORT
536 #warning "No pin/port mappings found, pin access will be slightly slower. See fastpin.h for info."
537 #define NO_HARDWARE_PIN_SUPPORT
541 FASTLED_NAMESPACE_END
Functions for rotating bits/bytes.
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a 3rd party library based CLEDController instance to the world.
Representation of an RGB pixel (Red, Green, Blue)
CLEDController & operator[](int x)
Get a reference to a registered controller.
Base definition for an LED controller.
int size()
Get the number of leds in the first controller.
contains definitions that can be used to configure FastLED at compile time
uint8_t getBrightness()
Get the current global brightness setting.
contains definitions for the predefined color palettes supplied by FastLED.
LPD8806 controller class.
Class base definitions for defining fast pin access.
Adafruit Pixie controller class.
void setMaxPowerInVoltsAndMilliamps(uint8_t volts, uint32_t milliamps)
Set the maximum power to be used, given in volts and milliamps.
int count()
Get how many controllers have been registered.
High level controller interface for FastLED.
static CLEDController & addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a clockless (aka 3wire, also DMX) based CLEDController instance to the world. ...
void setDither(uint8_t ditherMode=BINARY_DITHER)
Set the dithering mode.
uint8_t calculate_max_brightness_for_power_mW(const CRGB *ledbuffer, uint16_t numLeds, uint8_t target_brightness, uint32_t max_power_mW)
calculate_max_brightness_for_power_mW tells you the highest brightness level you can use and still st...
void setTemperature(const struct CRGB &temp)
Set a global color temperature.
uint16_t getFPS()
Get the number of frames/second being written out.
void setMaxPowerInMilliWatts(uint32_t milliwatts)
Set the maximum power to be used, given in milliwatts.
CRGB * leds()
Get a pointer to led data for the first controller.
contains the bulk of the definitions for the various LED chipsets supported.
void show()
Update all our controllers with the current led colors.
void setCorrection(const struct CRGB &correction)
Set a global color correction.
void showColor(const struct CRGB &color, uint8_t scale)
Set all leds on all controllers to the given color/scale.
base definitions used by led controllers for writing out led data
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Noise functions provided by the library.
functions for color fill, paletters, blending, and more
void showColor(const struct CRGB &color)
Set all leds on all controllers to the given color.
void countFPS(int nFrames=25)
for debugging, will keep track of time between calls to countFPS, and every nFrames calls...
ESPIChipsets
definitions for the spi chipset constants
void clear(boolean writeData=false)
clear the leds, optionally wiping the local array of data as well
void clearData()
clear out the local data array
wrapper definitions to allow seamless use of PROGMEM in environmens that have it
void setMaxRefreshRate(uint16_t refresh, bool constrain=false)
Set the maximum refresh rate.
void delay(unsigned long ms)
Delay for the given number of milliseconds.
SM16716 controller class.