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;
26#ifndef FASTLED_DEFINE_WEAK_YEILD_FUNCTION
27#if defined(__AVR_ATtiny13__)
29#define FASTLED_DEFINE_WEAK_YEILD_FUNCTION 0
31#define FASTLED_DEFINE_WEAK_YEILD_FUNCTION 1
39extern "C" __attribute__((weak))
int atexit(
void (* )()) {
return 0; }
41#if FASTLED_DEFINE_WEAK_YEILD_FUNCTION
42extern "C" __attribute__((weak))
void yield(
void) { }
47uint16_t cled_contoller_size() {
51uint8_t get_brightness();
61static uint32_t lastshow = 0;
79 m_nPowerData = 0xFFFFFFFF;
84 return (*
this)[0].size();
88 return (*
this)[0].leds();
93 int nLedsOrOffset,
int nLedsIfOffset) {
94 int nOffset = (nLedsIfOffset > 0) ? nLedsOrOffset : 0;
95 int nLeds = (nLedsIfOffset > 0) ? nLedsIfOffset : nLedsOrOffset;
98 pLed->
setLeds(data + nOffset, nLeds);
100 fl::EngineEvents::onStripAdded(pLed, nLedsOrOffset - nOffset);
104static void* gControllersData[MAX_CLED_CONTROLLERS];
107 fl::EngineEvents::onBeginFrame();
108 while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
113 scale = (*m_pPowerFunc)(scale, m_nPowerData);
120 while(pCur && length < MAX_CLED_CONTROLLERS) {
121 if (pCur->getEnabled()) {
122 gControllersData[length] = pCur->beginShowLeds(pCur->
size());
124 gControllersData[length] =
nullptr;
127 if (m_nFPS < 100) { pCur->
setDither(0); }
132 for (length = 0; length < MAX_CLED_CONTROLLERS && pCur; length++) {
133 if (pCur->getEnabled()) {
142 while(pCur && length < MAX_CLED_CONTROLLERS) {
143 if (pCur->getEnabled()) {
144 pCur->endShowLeds(gControllersData[length]);
150 fl::EngineEvents::onEndShowLeds();
151 fl::EngineEvents::onEndFrame();
177 while(m_nMinMicros && ((micros()-lastshow) < m_nMinMicros));
182 scale = (*m_pPowerFunc)(scale, m_nPowerData);
187 while(pCur && length < MAX_CLED_CONTROLLERS) {
188 if (pCur->getEnabled()) {
189 gControllersData[length] = pCur->beginShowLeds(pCur->
size());
191 gControllersData[length] =
nullptr;
198 while(pCur && length < MAX_CLED_CONTROLLERS) {
200 if (pCur->getEnabled()) {
208 while(pCur && length < MAX_CLED_CONTROLLERS) {
209 if (pCur->getEnabled()) {
210 pCur->endShowLeds(gControllersData[length]);
234 unsigned long start = millis();
236#ifndef FASTLED_ACCURATE_CLOCK
244 while((millis()-start) < ms);
324 static uint32_t lastframe = 0;
326 if(br++ >= nFrames) {
327 uint32_t now = millis();
332 m_nFPS = (br * 1000) / now;
334 lastframe = millis();
343 m_nMinMicros = ((1000000 / refresh) > m_nMinMicros) ? (1000000 / refresh) : m_nMinMicros;
345 }
else if(refresh > 0) {
346 m_nMinMicros = 1000000 / refresh;
353uint8_t get_brightness() {
362 #if !defined(ESP8266) && !defined(ESP32)
363 extern "C" void __cxa_pure_virtual (
void) {}
369 __extension__
typedef int __guard __attribute__((mode(__DI__)));
371 extern "C" int __cxa_guard_acquire (__guard *) __attribute__((weak));
372 extern "C" void __cxa_guard_release (__guard *) __attribute__((weak));
373 extern "C" void __cxa_guard_abort (__guard *) __attribute__((weak));
375 extern "C" int __cxa_guard_acquire (__guard *g)
377 return !*(
char *)(g);
380 extern "C" void __cxa_guard_release (__guard *g)
385 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)