Store endstop status in a variable
-
Is it possible to store the status of an endstop in a variable?
My goal is to write something like this:
var endstop_status = M119 X if endstop_status = TRIGGERED G1 ..... else G1 .....
Is it possible to base a condition on the status of an endstop?
-
@jan12345
As far as I understand it yes, but you'll (probably) need to reference it from the Object Model.You can define variables within the config.g file , like I do here:
; Variables definition global savedSpindleSpeed = 0 global PausePress = false
But the status of the variable need to be set within the macro that calls it, i.e. in my pause.g file:
; pause.g M42 P8 S0 ; pause/resume LED off set global.PausePress = !global.PausePress ; toggle the value from whatever it was before set global.savedSpindleSpeed = spindles[0].active ; sets the global variable echo "Spindle speed saved at ", {global.savedSpindleSpeed}, "RPM" ; shows saved spindle speed in the Console G1 Z{max(move.axes[2].userPosition+5,move.axes[2].max-5)} F2400 ; move the Z axis to a safe height G0 X273.5 Y560 ; move XY to a safe place M5
Sorry, I'm not a techie, but I hope this helps.
-
@jan12345 said in Store endstop status in a variable:
Is it possible to base a condition on the status of an endstop?
Yes:
if sensors.endstops[0].triggered G1 ... else G1 ...
No need to use a variable unless you want to save the triggered state to use later.