I do it in the Screen Start Script, Signal Library. A button, momentary, is wired to an input, in my case a Pokeys 57E, and the code is in the Signal Library. It IS a toggle. You need to setup the input for whatever input you're using, BOB, PoKeys, whatever. PMC might be easier, you don't have to write the code, but the code ain't much!!
My code:
------------Mach4 Input 8 PoKeys Pin 8----------------
------------Toggle SpinCW-----------------------------
[mc.ISIG_INPUT8] = function (state)
if (state == 1) then
local inst = mc.mcGetInstance();
local sigh = mc.mcSignalGetHandle(inst, mc.OSIG_SPINDLEON);
local sigState = mc.mcSignalGetState(sigh);
if (sigState == 1) then
mc.mcSpindleSetDirection(inst, 0);
else
SpinCW()
end
end
end,
Tom