1#define FASTLED_INTERNAL
21#if SKETCH_HAS_LARGE_MEMORY
32#include "platforms/init.h"
35#include "platforms/is_platform.h"
41#ifndef MAX_CLED_CONTROLLERS
45#if defined(FL_IS_AVR_ATMEGA) && !defined(FL_IS_AVR_ATMEGA_328P)
46#define MAX_CLED_CONTROLLERS 16
48#define MAX_CLED_CONTROLLERS 8
51#define MAX_CLED_CONTROLLERS 64
56volatile fl::u32 fuckit;
60#ifndef FASTLED_NO_ATEXIT
61#define FASTLED_NO_ATEXIT 0
68#ifdef FASTLED_NEEDS_YIELD
69extern "C" void yield(
void) { }
76#if !FL_PLATFORM_HAS_TINY_MEMORY
122#if FL_COLOR_PIPELINE_SHARED
123const fl::FramePowerDispatch*& fl::activeFramePowerDispatch()
FL_NO_EXCEPT {
124 static const FramePowerDispatch* dispatch =
nullptr;
137 return (*
this)[0].size();
141 return (*
this)[0].leds();
147 int nOffset = (nLedsIfOffset > 0) ? nLedsOrOffset : 0;
148 int nLeds = (nLedsIfOffset > 0) ? nLedsIfOffset : nLedsOrOffset;
151 pLed->setLeds(data + nOffset, nLeds);
152 FastLED.setMaxRefreshRate(pLed->getMaxRefreshRate(),
true);
161#if FL_COLOR_PIPELINE_SHARED
165 return channel !=
nullptr ? channel->colorPipeline()
174 for (fl::size i = 0; i < registered.
size(); ++i) {
180 if (
spi ==
nullptr)
return policy;
181 switch (
spi->timing.chipset) {
195 spi->timing.chipset, profile !=
nullptr
218 if (chnls.has(channel)) {
221 chnls.push_back(channel);
240 auto clearFlag = [&flags](
ClearFlags flag) ->
bool {
242 flags =
static_cast<ClearFlags>(
static_cast<fl::u32
>(flags) & ~static_cast<fl::u32>(flag));
252 FastLED.mNPowerData = 0xFFFFFFFF;
253 FastLED.mLastRequestedScale = 255;
281 for (
auto& channel : channelsCopy) {
341#if SKETCH_HAS_LARGE_MEMORY
346 if (elapsed >= minMicros) {
349#if SKETCH_HAS_LARGE_MEMORY
350 const fl::u32 remaining = minMicros - elapsed;
390 ControllerIndex
length = 0;
446 if(pCur ==
nullptr) {
463#if FL_COLOR_PIPELINE_SHARED
464 const fl::FramePowerDispatch* dispatch = fl::activeFramePowerDispatch();
526#ifndef FASTLED_ACCURATE_CLOCK
563 min_field < 1 ? 1 : (min_field > 31 ? 31 : min_field);
571#if FL_COLOR_PIPELINE_SHARED
572 if (apply_limiter &&
mPPowerFunc && fl::activeFramePowerDispatch()) {
573 bool managed =
false;
575 if (p->getEnabled() && fl::channelColorPipeline(*p)) {
584 const fl::u32 mcu_mW = plan.
mcu_mW;
590 fl::u32 controllable_power_mW = 0;
591 fl::u32 dither_reserve_power_mW = 0;
603 const fl::u32 dark_mW = dark_mW_per_led *
static_cast<fl::u32
>(
leds.size());
605 controllable_power_mW += unscaled_mW > dark_mW ? unscaled_mW - dark_mW : 0;
609#if !FL_PLATFORM_HAS_TINY_MEMORY
630 if (effective_brightness != 0) {
690#if SKETCH_HAS_LARGE_MEMORY
691 typedef fl::u32 frame_ms_t;
694 typedef fl::u16 frame_ms_t;
696 static frame_ms_t lastframe = 0;
698 if(br++ >= nFrames) {
699 const frame_ms_t sample =
static_cast<frame_ms_t
>(
fl::millis());
700 frame_ms_t now =
static_cast<frame_ms_t
>(sample - lastframe);
704 mNFPS =
static_cast<fl::u16
>((
static_cast<fl::u32
>(br) * 1000) / now);
723 return FastLED.getBrightness();
735 FastLED.setMaxPowerInVoltsAndMilliamps(volts, milliamps);
740 FastLED.setMaxPowerInMilliWatts(powerInmW);
832 #ifndef FASTLED_SUPPRESS_RUNTIME_DRIVER_WARNING
833 FL_WARN_ONCE(
"FastLED.add(cfg): runtime-selection mode — enrolling every "
834 "available driver via fl::enableAllDrivers(). For minimum "
835 "binary size, prefer FastLED.addLeds<CHIPSET, PIN, ORDER, "
836 "fl::Bus::X>(leds, n) which links only the named driver. "
837 "Suppress this warning with -DFASTLED_SUPPRESS_RUNTIME_DRIVER_WARNING.");
843 "No channel drivers available - channel API requires at least one registered driver");
844 auto channel = fl::Channel::create(config);
853 for (
const auto& config : configs) {
864 for (
const auto& config : configs) {
873 channels.reserve(multiConfig.mChannels.size());
875 for (
const auto& configPtr : multiConfig.mChannels) {
893 #if !defined(FL_IS_ESP8266) && !defined(FL_IS_ESP32) && !defined(ARDUINO)
894 extern "C" void __cxa_pure_virtual (
void) {}
900 __extension__
typedef int __guard __attribute__((mode(__DI__)));
902 extern "C" int __cxa_guard_acquire (__guard *)
FL_LINK_WEAK;
903 extern "C" void __cxa_guard_release (__guard *)
FL_LINK_WEAK;
904 extern "C" void __cxa_guard_abort (__guard *)
FL_LINK_WEAK;
906 extern "C" int __cxa_guard_acquire (__guard *g)
908 return !*(
char *)(g);
911 extern "C" void __cxa_guard_release (__guard *g)
916 extern "C" void __cxa_guard_abort (__guard *)
930 #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::u8 get_brightness() FL_NO_EXCEPT
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.
static void throttleToMaxRefreshRate(fl::u32 minMicros) FL_NO_EXCEPT
fl::u32 _frame_cnt
Global frame counter, used for debugging ESP implementations.
int noise_min
Unused value.
CLEDController * controller
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.
void clear(bool writeData=false) FL_NO_EXCEPT
Clear the leds, wiping the local array of data.
power_func mPPowerFunc
function for overriding brightness when using FastLED.show();
fl::u8 getHdFieldFloor() const FL_NO_EXCEPT
void setExclusiveDriver() FL_NO_EXCEPT
Register a single driver at a priority above the platform default (compile-time TU-linking variant).
void setCorrection(const CRGB &correction) FL_NO_EXCEPT
Set a global color correction.
static void _setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT
static void add(fl::ChannelPtr channel) FL_NO_EXCEPT
Add a Channel-based LED controller (from ChannelPtr)
void show() FL_NO_EXCEPT
Update all our controllers with the current led colors.
void setDriverEnabled(const char *name, bool enabled) FL_NO_EXCEPT
Enable or disable a channel driver by name at runtime.
static fl::ChannelEvents & channelEvents() FL_NO_EXCEPT
Access the channel event system.
void countFPS(int nFrames=25) FL_NO_EXCEPT
For debugging, this will keep track of time between calls to countFPS().
void onEndShowLeds() FL_NO_EXCEPT
Manually trigger the end show LEDs event.
static fl::u32 _getWaitSpinBudgetUs() FL_NO_EXCEPT
static fl::Watchdog & watchdog() FL_NO_EXCEPT
Access the unified cross-platform watchdog timer.
static void remove(fl::ChannelPtr channel) FL_NO_EXCEPT
Remove a channel from the LED controller list.
int size() FL_NO_EXCEPT
Get the number of leds in the first controller.
void clearData() FL_NO_EXCEPT
Clear out the local data array.
void setDither(fl::u8 ditherMode=BINARY_DITHER) FL_NO_EXCEPT
Set the dithering mode.
fl::u8 getLastShowBrightness() const FL_NO_EXCEPT
Brightness the most recent show() / showColor() actually applied, after the power limiter set by setM...
static fl::vector< fl::ChannelPtr > & channels() FL_NO_EXCEPT
stored ChannelPtrs to keep them alive
void onBeginFrame() FL_NO_EXCEPT
Manually trigger the begin frame event.
void showColor(const CRGB &color, fl::u8 scale) FL_NO_EXCEPT
Set all leds on all controllers to the given color/scale.
void wait() FL_NO_EXCEPT
Wait for all channel bus transmissions to complete.
fl::u8 mScale
the current global brightness scale setting
void onEndFrame() FL_NO_EXCEPT
bool isPowerLimited() const FL_NO_EXCEPT
True if the power limiter lowered the brightness of the most recent show() / showColor() below what i...
CRGB * leds() FL_NO_EXCEPT
Get a pointer to led data for the first controller.
void delay(unsigned long ms) FL_NO_EXCEPT
Delay for the given number of milliseconds.
static fl::RxChannelPtr addRx(const fl::RxChannelConfig &config) FL_NO_EXCEPT
Add an RX channel with runtime configuration.
fl::u32 mNPowerData
max power use parameter
fl::u16 mNFPS
tracking for current frames per second (FPS) value
void setMaxRefreshRate(fl::u16 refresh, bool constrain=false) FL_NO_EXCEPT
Set the maximum refresh rate.
void init() FL_NO_EXCEPT
Initialize platform-specific subsystems.
fl::u8 mLastShownScale
brightness the last show()/showColor() applied, after the power limiter
void setTemperature(const CRGB &temp) FL_NO_EXCEPT
Set a global color temperature.
int count() FL_NO_EXCEPT
Get how many controllers have been registered.
fl::u8 mLastRequestedScale
brightness the last show()/showColor() was asked for
CLEDController & operator[](int x) FL_NO_EXCEPT
Get a reference to a registered controller.
::CLEDController & addLeds(::CLEDController *pLed, CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
Add a CLEDController instance to the world.
fl::span< const fl::DriverInfo > getDriverInfos() const FL_NO_EXCEPT
Get full state of all registered channel drivers.
bool isDriverEnabled(const char *name) const FL_NO_EXCEPT
Check if a driver is enabled by name.
fl::u32 getEstimatedPowerInMilliWatts(bool apply_limiter=true) const FL_NO_EXCEPT
Get estimated power consumption in milliwatts.
void setHdFieldFloor(fl::u8 min_field) FL_NO_EXCEPT
Lowest 5-bit current field the colour-managed APA102-HD path may use (B1's flicker floor,...
fl::size getDriverCount() const FL_NO_EXCEPT
Get count of registered channel drivers.
static void enableAllDrivers() FL_NO_EXCEPT
Enroll every channel driver available on this platform with ChannelManager.
fl::u16 mMaxRefreshHz
frame-rate cap in Hz, 0 = unlimited (u16 saves 2 B over micros, #4788)
and refresh rates, and provides access functions for driving led data to controllers via the show() /...
void showColorInternal(const CRGB &data, int nLeds, fl::u8 brightness) FL_NO_EXCEPT
void showLedsInternal(fl::u8 brightness) FL_NO_EXCEPT
Write the data to the LEDs managed by this controller.
static void visitControllers(Visitor &&visitor) FL_NO_EXCEPT
Visit all controllers in the linked list with a visitor The visitor must be a callable that accepts (...
CLEDController & setTemperature(CRGB temperature) FL_NO_EXCEPT
Set the color temperature, aka white point, for this controller.
void clearLedDataInternal(int nLeds=-1) FL_NO_EXCEPT
Zero out the LED data managed by this controller.
static CLEDController * head() FL_NO_EXCEPT
Get the first LED controller in the linked list of controllers.
bool getEnabled() FL_NO_EXCEPT
VIRTUAL_IF_NOT_AVR void * beginShowLeds(int size) FL_NO_EXCEPT
VIRTUAL_IF_NOT_AVR int size() const FL_NO_EXCEPT
How many LEDs does this controller manage?
VIRTUAL_IF_NOT_AVR void endShowLeds(void *data) FL_NO_EXCEPT
CLEDController & setDither(fl::u8 ditherMode=BINARY_DITHER) FL_NO_EXCEPT
Set the dithering mode for this controller to use.
static CLEDController * mPHead
pointer to the first LED controller in the linked list
CLEDController * next() FL_NO_EXCEPT
Get the next controller in the linked list after this one.
CLEDController & setCorrection(CRGB correction) FL_NO_EXCEPT
The color corrction to use for this controller, expressed as a CRGB object.
void removeFromDrawList() FL_NO_EXCEPT
Remove this channel from the global controller draw list.
const EmitterProfile * emitterProfile() const FL_NO_EXCEPT
void addToDrawList() FL_NO_EXCEPT
Add this channel to the global controller draw list.
const ChipsetVariant & getChipset() const FL_NO_EXCEPT
Get the chipset configuration variant.
LED channel for parallel output, pretty much a CPixelLEDController but with timing and pin informatio...
void setDriverEnabled(const char *name, bool enabled) FL_NO_EXCEPT
Enable or disable a driver by name at runtime.
void reset() FL_NO_EXCEPT
Reset bus manager state, clearing all enqueued and transmitting channels.
fl::size getDriverCount() const FL_NO_EXCEPT
Get count of registered drivers (including unnamed ones)
void clearAllDrivers() FL_NO_EXCEPT
Remove all drivers from the manager.
void setExclusiveDriver() FL_NO_EXCEPT
Register a single driver at a priority above the platform default and disable all others (compile-tim...
bool isDriverEnabled(const char *name) const FL_NO_EXCEPT
Check if a driver is enabled by name.
bool waitForReady(u32 timeoutMs=1000) FL_NO_EXCEPT
Wait for all drivers to become READY.
fl::span< const DriverInfo > getDriverInfos() const FL_NO_EXCEPT
Get full state of all registered drivers.
Unified channel manager with priority-based driver selection.
static void onBeginFrame() FL_NO_EXCEPT
static void onStripAdded(CLEDController *strip, fl::u32 num_leds) FL_NO_EXCEPT
static void onEndShowLeds() FL_NO_EXCEPT
static void onEndFrame() FL_NO_EXCEPT
static RxChannelPtr create(const RxChannelConfig &config) FL_NO_EXCEPT
static Watchdog & instance() FL_NO_EXCEPT
Unified cross-platform watchdog interface.
void remove(shared_ptr< Processor > processor) FL_NO_EXCEPT
static AudioManager & instance() FL_NO_EXCEPT
shared_ptr< Processor > add(const Config &config) FL_NO_EXCEPT
static bool isAnyNetworkActive() FL_NO_EXCEPT
fl::size size() const FL_NO_EXCEPT
fl::CLEDController CLEDController
#define FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS
#define FL_DISABLE_WARNING_PUSH
#define FL_RUN_ONCE(code)
#define FL_DISABLE_WARNING_POP
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.
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.
#define FL_DITHER_ENABLE_MIN_REFRESH_HZ
High level controller interface for FastLED.
CFastLED FastLED
Global LED strip management instance.
central include file for FastLED, defines the CFastLED class/object
fl::u32 scale_power_for_brightness(fl::u32 total_mW, fl::u8 brightness) FL_NO_EXCEPT
Applies the configured power-scaling response to a total power value.
void delay_at_max_brightness_for_power(fl::u16 ms) FL_NO_EXCEPT
Similar to CFastLED::delay(), but pre-adjusts brightness to keep below the power threshold.
void set_max_power_in_milliwatts(fl::u32 powerInmW) FL_NO_EXCEPT
Set the maximum power used in watts.
fl::u32 controller_dither_reserve_mW(const fl::CLEDController &controller) FL_NO_EXCEPT
dither_reserve_mW() for a controller that dithers, and zero for one that does not: a mode other than ...
fl::u32 controller_unscaled_power_mW(const fl::CLEDController &controller) FL_NO_EXCEPT
One controller's demand at full brightness, in mW, including idle draw – the quantity the limiter sum...
void set_max_power_in_volts_and_milliamps(fl::u8 volts, fl::u32 milliamps) FL_NO_EXCEPT
Set the maximum power used in milliamps for a given voltage.
void show_at_max_brightness_for_power() FL_NO_EXCEPT
Similar to CFastLED::show(), but pre-adjusts brightness to keep below the power threshold.
PowerModelRGB get_power_model() FL_NO_EXCEPT
Get current RGB power model.
Functions to convert from the HSV colorspace to the RGB colorspace.
#define FL_WARN_ONCE(...)
Centralized logging categories for FastLED hardware interfaces and subsystems.
Unified manager for channel drivers with priority-based fallback.
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
u8 & hdFieldFloor() FL_NO_EXCEPT
Backing store for CFastLED::setHdFieldFloor().
void setWaitSpinBudgetUs(fl::u32 budget_us) FL_NO_EXCEPT
Set the tiered-wait spin budget (microseconds).
fl::u32 getWaitSpinBudgetUs() FL_NO_EXCEPT
Get the current tiered-wait spin budget (microseconds).
u8 ditherFrame() FL_NO_EXCEPT
Return the temporal-dither phase shared by all controllers in this frame.
void yield_system(fl::u32 microseconds) FL_NO_EXCEPT
OS-level yield only: same behavior as run(us, ExecFlags::SYSTEM).
void enableAllDrivers() FL_NO_EXCEPT
Register every channel driver available on this platform with ChannelManager, restoring 3....
u8 u8 fract8 blur_amount FL_NO_EXCEPT
typename conditional< B, T, F >::type conditional_t
void delay(u32 ms, bool run_async=true) FL_NO_EXCEPT
Public delay wrapper that keeps bare Arduino delay() preferred after using fl::delay; while still all...
ChannelManager & channelManager() FL_NO_EXCEPT
Get the global ChannelManager singleton instance.
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
fl::u32 micros() FL_NO_EXCEPT
Universal microsecond timer - returns microseconds since system startup.
u8 hdMinimumField(FiveBitSemantics semantics, u8 floor_setting) FL_NO_EXCEPT
The lowest field the managed HD path may choose: the configured flicker floor for a secondary slow-PW...
Bus
Portable public bus selector.
void yield() FL_NO_EXCEPT
Yield to the platform scheduler.
PowerCodecPolicy powerChannelCodecPolicy(const CLEDController &controller) FL_NO_EXCEPT
Identify the channel's final current/quantization choice without adding a virtual slot or storage to ...
@ LPD6803
LPD6803 LED chipset.
@ APA102HD
APA102 LED chipset with 5-bit gamma correction.
@ DOTSTARHD
APA102HD LED chipset alias.
@ SK9822HD
SK9822 LED chipset with 5-bit gamma correction.
@ LPD8806
LPD8806 LED chipset.
@ HD107HD
Same as APA102HD, but in turbo 40-mhz mode.
FiveBitSemantics fiveBitSemanticsFor(SpiChipset chip, FiveBitSemantics profile) FL_NO_EXCEPT
The 5-bit semantics for chip, with profile overriding the chip's default when it is not NotApplicable...
Result of the shared frame-budget prepass on large-memory managed output.
Cross-platform facade for runtime network activity detection.
static fl::u32 fixed_power_mW(fl::u32 led_count) FL_NO_EXCEPT
fl::u8 dark_mW
Dark LED baseline power consumption, in milliwatts.
Configuration for a single LED channel.
static ChannelEvents & instance() FL_NO_EXCEPT
Singleton event router for Channel lifecycle events.
SPI chipset configuration (data + clock pins)
FiveBitSemantics five_bit_semantics
Runtime-tunable microsecond spin budget for the channel-manager and driver wait loops (Phase 1 of #28...
Platform-aware cooperative yield for FastLED.