Below code only works if i disable (Comment out ) the EStop_Timer: Start(50) line
well at least it shows the running/stop stat of the controller
if i leave the timer stop line un commented then it works the first press of the trigger but soon as i release it then nothing anymore
got to be something stupid with the timer definition?
?
-- Charley Ulmschneider August 9 2018
-- Declirations
local mInst = mc.mcGetInstance()
local Xenabled = false
local ESState = false
--X360 Init Panel
X360_Panel = wx.wxPanel(wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize)
X360_Timer = wx.wxTimer(X360_Panel)
X360_Timer:Start(100)
--EStop Init Panel
EStop_Panel = wx.wxPanel(wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize)
EStop_Timer = wx.wxTimer(EStop_Panel)
-- Functions
function GetXin(xinput)
local hreg=mc.mcRegGetHandle(mInst, string.format("mcX360_LUA/%s", xinput))
return mc.mcRegGetValueLong(hreg)
end
-- Event Timers
X360_Panel:Connect(wx.wxEVT_TIMER, function (event)
if GetXin("LTR_Val")>150 and Xenabled == false then
EStop_Timer:start(50)
Xenabled=true
mc.mcCntlSetLastError(mInst,"x_360 Running")
elseif GetXin("LTR_Val")<50 and Xenabled==true then
EStop_Timer:stop(0)
Xenabled=false
mc.mcCntlSetLastError(mInst, "x_360 Stopped")
end
end)
EStop_Panel:Connect(wx.wxEVT_TIMER, function (event)
if GetXin("Btn_B") == 1 and ESState == false then
local EStop = mc.mcSignalGetState (mc.mcSignalGetHandle (mInst, mc.ISIG_EMERGENCY))
if (EStop ==1) then
mc.mcSignalSetState (mc.mcSignalGetHandle (mInst, mc.ISIG_EMERGENCY), 0)
else
mc.mcSignalSetState (mc.mcSignalGetHandle (mInst, mc.ISIG_EMERGENCY), 1)
end
ESState = true
end
if GetXin("Btn_B") == 0 and ESState == true then
ESState = false
end
end)