Hello Guest it is March 28, 2024, 04:31:28 PM

Author Topic: Map Lua Code to ShuttlePro button  (Read 8238 times)

0 Members and 1 Guest are viewing this topic.

Offline Pedio

*
  •  200 200
    • View Profile
Re: Map Lua Code to ShuttlePro button
« Reply #10 on: May 24, 2016, 08:21:35 AM »
I would like to get the same functionality on a button for the ShuttlePro. I would like to bring the spindle on CW at a power of 1 and then toggle off if the button on the ShuttlePro is pushed again. I don't seem to understand signal scripts. I posted what I was trying to insert into the screen load script for the main screen. It fails the compile.

The laser control script works on a button; however, the screen is far away from the CNC so I would like to put it on a ShuttlePro button.

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Map Lua Code to ShuttlePro button
« Reply #11 on: May 24, 2016, 09:28:55 AM »
You could do this by selecting User Gcode from the Shuttle config and then use a custom M code in that GCode.

DazTheGas
New For 2022 - Instagram: dazthegas

Offline Pedio

*
  •  200 200
    • View Profile
Re: Map Lua Code to ShuttlePro button
« Reply #12 on: May 24, 2016, 03:32:41 PM »
I found how to assign the User gcode to a button but don't know how to generate the file for the ShuttlePro to use or where to place the file. I looked at the scripting manual but did not get a lot of help. Is there any manual that talks about this?

I think I can use this code

function M3()
     inst=mc.mcGetInstance()
     mc.mcCntlSetLastError(inst, 'Spindle Clockwise')
     mc.mcSpindleSetDirection (inst, 1)
end
if (mc.mcInEditor()==1) then
   m3()
end

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Map Lua Code to ShuttlePro button
« Reply #13 on: May 25, 2016, 11:15:08 AM »

Create an m3 macro in your profile`s/macro  directory to add your code from above.

load up your machine.ini in an editor and find the section ShuttlePro0, at the bottom of the section add  "Gcode1=m3" (without the quotes) and this should then runthe m3 macro for you.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Map Lua Code to ShuttlePro button
« Reply #14 on: May 25, 2016, 01:33:24 PM »
Beware of mixing upper case and lower case in  your function names.  For example, when you define the M3() function you use upper case.  But when it is called from the "in editor" if statement it is called with lower case m3().

Some people claim that the case of the function name and the upper/lower case used in the file name matter.  I was not able to see any effect of upper/lower case in the file name, at least on my couple of PCs.  But I did not test on Win8 or Win10, so I cannot guarantee there ISN'T as issue.  To be safe, keep everything using the same case (I use lower case).

Bob

Offline Pedio

*
  •  200 200
    • View Profile
Re: Map Lua Code to ShuttlePro button
« Reply #15 on: May 25, 2016, 04:52:10 PM »
Still not doing something right?  ???

I placed the attached macro in the macro directory under my machine's profile.

I then went to the .ini file and edited it to include the Gcode1=m3 (see attached)

It did not work. I notice the ShuttlePro plugin called it "User Gcode1" so I changed the "Gcode1" to "UserGcode1", "User Gcode 1", and "User Gcode1". None of them seemed to work.

Attached are screen shots.

Thoughts or suggestions?
Peter

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Map Lua Code to ShuttlePro button
« Reply #16 on: May 25, 2016, 07:14:56 PM »
Bob was right with the naming so I put this together so you can see the effects of upper and lower case problems.

http://www.machsupport.com/forum/index.php/topic,32620.0.html

DazTheGas
New For 2022 - Instagram: dazthegas

Offline Pedio

*
  •  200 200
    • View Profile
Re: Map Lua Code to ShuttlePro button
« Reply #17 on: May 27, 2016, 08:11:05 AM »
Daz,

I believe I have used the lower case for M3 in all instances. If I have done it wrong I am being remedial and can not see it.

I have tested the M3 macro with the MDI box as you show in the video and it works like it should. I suspect I am doing something wrong when assigning the Gcode1 name in the LUA screen load script. Any thoughts?

Thanks,
Peter

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Map Lua Code to ShuttlePro button
« Reply #18 on: May 27, 2016, 10:17:46 AM »
Just tested on 3 different versions of mach4

Gcode1=m3 at end of the ShuttlePro0 section works fine on all.

if you still have problems go into the help menu and use  support/ package current profile,  then upload the .m4prof file, I will see if theres anything causing the problem.

DazTheGas
« Last Edit: May 27, 2016, 10:29:01 AM by DazTheGas »
New For 2022 - Instagram: dazthegas

Offline Pedio

*
  •  200 200
    • View Profile
Re: Map Lua Code to ShuttlePro button
« Reply #19 on: May 27, 2016, 01:59:50 PM »
Is there a way to get M4 to recompile the macros?