Function
Execute actions in simCNC from a hardware button, wired into the CSMIO controller.
Setup
- Open the settings and navigate to PyActions
- Click „add“ to add a new action
- Give it a meaningful name
- Set event to „IO Change“
- Select a port from your CSMIO, MPG module or extension module. If the button is wired correctly, the LED will light up if you press the selected button.
- Press the document icon next to „script name“
- A popup will open. Add the code from the below section
- Press „save as“
Code
Simple
This is the most simple setup possible for the task.
d.SetTrajectoryPause(True)
Complete
In this more complete example we will first check if the machine is in trajectory state (i.e. moving / executing GCode) before we issue the pause state.
if ( d.getState( ) == State.Trajectory ) or ( d.getState( ) == State.MDI ):
d.SetTrajectoryPause(True)
Some notes
- When testing your button, make sure that the machine is in idle state (i.e. connected). Otherwise the controller will not execute any action.