Skip to content

Example code that shows how to get a breathing effect when using FastLED to manage power

Notifications You must be signed in to change notification settings

jethomson/FastLED-managed-power-breathing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

FastLED-managed-power-breathing

Example code that shows how to get a breathing effect when using FastLED to manage power.

If using a FastLED function (e.g. FastLED.setMaxPowerInVoltsAndMilliamps()) to manage how much power your LEDs use FastLED limits the maximum brightness that can be set to a value that does not exceed the requested power draw. So if FastLED determines your power limited maximum brightness is M then calling setBrightness() with a value greater than M will result in FastLED setting the brightness to exactly M.

A breathing effect ramps the brightness up until it reaches the maximum brightness then ramps the brightness back down to a minimum brightness then starts the whole cycle over again. A naive approach would be to use a triangle wave that goes from 0 to 255 and back down to 0 as the input for setBrightness(), but if the power limited maximum brightness M is less than 255 then the brightness will plateau at M, and the brightness will remain fixed until the triangle wave input falls below M again. My breathing() function achieves a continually changing brightness by setting the peak of the triangle wave to M. However, M changes based on the number of LEDs currently lit and their colors, so breathing() recalculates M before setting a new brightness value.

FastLED's notes on power management
Power management functions documentation

About

Example code that shows how to get a breathing effect when using FastLED to manage power

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages