PSU toggle based on printer status condition
-
I want to write a macro that toggles the PSU On/Off based on the status of the printer.
It should be a single toggle macro instead of two separate macros for on and off because I want it to be triggered by a momentary switch.At the moment I already have a working toggle macro based on the current voltage of the internal 12V line (note that my PSU has inverted on/off levels):
if {boards[0].v12.current < 11.5} M81 else M80
I now want to change the condition to the status of the printer like
if {state.status == off} M81 elif {state.status == idle} M80 else M117 "prohibited!"
But unfortunately the comparing of the status isn't working I guess because of type incompatibilities.
I also tried setting "off" and "idle" in quotation marks which did not work either. Can someone help me out here?
Using RRF3.2.2 btw. -
okay upon further testing I noticed that
1: Quatation marks are required as expected
2: comparing the status to a string is working but only if the status is "off"In this example
if {state.status == "off"} M81 elif {state.status == "idle"} M80 else M291 R"prohibited" P"PSU toggle is only allowed in standby or idle state"
M81 will work if the printer is in off state (and then turn my PSU on resulting in the printer being now in idle state).
However if I run the macro again it will give me the message instead of running M80 to turn the PSU off again, although the printer is in idle state (checked that in the object model browser and by sendingM117 {status.state}
over DWC.
Checked spelling of the four letters thrice and also tried "Idle" instead of "idle"...
Am I completely blind or is there something to it that messes with the comparison of the word idle?EDIT: found the root cause
when running the macro (no matter how short it is) the state of course changes to busy but only if the board is not only on standby power (intentionally?)
now I only need to find a way that the busy state of running the macro is not confused with an actual busy state... -
My solution for now if anyone is interested
if state.status == "off" M81 elif state.status == "busy" ; state can't be idle because controller is busy running this macro M400 ; wait for all movement to stop if heat.heaters[1].current < fans[1].thermostatic.lowTemperature ; check for all tool based thermostatic fans to be off M80 else M291 R"Prohibited" P"PSU toggle is only allowed in standby or idle state! Wait for cooldown of hotend." else M291 R"Prohibited" P"PSU toggle is only allowed in standby or idle state!"