Hidden macro's not working

Basic Information:

Printer Model: CR-30
MCU / Printerboard: Creality V4.2.10
klippy.log - attached

Describe your issue:

I have a loop macro that uses M808 and it works fantastic. However, when I try to hide it from being displayed on Klipper screen and Mainsail by adding an underscore (_M808) the macro no longer runs. With the underscore, the program just ignores the M808 command and ends. I am running off of a Creality Sonic Pad so I’m not sure if that has anything to do with this. Does anyone else have this issue? Thanks!

This works:

‘Marlin’ style M808 compatibility macro for SDCard looping

[gcode_macro M808]
gcode:
{% if params.K is not defined and params.L is defined %}SDCARD_LOOP_BEGIN COUNT={params.L|int}{% endif %}
{% if params.K is not defined and params.L is not defined %}SDCARD_LOOP_END{% endif %}
{% if params.K is defined and params.L is not defined %}SDCARD_LOOP_DESIST{% endif %}

This does not work:

‘Marlin’ style M808 compatibility macro for SDCard looping

[gcode_macro _M808]
gcode:
{% if params.K is not defined and params.L is defined %}SDCARD_LOOP_BEGIN COUNT={params.L|int}{% endif %}
{% if params.K is not defined and params.L is not defined %}SDCARD_LOOP_END{% endif %}
{% if params.K is defined and params.L is not defined %}SDCARD_LOOP_DESIST{% endif %}

Gcode:
M104 S220 ; set nozzle temp
M140 S70 ; set bed temp
M109 S220 ; wait for nozzle to reach temp
M190 S70 ; wait for bed to reach tmp
G28 ; go to home position
G0 Y0 ; move nozzle to belt if negative offsets used
G92 X0 Y0 Z0 E0 ; zero out all axes (include extruder)
M83 ; set extruder to relative coordinates
M808 L100 ; start repeat
G92 Z0 ; Z needs to start at 0 at the start of the loop
G0 X215 E40 F800 ; extrude to “left” of belt
G0 Z5 E2 ; extrude short Z line
G0 X5 E40 ; extrude to “right” of belt
G0 Z10 E2 ; extrude short Z line
M808 ; go to loop start (M808 above)
M221 T0 S100 ; flow percentage to 100%
M104 S0 ; hotend temp to 0
M140 S0 ; bed temp to 0
M107 ; fans off
G91 ; incremetal positionng
G1 E-1 F300 ;
G1 Z+0.5 E-5 F300.00 ;
G90 ; absolute positioning
G28 Y0 ; home y
G28 X0 ; home x
M84 ; disable steppers

klippy (8).log (29.6 KB)

Your macro will still work if you call it, but you’ve given it a different name so you have to call it using the name you gave it (_M808), which your code is not doing. This is probably not what you want (it’s not really a compatibility macro at that point), so you should just leave it defined with the correct name and manually hide it in the interface.

1 Like

You can’t manually hide it in Klipperscreen any other way than using the underscore.

Mainsail also gives the same exact instructions for hiding a macro.

I don’t use KlipperScreen, but I think you need to take another look. Both sets of documentation that you linked say that it’s possible. For KlipperScreen: “As you probably already noticed, you can show and hide the gcode macros in the interface settings, but you can also hide gcode macros by prefixing the name with an underscore.” For Mainsail: “You can show and hide G-Code macros in the interface settings. Did you know, that you can also hide G-Code macros by prefixing the name with an underscore?”

Here’s the Mainsail settings:

I should have mentioned in my first post that the Creality Sonic screen doesn’t allow you to hide macros individually like a regular Klipper screen install. You can only hide all of them or use the _.

Please not this:

Oh my, I didn’t realize that the Sonic Pad was running on outdated versions. That explains a lot of the bugs I’ve run into. As the underscore is a suggestion in both Mainsail and Klipper screen as a way to hide macros it would be nice if Klipper ignored leading underscores for macro names. However, changing this wouldn’t fix the outdated sonic pad so it’s a moot point