What's new
VORON Design

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members!

Need Help: Trident WLED G-code Toggle

[Sorry long post, so I color coded it]
I built a trident. So far so good. Awesome printer, fun build.
I bought some LED buttons on Ali and figured out how to use them as G-code buttons on the front skirt. Pretty cool. One toggles my case lights on and off (they are connected to a spare HE2 output on my board and run off 24 volts) It was pretty simple to write the IF/AND statement that I use to toggle those on and off seen below in green. It works to turn the case lights on if they happen to be off, and off if they are currently set to more than 10%. It might not be the cleanest way to do it but it works for my purposes of walking up to the printer and making it go dark if I'm walking away for a while, or quickly flicking the lights on when I walk back up to it to check on things.
The code looks like this:
[gcode_macro DAYLIGHT_TOGGLE]
gcode:
{% if printer["output_pin daylight"].value >= 0.1 %}
DAYLIGHT_OFF
{% else %}
DAYLIGHT_ON
{% endif %}


Now, I also have LED lights installed behind my skirts running off WLED. I have the WLED running off an ESP8266. They run through various output effects depending on the state of the print. It's pretty cool to see and I can see them from clear across the room to know what's going on. I followed this guide which was super helpful for setting up the WLED controller and integrating it into Klipper (https://github.com/Gliptopolis/WLED_Klipper).
I have the WLED running via this macro:
[gcode_macro WLED_ON]
description: Turn WLED strip on using optional preset and resets led colors
gcode:
{% set strip = params.STRIP|default("groundeffects")|string %}
{% set preset = params.PRESET|default(4)|int %}

{action_call_remote_method("set_wled_state",
strip=strip,
state=True,
preset=preset)}


Can anyone help me figure out the syntax for an IF/AND statement for a second G-code button to toggle the WLEDS on - off? I'd like them to turn off if they are on, or on to a specific preset if they are off. This is more difficult because they aren't controlled by a simple output pin like my case lights are. I don't understand how to use variables properly or how to save variable states. Any help would be appreciated. The strip name is 'groundeffects'.
I think the code should look roughly like this but this obviously doesn't work as written:
[gcode_macro WLED_TOGGLE]
gcode:
{% if WLED_ON[strip=groundeffects] preset=6 #preset 6 is WLEDs off
WLED_READY #this is a working macro to set the WLEDs to rainbow fade preset
{% else %}
WLED_OFF #this is a working macro to turn off the WLED strips
{% endif %}


Thanks,
DR
 
Top