[gcode_macro SetLED]
description: Set LED colors and area
gcode:
{% set S = params.Start|default(0)|int %}
{% set E = params.End|default(13)|int %}
{% set R = params.Red|default(0)|float %}
{% set G = params.Green|default(0)|float %}
{% set B = params.Blue|default(0.5)|float %}
{% for cnt in range(S, E) %}
SET_LED LED=my_neopixel RED={R} GREEN={G} BLUE={B} INDEX={cnt+1} TRANSMIT=1
{% endfor %}
have one LED strip with 25 LEDs. The macro is just for play, trying out, and stuff for later use. With the macro and its 5 parameters, I want to set the colors of a certain LED range. For example, set the first 13 LEDs to blue and the other 12 to white.
When I replace the default numbers and only press send, it works as expected. However, if I type in another number (between 0.0 and 1.0, of course) using the parameter dropdown window and press send, nothing happens. All LEDs turn off, and that’s it. Does anyone have an idea what is wrong?
[gcode_macro SetLED]
description: Set LED colors and area
gcode:
{% set S = params.START|default(0)|int %}
{% set E = params.END|default(13)|int %}
{% set R = params.RED|default(0)|float %}
{% set G = params.GREEN|default(0)|float %}
{% set B = params.BLUE|default(0.5)|float %}
{% for cnt in range(S, E) %}
SET_LED LED=my_neopixel RED={R} GREEN={G} BLUE={B} INDEX={cnt+1} TRANSMIT=1
{% endfor %}
And then invoke with: SetLED START=0 END=25 RED=1 GREEN=1 BLUE=1
According to the Command Templates documentation, “parameter names are always in upper-case when evaluated in the macro . . . .”