1#define FASTLED_INTERNAL
18#if SKETCH_HAS_LARGE_MEMORY
26#include "platforms/init.h"
29#include "platforms/is_platform.h"
34#ifndef MAX_CLED_CONTROLLERS
37#if defined(FL_IS_AVR_ATMEGA_2560) || defined(FL_IS_AVR_ATMEGA)
38#define MAX_CLED_CONTROLLERS 16
40#define MAX_CLED_CONTROLLERS 8
43#define MAX_CLED_CONTROLLERS 64
48volatile fl::u32 fuckit;
52#ifndef FASTLED_NO_ATEXIT
53#define FASTLED_NO_ATEXIT 0
60#ifdef FASTLED_NEEDS_YIELD
61extern "C" void yield(
void) { }
111 return (*
this)[0].size();
115 return (*
this)[0].leds();
120 int nLedsOrOffset,
int nLedsIfOffset) {
121 int nOffset = (nLedsIfOffset > 0) ? nLedsOrOffset : 0;
122 int nLeds = (nLedsIfOffset > 0) ? nLedsIfOffset : nLedsOrOffset;
125 pLed->
setLeds(data + nOffset, nLeds);
141 if (chnls.has(channel)) {
144 chnls.push_back(channel);
148 channel->addToDrawList();
156 channel->removeFromDrawList();
163 auto clearFlag = [&flags](
ClearFlags flag) ->
bool {
165 flags =
static_cast<ClearFlags>(
static_cast<fl::u32
>(flags) & ~static_cast<fl::u32>(flag));
175 FastLED.mNPowerData = 0xFFFFFFFF;
202 for (
auto& channel : channelsCopy) {
238#if SKETCH_HAS_LARGE_MEMORY
288 #if FASTLED_HAS_ENGINE_EVENTS
308 if(pCur ==
nullptr) {
317#if SKETCH_HAS_LARGE_MEMORY
380#ifndef FASTLED_ACCURATE_CLOCK
416 fl::u32 total_power_mW = 0;
492 static fl::u32 lastframe = 0;
494 if(br++ >= nFrames) {
500 mNFPS = (br * 1000) / now;
513 }
else if(refresh > 0) {
522 return FastLED.getBrightness();
534 FastLED.setMaxPowerInVoltsAndMilliamps(volts, milliamps);
539 FastLED.setMaxPowerInMilliWatts(powerInmW);
561void CFastLED::setDriverEnabled(
const char* name,
bool enabled) {
631 #ifndef FASTLED_SUPPRESS_RUNTIME_DRIVER_WARNING
632 FL_WARN_ONCE(
"FastLED.add(cfg): runtime-selection mode — enrolling every "
633 "available driver via fl::enableAllDrivers(). For minimum "
634 "binary size, prefer FastLED.addLeds<CHIPSET, PIN, ORDER, "
635 "fl::Bus::X>(leds, n) which links only the named driver. "
636 "Suppress this warning with -DFASTLED_SUPPRESS_RUNTIME_DRIVER_WARNING.");
642 "No channel drivers available - channel API requires at least one registered driver");
643 auto channel = fl::Channel::create(config);
652 for (
const auto& config : configs) {
663 for (
const auto& config : configs) {
674 for (
const auto& configPtr : multiConfig.
mChannels) {
692 #if !defined(FL_IS_ESP8266) && !defined(FL_IS_ESP32) && !defined(ARDUINO)
693 extern "C" void __cxa_pure_virtual (
void) {}
699 __extension__
typedef int __guard __attribute__((mode(__DI__)));
701 extern "C" int __cxa_guard_acquire (__guard *)
FL_LINK_WEAK;
702 extern "C" void __cxa_guard_release (__guard *)
FL_LINK_WEAK;
703 extern "C" void __cxa_guard_abort (__guard *)
FL_LINK_WEAK;
705 extern "C" int __cxa_guard_acquire (__guard *g)
707 return !*(
char *)(g);
710 extern "C" void __cxa_guard_release (__guard *g)
715 extern "C" void __cxa_guard_abort (__guard *)
724 #if FASTLED_HAS_ENGINE_EVENTS
731 #if FASTLED_HAS_ENGINE_EVENTS
#define MAX_CLED_CONTROLLERS
FL_LINK_WEAK int atexit(void(*)())
void * pSmartMatrix
Pointer to the matrix object when using the Smart Matrix Library.
fl::u32 _retry_cnt
Global frame retry counter, used for debugging ESP implementations.
static void * gControllersData[MAX_CLED_CONTROLLERS]
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
int noise_max
Unused value.
fl::u32 _frame_cnt
Global frame counter, used for debugging ESP implementations.
int noise_min
Unused value.
ClearFlags
Flags for FastLED.clear() to control what state gets cleared/reset.
@ CHANNELS
Remove all channels from controller list.
@ BRIGHTNESS
Reset global brightness to 255.
@ CHANNEL_ENGINES
Clear all channel drivers from ChannelManager.
@ POWER_SETTINGS
Reset power management (setMaxPowerInMilliWatts)
@ FPS_COUNTER
Reset FPS tracking counter to 0.
@ NONE
Clear nothing (no-op)
@ REFRESH_RATE
Reset refresh rate limiting to unlimited.
CFastLED FastLED
Global LED strip management instance.
central include file for FastLED, defines the CFastLED class/object
fl::UISlider scale("Scale", 4,.1, 4,.1)
Declaration of fl::enableAllDrivers() — enrolls every channel driver available on the current platfor...
#define FL_ASSERT(x, MSG)
ESP32-P4 Parallel IO (PARLIO) LED channel.
static void enableAllDrivers()
Enroll every channel driver available on this platform with ChannelManager.
power_func mPPowerFunc
function for overriding brightness when using FastLED.show();
fl::u32 getEstimatedPowerInMilliWatts(bool apply_limiter=true) const
Get estimated power consumption in milliwatts.
static fl::vector< fl::ChannelPtr > & channels()
stored ChannelPtrs to keep them alive
int size()
Get the number of leds in the first controller.
CRGB * leds()
Get a pointer to led data for the first controller.
bool isDriverEnabled(const char *name) const
Check if a driver is enabled by name.
void onEndShowLeds()
Manually trigger the end show LEDs event.
void setMaxRefreshRate(fl::u16 refresh, bool constrain=false)
Set the maximum refresh rate.
static fl::RxChannelPtr addRx(const fl::RxChannelConfig &config)
Add an RX channel with runtime configuration.
void setTemperature(const CRGB &temp)
Set a global color temperature.
void show()
Update all our controllers with the current led colors.
void onBeginFrame()
Manually trigger the begin frame event.
static void remove(fl::ChannelPtr channel)
Remove a channel from the LED controller list.
void showColor(const CRGB &color, fl::u8 scale)
Set all leds on all controllers to the given color/scale.
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 setExclusiveDriver() FL_NOEXCEPT
Register a single driver at a priority above the platform default (compile-time TU-linking variant).
static void _setWaitSpinBudgetUs(fl::u32 budget_us) FL_NOEXCEPT
fl::u8 mScale
the current global brightness scale setting
void setDither(fl::u8 ditherMode=BINARY_DITHER)
Set the dithering mode.
fl::size getDriverCount() const
Get count of registered channel drivers.
static fl::Watchdog & watchdog()
Access the unified cross-platform watchdog timer.
fl::u32 mNPowerData
max power use parameter
static fl::u32 _getWaitSpinBudgetUs() FL_NOEXCEPT
fl::u16 mNFPS
tracking for current frames per second (FPS) value
fl::u32 mNMinMicros
minimum µs between frames, used for capping frame rates
void init()
Initialize platform-specific subsystems.
static void add(fl::ChannelPtr channel)
Add a Channel-based LED controller (from ChannelPtr)
void clearData()
Clear out the local data array.
int count()
Get how many controllers have been registered.
void wait()
Wait for all channel bus transmissions to complete.
void clear(bool writeData=false)
Clear the leds, wiping the local array of data.
void setCorrection(const CRGB &correction)
Set a global color correction.
::CLEDController & addLeds(::CLEDController *pLed, CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
fl::span< const fl::DriverInfo > getDriverInfos() const
Get full state of all registered channel drivers.
static fl::ChannelEvents & channelEvents()
Access the channel event system.
High level controller interface for FastLED.
CLEDController & setCorrection(CRGB correction) FL_NOEXCEPT
The color corrction to use for this controller, expressed as a CRGB object.
virtual void * beginShowLeds(int size) FL_NOEXCEPT
void clearLedDataInternal(int nLeds=-1) FL_NOEXCEPT
Zero out the LED data managed by this controller.
virtual void endShowLeds(void *data) FL_NOEXCEPT
static CLEDController * mPTail
pointer to the last LED controller in the linked list
CLEDController & setLeds(CRGB *data, int nLeds) FL_NOEXCEPT
Set the default array of LEDs to be used by this controller.
void showLedsInternal(fl::u8 brightness) FL_NOEXCEPT
Write the data to the LEDs managed by this controller.
CLEDController & setDither(fl::u8 ditherMode=BINARY_DITHER) FL_NOEXCEPT
Set the dithering mode for this controller to use.
CLEDController * next() FL_NOEXCEPT
Get the next controller in the linked list after this one.
virtual void init() FL_NOEXCEPT=0
Initialize the LED controller.
virtual fl::u16 getMaxRefreshRate() const FL_NOEXCEPT
Gets the maximum possible refresh rate of the strip.
static void visitControllers(Visitor &&visitor) FL_NOEXCEPT
Visit all controllers in the linked list with a visitor The visitor must be a callable that accepts (...
virtual int size() const FL_NOEXCEPT
How many LEDs does this controller manage?
static CLEDController * mPHead
pointer to the first LED controller in the linked list
CLEDController & setTemperature(CRGB temperature) FL_NOEXCEPT
Set the color temperature, aka white point, for this controller.
static CLEDController * head() FL_NOEXCEPT
Get the first LED controller in the linked list of controllers.
bool getEnabled() FL_NOEXCEPT
void showColorInternal(const CRGB &data, int nLeds, fl::u8 brightness) FL_NOEXCEPT
bool isDriverEnabled(const char *name) const FL_NOEXCEPT
Check if a driver is enabled by name.
void setDriverEnabled(const char *name, bool enabled) FL_NOEXCEPT
Enable or disable a driver by name at runtime.
void setExclusiveDriver() FL_NOEXCEPT
Register a single driver at a priority above the platform default and disable all others (compile-tim...
void reset() FL_NOEXCEPT
Reset bus manager state, clearing all enqueued and transmitting channels.
fl::span< const DriverInfo > getDriverInfos() const FL_NOEXCEPT
Get full state of all registered drivers.
fl::size getDriverCount() const FL_NOEXCEPT
Get count of registered drivers (including unnamed ones)
bool waitForReady(u32 timeoutMs=1000) FL_NOEXCEPT
Wait for all drivers to become READY.
void clearAllDrivers() FL_NOEXCEPT
Remove all drivers from the manager.
Unified channel manager with priority-based driver selection.
static void onStripAdded(CLEDController *strip, fl::u32 num_leds) FL_NOEXCEPT
static void onEndShowLeds() FL_NOEXCEPT
static void onEndFrame() FL_NOEXCEPT
static void onBeginFrame() FL_NOEXCEPT
static RxChannelPtr create(const RxChannelConfig &config) FL_NOEXCEPT
static Watchdog & instance() FL_NOEXCEPT
Unified cross-platform watchdog interface.
shared_ptr< Processor > add(const Config &config) FL_NOEXCEPT
static AudioManager & instance() FL_NOEXCEPT
void remove(shared_ptr< Processor > processor) FL_NOEXCEPT
constexpr fl::size size() const FL_NOEXCEPT
fl::size size() const FL_NOEXCEPT
fl::CLEDController CLEDController
Delay utilities for FastLED Includes nanosecond-precision delays, cycle counting, and microsecond del...
fl::UISlider length("Length", 1.0f, 0.0f, 1.0f, 0.01f)
Task executor — runs registered task runners and manages the run loop.
void show_at_max_brightness_for_power()
Similar to CFastLED::show(), but pre-adjusts brightness to keep below the power threshold.
fl::u32 scale_power_for_brightness(fl::u32 total_mW, fl::u8 brightness)
Applies the configured power-scaling response to a total power value.
void delay_at_max_brightness_for_power(fl::u16 ms)
Similar to CFastLED::delay(), but pre-adjusts brightness to keep below the power threshold.
void set_max_power_in_volts_and_milliamps(fl::u8 volts, fl::u32 milliamps)
Set the maximum power used in milliamps for a given voltage.
void set_max_power_in_milliwatts(fl::u32 powerInmW)
Set the maximum power used in watts.
fl::u32 calculate_unscaled_power_mW(fl::span< const CRGB > leds)
Functions to convert from the HSV colorspace to the RGB colorspace.
Centralized logging categories for FastLED hardware interfaces and subsystems.
Unified manager for channel drivers with priority-based fallback.
fl::u32 getWaitSpinBudgetUs() FL_NOEXCEPT
Get the current tiered-wait spin budget (microseconds).
void setWaitSpinBudgetUs(fl::u32 budget_us) FL_NOEXCEPT
Set the tiered-wait spin budget (microseconds).
void run(fl::u32 microseconds, ExecFlags flags)
Run selected task subsystems.
constexpr remove_reference< T >::type && move(T &&t) FL_NOEXCEPT
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
void delay(u32 ms, bool run_async=true) FL_NOEXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
Bus
Driver identifier for compile-time bus selection.
ChannelManager & channelManager()
Get the global ChannelManager singleton instance.
fl::u32 micros()
Universal microsecond timer - returns microseconds since system startup.
void yield()
Yield to the platform scheduler.
void enableAllDrivers() FL_NOEXCEPT
Register every channel driver available on this platform with ChannelManager, restoring 3....
#define FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS
#define FL_DISABLE_WARNING_PUSH
#define FL_RUN_ONCE(code)
#define FL_DISABLE_WARNING_POP
Configuration for a single LED channel.
static ChannelEvents & instance()
Singleton event router for Channel lifecycle events.
fl::vector< ChannelConfigPtr > mChannels
Vector of shared pointers to channel configurations.
Runtime-tunable microsecond spin budget for the channel-manager and driver wait loops (Phase 1 of #28...
Platform-aware cooperative yield for FastLED.