A command to wait for a variable update

Basic Information:

Printer Model: Custom
MCU / Printerboard: SKR Pico 1.0

Describe your issue:

This is a general gcode macro question, not specific to my printer.

My understanding is that if you have a screen attached you can generate a menu and stall gcode execution while waiting for user input. However, if you only interact with klipper through Mainsail, then there is no equivalent “wait for a user input”, or “wait for a variable to change” function.

I’ve tried PAUSE, but it doesn’t actually wait unless a print is currently running. Adapting this, or making a similar command would be very helpful, since some operations can occur outside of printing, but still in a sequence (e.g. manually attaching/removing a probe during homing).

Generating recursive loops are not allowed, so I can’t abuse G4 (dwell) for a check-then-wait loop.
delayed_gcode does allow infinite loops, but as far as I can tell it’s unable to block other gcode from running since the loop is not one “continuous” command.

Another thought is that I could try to generate a “dummy print” that is the bare-minimum to register whatever is required for PAUSE to work, though this is also very hacky.

Have I missed any current functionality for a wait-for-input command (using only a web UI, not a screen)? If not, are there any plans to implement one? (Should this be in another category?)

1 Like

Hi there. Just stumbled into this post while looking into how to write a macro to manually place a probe before the print starts. Having issues with PAUSE just as you describe. Did you find a solution?.

You need to understand following statement provided in documentation.

Important! Macros are first evaluated in entirety and only then are the resulting commands executed. If a macro issues a command that alters the state of the printer, the results of that state change will not be visible during the evaluation of the macro. This can also result in subtle behavior when a macro generates commands that call other macros, as the called macro is evaluated when it is invoked (which is after the entire evaluation of the calling macro).

1 Like