Put this in your screen load script. Notice I removed the local keyword from the function definition. This way, you could have multiple buttons call this function, if you wish.
function myHomeC()
local inst=mc.mcGetInstance('myHomeC()') -- this will log all API calls as coming from source "myHomeC()"
local sState
local pos=-1
mc.mcCntlEnable(inst,0)
mc.mcCntlConfigStart(inst)
local hSigH=mc.mcSignalGetHandle(inst,mc.ISIG_MOTOR3_HOME)
rc = mc.mcSignalEnable(hSigH,1)
mc.mcProfileWriteInt(inst, 'Signal68', 'Enabled', 1)
mc.mcProfileSave(inst)
mc.mcProfileFlush(inst)
mc.mcCntlConfigStop(inst)
mc.mcCntlEnable(inst,1)
local hSig,rc=mc.mcSignalGetHandle(inst, mc.ISIG_INDEX)
if (rc == mc.MERROR_SIGNAL_NOT_FOUND) then
wx.wxMessageBox('wrong Signal')
end
sState = mc.mcSignalGetState(hSig)
if (sState == 1) then -- sitting on the slot so move off it
mc.mcCntlGcodeExecuteWait(inst, 'g0 f20000 h15\n')--g1 h366 f5000')
end
rc = mc.mcAxisHome(inst, mc.C_AXIS)
--this never gets executed
mc.mcCntlSetLastError(inst, 'Homing')
repeat
wx.wxMilliSleep(1000)
rc = mc.mcAxisIsHoming(inst, mc.C_AXIS)
mc.mcCntlSetLastError(inst,'Homing: '..tostring(rc))
until rc == mc.MERROR_NOERROR
rc = mc.mcSignalEnable(hSigH, 0)
mc.mcProfileFlush(inst)
end
And then simply put:
myHomeC()
in any button's left up script you want.
I know I harp on error checking, but... it needs more error checking!
I also still don't like the G code execute wait that doesn't move. It may or may not cause problems.