1#define FASTLED_INTERNAL
3#include "fl/singleton.h"
4#include "fl/engine_events.h"
9#ifndef MAX_CLED_CONTROLLERS
12#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__)
13#define MAX_CLED_CONTROLLERS 16
15#define MAX_CLED_CONTROLLERS 8
18#define MAX_CLED_CONTROLLERS 64
22#if defined(__SAM3X8E__)
23volatile uint32_t fuckit;
30extern "C" __attribute__((weak))
int atexit(
void (* )()) {
return 0; }
31extern "C" __attribute__((weak))
void yield(
void) { }
35uint16_t cled_contoller_size() {
39uint8_t get_brightness();
49static uint32_t lastshow = 0;
67 m_nPowerData = 0xFFFFFFFF;
72 return (*
this)[0].size();
76 return (*
this)[0].leds();
81 int nLedsOrOffset,
int nLedsIfOffset) {
82 int nOffset = (nLedsIfOffset > 0) ? nLedsOrOffset : 0;
83 int nLeds = (nLedsIfOffset > 0) ? nLedsIfOffset : nLedsOrOffset;
86 pLed->
setLeds(data + nOffset, nLeds);
88 fl::EngineEvents::onStripAdded(pLed, nLedsOrOffset - nOffset);
92static void* gControllersData[MAX_CLED_CONTROLLERS];
95 fl::EngineEvents::onBeginFrame();
96 while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
101 scale = (*m_pPowerFunc)(scale, m_nPowerData);
108 while(pCur && length < MAX_CLED_CONTROLLERS) {
109 gControllersData[length++] = pCur->beginShowLeds();
110 if (m_nFPS < 100) { pCur->
setDither(0); }
117 while(pCur && length < MAX_CLED_CONTROLLERS) {
118 pCur->endShowLeds(gControllersData[length++]);
122 fl::EngineEvents::onEndShowLeds();
123 fl::EngineEvents::onEndFrame();
149 while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
154 scale = (*m_pPowerFunc)(scale, m_nPowerData);
159 while(pCur && length < MAX_CLED_CONTROLLERS) {
160 gControllersData[length++] = pCur->beginShowLeds();
168 while(pCur && length < MAX_CLED_CONTROLLERS) {
169 pCur->endShowLeds(gControllersData[length++]);
191 unsigned long start = millis();
193#ifndef FASTLED_ACCURATE_CLOCK
201 while((millis()-start) < ms);
281 static uint32_t lastframe = 0;
283 if(br++ >= nFrames) {
284 uint32_t now = millis();
289 m_nFPS = (br * 1000) / now;
291 lastframe = millis();
300 m_nMinMicros = ((1000000 / refresh) > m_nMinMicros) ? (1000000 / refresh) : m_nMinMicros;
302 }
else if(refresh > 0) {
303 m_nMinMicros = 1000000 / refresh;
310uint8_t get_brightness() {
319 #if !defined(ESP8266) && !defined(ESP32)
320 extern "C" void __cxa_pure_virtual (
void) {}
326 __extension__
typedef int __guard __attribute__((mode(__DI__)));
328 extern "C" int __cxa_guard_acquire (__guard *) __attribute__((weak));
329 extern "C" void __cxa_guard_release (__guard *) __attribute__((weak));
330 extern "C" void __cxa_guard_abort (__guard *) __attribute__((weak));
332 extern "C" int __cxa_guard_acquire (__guard *g)
334 return !*(
char *)(g);
337 extern "C" void __cxa_guard_release (__guard *g)
342 extern "C" void __cxa_guard_abort (__guard *)
uint32_t _retry_cnt
Global frame retry counter, used for debugging ESP implementations.
void * pSmartMatrix
Pointer to the matrix object when using the Smart Matrix Library.
int atexit(void(*)())
Has to be declared outside of any namespaces.
CFastLED FastLED
Global LED strip management instance.
int noise_max
Unused value.
uint32_t _frame_cnt
Global frame counter, used for debugging ESP implementations.
int noise_min
Unused value.
central include file for FastLED, defines the CFastLED class/object
CFastLED FastLED
Global LED strip management instance.
High level controller interface for FastLED.
int size()
Get the number of leds in the first controller.
void setMaxRefreshRate(uint16_t refresh, bool constrain=false)
Set the maximum refresh rate.
CRGB * leds()
Get a pointer to led data for the first controller.
void setTemperature(const struct CRGB &temp)
Set a global color temperature.
void show()
Update all our controllers with the current led colors.
void countFPS(int nFrames=25)
For debugging, this will keep track of time between calls to countFPS().
CLEDController & operator[](int x)
Get a reference to a registered controller.
void delay(unsigned long ms)
Delay for the given number of milliseconds.
void showColor(const struct CRGB &color, uint8_t scale)
Set all leds on all controllers to the given color/scale.
void setDither(uint8_t ditherMode=BINARY_DITHER)
Set the dithering mode.
uint8_t getBrightness()
Get the current global brightness setting.
void clearData()
Clear out the local data array.
void setCorrection(const struct CRGB &correction)
Set a global color correction.
int count()
Get how many controllers have been registered.
void clear(bool writeData=false)
Clear the leds, wiping the local array of data.
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Base definition for an LED controller.
CLEDController * next()
Get the next controller in the linked list after this one.
CLEDController & setDither(uint8_t ditherMode=BINARY_DITHER)
Set the dithering mode for this controller to use.
virtual uint16_t getMaxRefreshRate() const
Gets the maximum possible refresh rate of the strip.
CLEDController & setLeds(CRGB *data, int nLeds)
Set the default array of LEDs to be used by this controller.
CLEDController & setCorrection(CRGB correction)
The color corrction to use for this controller, expressed as a CRGB object.
static CLEDController * head()
Get the first LED controller in the linked list of controllers.
CLEDController & setTemperature(CRGB temperature)
Set the color temperature, aka white point, for this controller.
static CLEDController * m_pTail
pointer to the last LED controller in the linked list
void showColorInternal(const struct CRGB &data, int nLeds, uint8_t brightness)
void showLedsInternal(uint8_t brightness)
Write the data to the LEDs managed by this controller.
void clearLedDataInternal(int nLeds=-1)
Zero out the LED data managed by this controller.
virtual void init()=0
Initialize the LED controller.
static CLEDController * m_pHead
pointer to the first LED controller in the linked list
#define FASTLED_NAMESPACE_END
End of the FastLED namespace.
#define FASTLED_NAMESPACE_BEGIN
Start of the FastLED namespace.
Representation of an RGB pixel (Red, Green, Blue)