Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    How to create a conditional "jog_command"

    Scheduled Pinned Locked Moved
    DueUI
    2
    4
    440
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stuartofmtundefined
      stuartofmt
      last edited by

      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"
      },
      
      1 Reply Last reply Reply Quote 0
      • gtj0undefined
        gtj0
        last edited by

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

        1 Reply Last reply Reply Quote 0
        • stuartofmtundefined
          stuartofmt
          last edited by stuartofmt

          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 ) }"
          	}						
          },
          
          1 Reply Last reply Reply Quote 0
          • gtj0undefined
            gtj0
            last edited by

            Gotcha. Let me investigate.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Unless otherwise noted, all forum content is licensed under CC-BY-SA