Hello Guest it is April 25, 2024, 02:12:11 AM

Author Topic: mcX360 Plugin for Lua  (Read 45450 times)

0 Members and 2 Guests are viewing this topic.

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #60 on: March 18, 2018, 04:19:08 AM »
This was made for an XBox controller only.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: mcX360 Plugin for Lua
« Reply #61 on: May 11, 2018, 05:53:01 AM »
Hi DazTheGas,

I'm using your plugin with TomL21's  XboxPMC and it works. Since I can view the Regs within Diagnostics->RegFile I
don't need the debug output in mach4's last error. Is there a way to turn off the debug messages ?

Helmut

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #62 on: May 11, 2018, 12:37:30 PM »
Can you be a bit more precise on what messages?

DazTheGas
New For 2022 - Instagram: dazthegas

Offline Klaus

*
  •  42 42
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #63 on: July 10, 2018, 07:17:32 PM »
So no script or plugin exist for Mach4 which have a configuration screen like on the Mach3 plugin?
Re: mcX360 Plugin for Lua
« Reply #64 on: August 08, 2018, 03:21:29 PM »
I have loaded the latest plugin and i can get everything to work except Button A Cycle Start
Rht Shoulder Button A works fine and I can see button A change state in the registry window but it does not perform a cycle start

Typed following into MDI
G1 F50 X1
G1 F50 X0

Press A and nothing
actually press Cycle Start and code exicutes with machine motion

Is there actually a way to edit/see the code in your plugin, i am new to MACH 4 and LUA but have written in C# before i retired

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #65 on: August 08, 2018, 04:09:52 PM »
The example for the A does not run an mdi, a cycle start in general will start a loaded gcode file, you would need to change to something like

if GetXin("Btn_A") == 1 and A_Btn == false then
      scr.ExecMdi('mdi1')
      A_Btn = true
end

DazTheGas
New For 2022 - Instagram: dazthegas
Re: mcX360 Plugin for Lua
« Reply #66 on: August 08, 2018, 05:55:24 PM »
Do you have the code you used in the part 1 video for the xbox controller and is there a part 2 i could not find it
Re: mcX360 Plugin for Lua
« Reply #67 on: August 09, 2018, 05:08:54 PM »
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)
Re: mcX360 Plugin for Lua
« Reply #68 on: August 09, 2018, 05:11:24 PM »
NEVER MIND
Stupid mistake

start and stop instead of Start ans Stop

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: mcX360 Plugin for Lua
« Reply #69 on: August 10, 2018, 03:35:08 AM »
It gets us all at some time Lua is case sensitive

DaTheGas
New For 2022 - Instagram: dazthegas