FastLED 3.9.15
Loading...
Searching...
No Matches
power_mgt.cpp.hpp File Reference
#include "led_sysdefs.h"
#include "pixeltypes.h"
#include "controller.h"
#include "fastpin.h"
#include "fl/system/sketch_macros.h"
#include "fl/stl/int.h"
#include "power_mgt.h"
#include "fl/stl/singleton.h"
+ 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.

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.
 

Functions

fl::u8 calculate_max_brightness_for_power_mW (const CRGB *ledbuffer, fl::u16 numLeds, fl::u8 target_brightness, fl::u32 max_power_mW)
 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)
 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)
 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_power_mW (const CRGB *ledbuffer, fl::u16 numLeds)
 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)
 
PowerModelRGB get_power_model ()
 Get current RGB power model.
 
float get_power_scaling_exponent ()
 Get the current brightness-to-power response exponent.
 
void set_max_power_indicator_LED (fl::u8 pinNumber)
 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)
 Set custom RGB LED power consumption model.
 
void set_power_scaling_exponent (float exponent)
 Set a non-linear brightness-to-power response exponent.
 

Variables

static fl::u8 gMaxPowerIndicatorLEDPinNumber = 0
 
static const fl::u8 gMCU_mW = 25 * 5
 

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:27
static PowerModelRGBgPowerModel ()
 Global RGB power model (initialized to WS2812 @ 5V defaults, linear response)
 
static constexpr float kLinearPowerScalingExponent = 1.0f
 
static constexpr float kPowerScalingExponentEpsilon = 0.0001f
 
static fl::u8 map_power_value (fl::u8 brightness)
 
fl::u32 scale_power_for_brightness (fl::u32 total_mW, fl::u8 brightness)
 Applies the configured power-scaling response to a total power value.
 
static fl::u8 unmap_power_value (fl::u8 scaled_brightness)