M291, non-blocking with a timer?
-
I'm trying to write a macro this will execute one code path if a user responds to a message and execute a different code path if the user does not respond. The idea is to have a series of things the printer will do at power-on ( heat bed, home, level bed, create mesh), but that there will be occasions when the user wants to skip one or more of these steps.
I think it might not be possible at all, but I thought I'd ask here. I've been looking at M291 and I can implement two code paths if I use a blocking mode like S=3 or S=4, but it requires the user to make a choice at each step. I want to give the user an amount of time and if they don;t respond, continue.
One thought is that I could use a non-blocking message like S=1 if I put it in a delay loop and checked on every iteration whether the user has selected the "Close" button. Is this possible with 3.5?
-
@mikeabuilder Something like this?
var now = state.time M291 S2 T5 P"Confirm or ignore" if state.time - var.now >= 5 echo "Prompt ignored" else echo "Prompt confirmed"
-
@chrishamm - This is precisely what I'm looking for - a solution, and better than the one I was contemplating.
One question about the solution, though. I noticed a different behavior in RRF3.5 (works) vs RRF3.4 (did not work). In the gcode dictionary, M291 with S=2 is described as blocking, and the T parameter is supposed to be ignored for S=2 or S=3. For the code above to work, I think the T parameter is not being ignored. Is this a change in RRF 3.5?
-
@mikeabuilder Yes, I think it is a change from 3.5. The messagebox implementation is different from 3.4 because of the new types that are now supported but TBH I wasn't aware that T was supposed to be ignored before for S=2 and S=3. I'll check the docs again.
-