1
Mach4 General Discussion / Toggle button
« on: May 01, 2018, 07:52:40 AM »
I have built a panel with several buttons and a PoKey56E. I want two buttons to be a toggle for spindle on/off in forward and reverse. I used this code in the signal script.
Problem is when the button is pressed the signal is called and the function turns on, but as soon as the button is released the signal script sees the change and call the function again, turning the spindle off.
Any idea how to handle this? Is there a way to only see the signal when it rises, not on any change?
Code: [Select]
[mc.ISIG_INPUT7] = function (state)
if (state == 1) then
mc.mcCntlSetLastError(inst, "Spindle Forward Off");
mc.mcSpindleSetDirection(inst, 0);
else
mc.mcCntlSetLastError(inst, "Spindle Forward ");
mc.mcSpindleSetDirection(inst, 1);
end
end,
Problem is when the button is pressed the signal is called and the function turns on, but as soon as the button is released the signal script sees the change and call the function again, turning the spindle off.
Any idea how to handle this? Is there a way to only see the signal when it rises, not on any change?