New: LED Power / Battery Management
New on the FastLED 2.1 branch: some power management functions which are not yet integrated into the main FastLED APIs, but which are working and useful, especially for battery-powered projects.
Here’s how it works: you specify the maximum power (in milliamps) that you want your LEDs to draw, and then these new functions will automatically adjust the master brightness control to keep the power consumption (approximately) at or below the maximum that you set. Keep your wearable up and running all night!
These functions are not integrated into the FastLED “API” yet – so using these functions will take a little bit of work! But given how many FastLED projects are heading out to the playa, the land of battery power, I wanted to share this code with everyone sooner rather than later. Our hope is to get it eventually integrated in a way that makes it clean for people who want to use it, and zero-cost for people who don’t. In the meantime, it works and you can try it out.
How To Use It
Grab the latest FastLED v2.1 branch from https://github.com/FastLED/FastLED/archive/FastLED2.1.zip and install it, replacing your old FastLED folder. Now…
In setup(), specify the maximum power you want your project to draw, like this:
set_max_power_in_volts_and_milliamps( 5, 500); //5v 500mA
Now comment out your existing calls to FastLED.show() and replace them with this:
show_at_max_brightness_for_power();
Similarly, replace your old calls to FastLED.delay(ms) with this:
delay_at_max_brightness_for_power( ms);
(I told you the new functions weren’t integrated into the FastLED API, didn’t I? Yeah. They’re not. They’re “wrappers” around FastLED.show() and FastLED.delay() right now.)
Now compile and run your code as usual. Everything should work pretty much as before, but with the brightness automatically managed to keep you within the power envelope you’ve specified.
An interesting way to test this is to set the maximum power draw very low, say 100mA, and then re-run your code. How do you know it’s doing anything? Well, funny you should ask…
LED indicator
The new power management functions have a built-in indicator for when the power draw is being capped: the Arduino’s on-board LED (usually on pin 13). When the power cap kicks in, the on-board LED lights up to let you know. You can change the indicator LED pin number with set_max_power_indicator_LED( pin). Setting it to zero disables the indicator function.
Caveats: The new code currently adds roughly 1K to your code size on AVR, and takes up 5 additional bytes of SRAM. The power computations are approximate. They seem about right, if a tad conservative. The API will change.
I’ve tested this code on a few different AVR and ARM boards, at 12 volts and 5 volts, and with power limits ranging from 50mA to 6,000mA, and so far it all seems to work as intended. It has not been exhaustively tested, but it might be worth a few minutes of your time to experiment with it, especially if you have a battery-powered project. As always, please let us know what you find.
Explore
It’s interesting to take your old animation, in which you’ve limited the master brightness control with setBrightness to a lower value, and instead set the brightness (back) to 255, but set the maximum power draw to something lower, like 100mA or 500mA, or 1000mA, and see what you get. Typically you’ll see more dynamic range in pixel brightness, with no additional peak power draw; the dimmest parts won’t be dimmer, but the brightest parts may be brighter!
Please consider this my ‘playa gift’ to you. Let me know if you try it out, and what you find! I have a million ideas for future directions here, but the basic functions are useful enough that I wanted to share them now.

) But I’d say that above 80% of the rated power of the PSU, the power-in vs power-out isn’t going to be anything like linear.