bed_mesh is an attribute of the printer object, which is why this line checks to see if the printer object has a bed_mesh attribute before trying to interact with it.
When it comes to actually interacting with it, you have to access it as an attribute of the printer object: printer.bed_mesh
Oh my gosh, Iām such a dumb⦠Thank you. I havenāt been able to test it with the revised code, but that is it I bet. I forgot the freaking printer objectā¦
Iām struggling with syntax to combine literal strings with numeric variables. Have googled till my fingers are sore, looked at a zillion examples, and tried every imaginable combination of quotes, apostrophes, brackets, braces, plus signs, tildes, ("'{}+~) and more. I have tried combining into new string variables first, etc. Nothing works. Either Klipper throws an error when restarting, or an error when running the macro, or I just get blank results.
Here is my latest of many attempts. Should be pretty obvious what Iām attempting.
[gcode_macro SEND_THIS]
gcode:
# This Works!
#SHOW_THIS S="This works without any parameters"
# But none of of this does. What is syntax to include variables??
SHOW_THIS S='The bed is currently at ' + {bed_temp} + ' degrees Celsius.'
#{ set qq = "Hello World" }
#qq: "Hello World"
#qq: 'The bed is currently at' + {bed_temp} + "Degrees Celsius" %}
#qq: ["The bed is currently at " + {bed_temp} + "Degrees Celsius"]
#SHOW_THIS {qq}
#SHOW_THIS S='The bed is ' ~ bed_temp
[gcode_macro SHOW_THIS]
gcode:
M117 {params.S}
Youāre overcomplicating things. If you want to include the value of the variable bed_temp, the syntax is { bed_temp }.
Everything outside of Jinja delimiters is a static string, so you canāt (and donāt need to) put operators or extra quotes or anything else to indicate concatenation.
SHOW_THIS S="The bed is currently at {bed_temp} degrees Celsius."
If you really want to do the concatenation in Jinja itās possible, but you have to enclose the whole expression in the Jinja delimiters and overall itās going to be less readable.
SHOW_THIS S="{ "The bed is currently at" ~ bed_temp ~ "degrees Celsius." }"
@garethky Hi! I have 4 servos, controlling each separately is not very convenient and not so elegant. Iāve been thinking about your way of using objects for my task for a while, but I canāt find a way. Now I have:
and then
{% for servo in servos -%}
with the transmission of the servo number and the corresponding conditions through a variable of the complex data type. Do you think there is a way to implement this?