M291: cancel vs timeout
-
Is there any way to tell if a dialog box with a cancel button has been cancelled or it has timed out?
-
-
@Leonard03 from the documentation:
Jn (RRF 3.5 and later only, optional) If message box mode >= 4: 0 = no Cancel button (default), 1 = display a Cancel button (job/macro is cancelled immediately when pressed or when it times out); 2 (RRF 3.6.0-beta.3 and later) = dispay a Cancel button (result variable is set to -1 when pressed or when timeout is reached).
So not from the result.
You could check the time before and after and see if the timeout length was reached but that's not necessarily foolproof.
Why do you need to distinguish between those options?
-
@T3P3Tony Thank you for your replay
Regarding checking the time, I already tried this using daemon, but if a blocking dialog is already active, the response from daemon is somehow in background, so I need to do something with the active one and after that daemon can show its dialog.
In short: I would like to do a "heater timeout" to cool the nozzle if I'm not around the printer if an event has occurred.
The long version:
If manual cancel and the timeout can be distinct, it would be possible to distinguish between an "automatic" action or an user input.Lets take the case of a filament runout:
Just lift the nozzle a bit and wait there, at temperature, but Without pausing.
if I am around the printer when the runout has occurred I can tell the printer to reload a new spool and continue, without pausing the job (parking the nozzle).
Else if, I am around the printer but I don't have a new spool prepared at hand.
in this case, park the nozzle but keep the heater on.
Else, if I'm not around pause the print AND turn off the hotend heater, eg. overnightMy particular case is this:
while true M98 P"0:/sys/MMU Control/moveIdler.g" S5 M291 P"FINDA didn't switch off while unloading filament. Try unloading manually. Ensure filament can move and FINDA works." R"FINDA FILAM. STUCK" S4 J0 K{"Retry","PAUSE",} F0 if input = 0 M98 P"0:/sys/MMU Control/moveIdler.g" S0 M98 P"0:/sys/MMU Control/unloadToPTFE.g" if global.errQueue[#global.errQueue-1] != "FINDA_FILAMENT_STUCK" break else continue else set global.tcBlock = true if state.status = "processing" set global.pause = true M226 break
If lets say the cancel button can set the result = -1 and the timeout can set the result = -2 the above can be changed to this
while true M98 P"0:/sys/MMU Control/moveIdler.g" S5 M291 P"FINDA didn't switch off while unloading filament. Try unloading manually. Ensure filament can move and FINDA works." R"FINDA FILAM. STUCK" S4 J2 K{"Retry",} F0 T600 if input = 0 ; retry button M98 P"0:/sys/MMU Control/moveIdler.g" S0 M98 P"0:/sys/MMU Control/unloadToPTFE.g" if global.errQueue[#global.errQueue-1] != "FINDA_FILAMENT_STUCK" break else continue elif result = -1 ; cancel button, pause the print set global.tcBlock = true if state.status = "processing" set global.pause = true M226 break elif result = -2 ; timeout after 10 minutes, pause the print set global.tcBlock = true if state.status = "processing" M568 P0 A0 ;turn off heater 0 set global.pause = true M226 break
-
@Leonard03 thanks for the example. I can see how it could be useful. Once concern with making (for example) user action rather than timeout -2 would be a breaking change where peoples existing scripts would not work if they explicitly checked for -1.
Lets see what @dc42 thinks - there may be another way to achieve what you need.
-
@T3P3Tony That's fantastic, thank you!
@T3P3Tony said in M291: cancel vs timeout:
Once concern with making (for example) user action rather than timeout -2 would be a breaking change where peoples existing scripts would not work if they explicitly checked for -1
I thought about that and there might be some ideas for this.
First, don't include an timeout in the M291 line, so the result can never be -2 for example.
Second, in existing macros that works, the only modification that might need is instead of anresult = -1
toresult <= -1
so the behavior might remain unchanged (right?)
Those are only my ideas. Any feedback is welcomed