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;
40extern "C" __attribute__((weak))
int atexit(
void (* )()) {
return 0; }
42#ifdef FASTLED_NEEDS_YIELD
43extern "C" void yield(
void) { }
48uint16_t cled_contoller_size() {
52uint8_t get_brightness();
62static uint32_t lastshow = 0;
80 m_nPowerData = 0xFFFFFFFF;
85 return (*
this)[0].size();
89 return (*
this)[0].leds();
94 int nLedsOrOffset,
int nLedsIfOffset) {
95 int nOffset = (nLedsIfOffset > 0) ? nLedsOrOffset : 0;
96 int nLeds = (nLedsIfOffset > 0) ? nLedsIfOffset : nLedsOrOffset;
99 pLed->
setLeds(data + nOffset, nLeds);
101 fl::EngineEvents::onStripAdded(pLed, nLedsOrOffset - nOffset);
105static void* gControllersData[MAX_CLED_CONTROLLERS];
108 fl::EngineEvents::onBeginFrame();
109 while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
114 scale = (*m_pPowerFunc)(scale, m_nPowerData);
121 while(pCur && length < MAX_CLED_CONTROLLERS) {
122 if (pCur->getEnabled()) {
123 gControllersData[length] = pCur->beginShowLeds(pCur->
size());
125 gControllersData[length] =
nullptr;
128 if (m_nFPS < 100) { pCur->
setDither(0); }
133 for (length = 0; length < MAX_CLED_CONTROLLERS && pCur; length++) {
134 if (pCur->getEnabled()) {
143 while(pCur && length < MAX_CLED_CONTROLLERS) {
144 if (pCur->getEnabled()) {
145 pCur->endShowLeds(gControllersData[length]);
151 fl::EngineEvents::onEndShowLeds();
152 fl::EngineEvents::onEndFrame();
178 while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
183 scale = (*m_pPowerFunc)(scale, m_nPowerData);
188 while(pCur && length < MAX_CLED_CONTROLLERS) {
189 if (pCur->getEnabled()) {
190 gControllersData[length] = pCur->beginShowLeds(pCur->
size());
192 gControllersData[length] =
nullptr;
199 while(pCur && length < MAX_CLED_CONTROLLERS) {
201 if (pCur->getEnabled()) {
209 while(pCur && length < MAX_CLED_CONTROLLERS) {
210 if (pCur->getEnabled()) {
211 pCur->endShowLeds(gControllersData[length]);
235 unsigned long start = millis();
237#ifndef FASTLED_ACCURATE_CLOCK
245 while((millis()-start) < ms);
325 static uint32_t lastframe = 0;
327 if(br++ >= nFrames) {
328 uint32_t now = millis();
333 m_nFPS = (br * 1000) / now;
335 lastframe = millis();
344 m_nMinMicros = ((1000000 / refresh) > m_nMinMicros) ? (1000000 / refresh) : m_nMinMicros;
346 }
else if(refresh > 0) {
347 m_nMinMicros = 1000000 / refresh;
354uint8_t get_brightness() {
363 #if !defined(ESP8266) && !defined(ESP32)
364 extern "C" void __cxa_pure_virtual (
void) {}
370 __extension__
typedef int __guard __attribute__((mode(__DI__)));
372 extern "C" int __cxa_guard_acquire (__guard *) __attribute__((weak));
373 extern "C" void __cxa_guard_release (__guard *) __attribute__((weak));
374 extern "C" void __cxa_guard_abort (__guard *) __attribute__((weak));
376 extern "C" int __cxa_guard_acquire (__guard *g)
378 return !*(
char *)(g);
381 extern "C" void __cxa_guard_release (__guard *g)
386 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.
virtual int size()
How many LEDs does this controller manage?
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)