FastLED 3.10.8
Loading...
Searching...
No Matches
power_mgt.cpp.hpp File Reference
+ Include dependency graph for power_mgt.cpp.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  RgbwwEmitterPower
 
struct  WhiteEmitterPower
 The white emitter's draw, when the caller declared one. More...
 

Macros

#define POWER_DEBUG_PRINT   0
 Debug Option: Set to enable Serial debug statements for power limit functions.
 
#define POWER_LED   1
 Debug Option: Set to 1 to enable the power limiting LED.
 

Typedefs

typedef fl::conditional< sizeof(fl::size)<=2, fl::u32, fl::u64 >::type dither_acc_t
 
typedef fl::u32(* rgbw_power_fn) (fl::span< const CRGB >, const fl::Rgbw &)
 

Functions

static void apply_rgb_power_model (const PowerModelRGB &model) FL_NO_EXCEPT
 
static fl::u8 brightness_within_budget (fl::u32 fixed_mW, fl::u32 controllable_mW, fl::u8 target_brightness, fl::u32 max_power_mW) FL_NO_EXCEPT
 
fl::u8 calculate_max_brightness_for_power_mW (const CRGB *ledbuffer, fl::u16 numLeds, fl::u8 target_brightness, fl::u32 max_power_mW) FL_NO_EXCEPT
 Determines the highest brightness level you can use and still stay under the specified power budget for a given set of LEDs.
 
fl::u8 calculate_max_brightness_for_power_mW (fl::u8 target_brightness, fl::u32 max_power_mW) FL_NO_EXCEPT
 Determines the highest brightness level you can use and still stay under the specified power budget for all sets of LEDs.
 
fl::u8 calculate_max_brightness_for_power_vmA (const CRGB *ledbuffer, fl::u16 numLeds, fl::u8 target_brightness, fl::u32 max_power_V, fl::u32 max_power_mA) FL_NO_EXCEPT
 Determines the highest brightness level you can use and still stay under the specified power budget for a given set of LEDs.
 
fl::u32 calculate_unscaled_emitter_power_mW (fl::span< const fl::u8 > codes, fl::u8 emitter_count) FL_NO_EXCEPT
 Charge already-solved physical output bytes in source emitter order: RGB, RGBW, or RGB + warm white + cool white.
 
fl::u32 calculate_unscaled_power_mW (const CRGB *ledbuffer, fl::u16 numLeds) FL_NO_EXCEPT
 Determines how many milliwatts the current LED data would draw at max brightness (255)
 
fl::u32 calculate_unscaled_power_mW (fl::span< const CRGB > leds) FL_NO_EXCEPT
 Determines how many milliwatts the current LED data would draw at max brightness (255)
 
fl::u32 calculate_unscaled_power_mW (fl::span< const CRGB > leds, const fl::Rgbw &rgbw) FL_NO_EXCEPT
 Same, for a strip driven through the RGBW conversion.
 
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 BINARY_DITHER, or an active RGBW/RGBWW conversion (which reads the raw pixel on every non-AVR target).
 
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 sums and scales.
 
fl::u32 dither_reserve_mW (fl::span< const CRGB > leds) FL_NO_EXCEPT
 The most BINARY_DITHER can add to one latched frame of leds, in mW (#4342, contract R4: "quantization reserve").
 
static fl::u32 fixed_power_mW (fl::u32 led_count) FL_NO_EXCEPT
 
 FL_STATIC_ASSERT (sizeof(fl::size) > 2||65535ull *3u *255u *kDitherReserveCodes+255u<=0xFFFFFFFFull, "dither reserve must fit 32 bits on 16-bit-size targets")
 
PowerModelRGB get_power_model () FL_NO_EXCEPT
 Get current RGB power model.
 
float get_power_scaling_exponent () FL_NO_EXCEPT
 Get the current brightness-to-power response exponent.
 
fl::u8 get_white_emitter_mW () FL_NO_EXCEPT
 The white-emitter draw the caller declared, or zero if they declared only an RGB model.
 
fl::u32 power_ratio_of_255 (fl::u32 num, fl::u32 den) FL_NO_EXCEPT
 min(255, floor(255 * num / den)) for den > 0, computed in 32-bit arithmetic.
 
void set_max_power_indicator_LED (fl::u8 pinNumber) FL_NO_EXCEPT
 Select a pin with an LED that will be flashed to indicate that power management is pulling down the brightness.
 
void set_power_model (const PowerModelRGB &model) FL_NO_EXCEPT
 Set custom RGB LED power consumption model.
 
void set_power_model (const PowerModelRGBW &model) FL_NO_EXCEPT
 Set custom RGBW LED power consumption model.
 
void set_power_model (const PowerModelRGBWW &model) FL_NO_EXCEPT
 Set custom RGBWW LED power consumption model.
 
void set_power_scaling_exponent (float exponent) FL_NO_EXCEPT
 Set a non-linear brightness-to-power response exponent.
 

Variables

static fl::u8 gMaxPowerIndicatorLEDPinNumber = 0
 
static const fl::u8 gMCU_mW = 25 * 5
 
static rgbw_power_fn gRgbwPowerEstimate = nullptr
 
static constexpr fl::u32 kDitherReserveCodes = 2
 

Power Usage Values

Disables pragma messages and warnings

These power usage values are approximate, and your exact readings will be slightly (10%?) different from these.

They were arrived at by actually measuing the power draw of a number of different LED strips, and a bunch of closed-loop-feedback testing to make sure that if we USE these values, we stay at or under the target power consumption. Actual power consumption is much, much more complicated and has to include things like voltage drop, etc., etc. However, this is good enough for most cases, and almost certainly better than no power management at all.

You can now customize these values using the PowerModel API:

FastLED.setPowerModel(PowerModelRGB(40, 40, 40, 2)); // WS2812B @ 3.3V
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
RGB LED power consumption model Used for standard 3-channel LEDs (WS2812, WS2812B,...
Definition power_mgt.h:30
static void emitter_power_weights (fl::u8 count, fl::u8(&weights)[5]) FL_NO_EXCEPT
 
static PowerModelRGB & gPowerModel () FL_NO_EXCEPT
 Global RGB power model (initialized to WS2812 @ 5V defaults, linear response)
 
static RgbwwEmitterPower & gRgbwwEmitterPower () FL_NO_EXCEPT
 
static WhiteEmitterPower & gWhiteEmitterPower () FL_NO_EXCEPT
 
static constexpr float kLinearPowerScalingExponent = 1.0f
 
static constexpr float kPowerScalingExponentEpsilon = 0.0001f
 
static fl::u8 map_power_value (fl::u8 brightness) FL_NO_EXCEPT
 
static fl::u8 max_power_step () FL_NO_EXCEPT
 What one output code can cost at the steepest point of the response, in the 0-255 scaled units calculate_unscaled_power_mW multiplies by.
 
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.
 
static fl::u8 unmap_power_value (fl::u8 scaled_brightness) FL_NO_EXCEPT
 

Class Documentation

◆ RgbwwEmitterPower

struct RgbwwEmitterPower
+ Collaboration diagram for RgbwwEmitterPower:
Class Members
bool declared = false
PowerModelRGBWW model

◆ WhiteEmitterPower

struct WhiteEmitterPower
Class Members
u8 mW