OK, below is a pretty simple way to do it. But it may not be as robust as it should be. There might need to be some checks/lockouts that prevent the function from being called again before the previous move is finished. What can happen now is you can click the button or pedal and while it is moving the 10 units let off the pedal or click the button again. This will make it move again in the same direction (like a step jog would) the next time the button or pedal changes states. But it will move another 10 form its current position at that time. You might even find that a bit helpful? But if you press the pedal down and hold until it has moved the 10 it will move in one direction when pressed and the other when released. Same with the button. If you click it one time and wait until it finishes moving before pressing it again up will move it one direction and down will move it in the other.
Add this to the top of the sigLib table in the screen load script.
[mc.ISIG_INPUT3] = function (state)
moveYhardStop(state)
end,
Add this function to the screen load script anywhere after the sigLib table.
function moveYhardStop(dir)
scr.SetProperty("togBGtest", "Button State", tostring(dir))
local inst, YMach, rc
inst = mc.mcGetInstance()
YMach, rc = mc.mcAxisGetMachinePos(inst, mc.Y_AXIS)
if (dir == 0) then --Up == "0" Down == "1"
rc = mc.mcCntlMdiExecute(inst, string.format("G0 G53 Y%4.4f", (YMach + 10)))
else
rc = mc.mcCntlMdiExecute(inst, string.format("G0 G53 Y%4.4f", (YMach - 10)))
end
end
Now for your toggle button. First clear the Input Signal property you have that input set to. Then in its Up and Down Script events put this code which calls the function you put in the screen load script passing it the direction parameter. The direction parameter (dir) needs to be the number 0 or 1. So, both Up and Down script events will have the same code. the only difference is one will have a 0 and the other will have a 1. I think your up script should have a 0 and down a 1 but that depends on how/when your foot pedal goes low and high and if you want pedal down to == button down or button up.
moveYhardStop(0)
Play with that and see if you like it, need to add some checks, etc.