How to create a conditional "jog_command"



  • I am working on a custom UI where buttons and actions are conditional. I pretty much have it working except for "type": "jog"

    Below is an example. The button classes behave as I want. What I cannot figure out (having tried all manner of variations, positions, "state" vs "tolerance" etc. ) is to create a conditional "jog_command". Specifically - I want to disable the jog buttons unless a specific condition applies.

    I'm almost of the opinion that it is not possible given the current definition for "type": "jog" but my skill level does not extend to properly analyzing the underlying js code.

    Any suggestions ?

    {
    	"id": "babystep_z_p",
    	"type": "jog",
    	"position": {
    		"my": "left top",
    		"at": "left+15 top+60",
    		"of": "#baby_steps_panel"
    	},
    	"button_defaults": {
    		"state": {
    			"states": [
    				{ "state": 0, "classes": "btn-warning"
    				},
    				{ "state": 1, "classes": "btn-success"
    				}
    			],
    			"field": "${(state.move.axes[2].babystep !== 0 ) ? 0 : 1 }"
    		},
    		"style": {
    			"width": "10ch",
    			"height": "4em",
    			"padding": "5px",
    			"margin-top": "12px"
    		}
    	},
    	"axis": "Z",
    	"values": [
    		[-0.05,{
    			"type": "button",
    			"id": "babystep_reset",
    			"value": "<-->",
    		},0.05]
    	],
    	"jog_command": "M290 ${axis}${position} R1;M290",
    	"direction": "row"
    },
    


  • I'm gonna have to think about this one a bit. What condition do you want to use as the control for enabled/disabled?



  • Essentially - the ideal behavior would be to be able to place (or not) a jog_command inside a state array (or similar contruct) i.e. so that it behaves more-or-less as an action.

    If there were "n" states then there might be "n" or less variants of the jog_command. Or not even use jog_command per se but just a selective action as can be done for buttons.

    e.g. similar to this type of construct

    {
    	"id": "pause",
    	"type": "button",
    	"style": {
    		"width": "13ch"
    	},
    	"position": {
    		"my": "left top",
    		"at": "left bottom+15",
    		"of": "#elapsed_label"
    	},
    	"state": {
    		"states": [
    			{ "state": 0, "classes": "btn-danger", "value": "PAUSE",
    				"actions": {"type": "gcode", "gcode": "M25"}
    			},
    			{ "state": 1, "classes": "btn-warning", "value": "Paused"
    			},
    			{ "state": 2, "classes": "btn-primary", "value": "Pause"
    			}
    		],
    		"field": "${['processing', 'resuming'].includes(state.state.status) ? 0 : (['paused', 'pausing'].includes(state.state.status) ? 1 : 2 ) }"
    	}						
    },
    


  • Gotcha. Let me investigate.


Log in to reply