[Advanced]Effect Layer Blending
Effect Layer Blending
If you have ever used image editing software you may be familiar with color blending between image layers. Several common color blending techniques have been added to blend LED layers together. Layers defined in the configuration are ordered top to bottom.
If there are 3 layers defined, the bottom layer is first blended with the middle layer. The resultant layer is then blended with the top. The bottom layer will never be blended with anything even if a blending mode is specified.
Layer blending is always evaluated from the bottom up.
Since values cannot exceed 100% brightness and 0% darkness, they are clamped to this range as a floating-point number ( 0.0 - 1.0 )
Blending Mode | Description | Formula |
---|---|---|
| bottom:No blending; uses the color from the bottom layer. | — |
| top:No blending; uses the color from the top layer. | — |
| add:Color channels (Red, Green, and Blue) are added together, resulting in brighter channels. | top + bottom |
| subtract:The top layer is subtracted from the bottom layer, darkening similar colors. | bottom - top |
| subtract_b:The bottom layer is subtracted from the top layer, darkening similar colors. | top - bottom |
| difference:The darker of the layers is subtracted from the brighter one. | |
| average:The average of the color channels is taken. | (top + bottom) / 2 |
| multiply:The channels are multiplied together, useful for darkening colors. | top * bottom |
| divide:The channels are divided, often brightening colors toward white. | top / bottom |
| divide_inv:Similar to divide, but the bottom layer is divided by the top. | bottom / top |
| screen:Values are inverted, multiplied, and inverted again, resulting in brighter colors. | 1 - (1 - top) * (1 - bottom) |
| lighten:The brighter of the color channels is used. | brighter of (top, bottom) |
| darken:The darker of the color channels is used. | darker of (top, bottom) |
| overlay:Overlay combines multiply and screen, enhancing contrast. | 2 * top * bottom if top > 0.5, else 1 - 2 * (1 - top) * (1 - bottom) |
Sample Configurations
das Blinkenlights
In the event of critical error, all LED strips breath red in unison to provide a visible indicator of an error condition with the printer. This effect is disabled during normal operation and only starts when the MCU enters a shutdown state (currently not supported).
Bed Idle with Temperature
Brightness Controlled By Potentiometer
This is an example of how to combine the Analog Pin effect with layer blending so it controls the brightness of the lights. One could connect a potentiometer to a thermistor port and use the voltage reading from that pin to determine the amount of color to subtract from the base layers. The potentiometer would need to be wired so that when it is turned "down" the voltage on the analog pin is on full output and when it is turned up it is on minimum output. This way, when the potentiometer is "down", the color (1.0, 1.0, 1.0) (Full white) is being subtracted from the colors of the layer, resulting in (0.0, 0.0, 0.0) (Full Black). The effect rate and cutoff would need to be tuned to the specific potentiometer and board combination.
Progress Bar
Using a single strip of LEDs, print progress is displayed as a light blue line over a dark blue background
Last updated