FastLED 3.9.15
Loading...
Searching...
No Matches
power_mgt.cpp File Reference

Detailed Description

Functions to limit the power used by FastLED.

Definition in file power_mgt.cpp.

#include "FastLED.h"
#include "power_mgt.h"
#include "fl/namespace.h"
+ Include dependency graph for power_mgt.cpp:

Go to the source code of this file.

Macros

#define FASTLED_INTERNAL
 Disables pragma messages and warnings.
 
#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

uint8_t calculate_max_brightness_for_power_mW (const CRGB *ledbuffer, uint16_t numLeds, uint8_t target_brightness, uint32_t 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.
 
uint8_t calculate_max_brightness_for_power_mW (uint8_t target_brightness, uint32_t max_power_mW)
 Determines the highest brightness level you can use and still stay under the specified power budget for all sets of LEDs.
 
uint8_t calculate_max_brightness_for_power_vmA (const CRGB *ledbuffer, uint16_t numLeds, uint8_t target_brightness, uint32_t max_power_V, uint32_t 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.
 
uint32_t calculate_unscaled_power_mW (const CRGB *ledbuffer, uint16_t numLeds)
 Determines how many milliwatts the current LED data would draw at max brightness (255)
 
void delay_at_max_brightness_for_power (uint16_t ms)
 Similar to CFastLED::delay(), but pre-adjusts brightness to keep below the power threshold.
 
void set_max_power_in_milliwatts (uint32_t powerInmW)
 Set the maximum power used in watts.
 
void set_max_power_in_volts_and_milliamps (uint8_t volts, uint32_t milliamps)
 Set the maximum power used in milliamps for a given voltage.
 
void set_max_power_indicator_LED (uint8_t pinNumber)
 Select a pin with an LED that will be flashed to indicate that power management is pulling down the brightness.
 
void show_at_max_brightness_for_power ()
 Similar to CFastLED::show(), but pre-adjusts brightness to keep below the power threshold.
 

Variables

static uint8_t gMaxPowerIndicatorLEDPinNumber = 0
 
static const uint8_t gMCU_mW = 25 * 5
 
Power Usage Values

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're welcome to adjust these values as needed; there may eventually be an API for changing these on the fly, but it saves codespace and RAM to have them be compile-time constants.

static const uint8_t gBlue_mW = 15 * 5
 15mA @ 5v = 75mW
 
static const uint8_t gDark_mW = 1 * 5
 1mA @ 5v = 5mW
 
static const uint8_t gGreen_mW = 11 * 5
 11mA @ 5v = 55mW
 
static const uint8_t gRed_mW = 16 * 5
 16mA @ 5v = 80mW