Hello Guest it is April 28, 2024, 01:24:54 PM

Author Topic: How to trigger "action" with an input?  (Read 1003 times)

0 Members and 1 Guest are viewing this topic.

Re: How to trigger "action" with an input?
« Reply #10 on: January 10, 2023, 10:56:59 AM »
Beautiful!

Can the new toggle interact with the existing gui buttons? (as in if I activate the soft limits via this mechanism will the soft limits indicator on the GUI light up green?)
Re: How to trigger "action" with an input?
« Reply #11 on: January 10, 2023, 12:00:03 PM »
Hi,

Quote
I found a workaround to use these actions by way of the scr commands.  They appear to work well but it feels kinda 'hackey' and not the right way.

Correct, I try to avoid scr commands. The correct way is to place an object, like a button, it does not have to be visible, but then you get the options of UpAction,
DownAction, UpScrpit, DownScript, ClikedScript etc.

Quote
Is there a convenient way to have an "include" file or something in the screen script that will pull from a separate lua file of my creation?

Yes you can write Lua modules or Lua Panels....I'm not really familiar with them Look up some of Daz-the-Gaz's videos.

Quote
I'm thinking to modify the actual screen script as little as possible and put my code in one script if at all possible.

Why?. I modify the screen load script, PLC script and others all the time. That's what they are for, and they work a treat. Take a copy of your preferred screen script,
wx4.set say, give it a unique name like Mywx4.set, and modify the hell out of it. When you update to the latest build the uniquely named .set file will survive the update
unaltered so you can carry on using it.

You are at the very least going to have to edit the SigLib table......so there is no avoiding editing the screen script. It does make sense to have all your edits gathered in one
place, so I'll often put all my own coded functions at the end of the script, but inevitably you will have to make a few edits throughout the screen script which can be a pain
to recall and trace. There is a function, if I recall correctly, which allows you to compare the differences between files and thereby locate any edits in one file compared to the
standard issue .set file.

Craig

Do you usually edit the xml file directly (within the .set file)?  I'm looking for something I can use in a different editor while looking at the current wx screen for reference.   I've got 'visual studio code' which I like because it is close enough to visual studio for me. 
Re: How to trigger "action" with an input?
« Reply #12 on: January 10, 2023, 01:58:33 PM »
Hi,

Quote
(as in if I activate the soft limits via this mechanism will the soft limits indicator on the GUI light up green?)

I don't know, its not something that I have tried but yes I believe you can code that.

Quote
Do you usually edit the xml file directly (within the .set file)?  I'm looking for something I can use in a different editor while looking at the current wx screen for reference.   I've got 'visual studio code' which I like because it is close enough to visual studio for me.

No, I edit the screen with the screen editor provided, after all that's what it's for. The visual representation of the screen while the editor is active
is perfectly adequate for the purpose. Mach4 is not a software development environment, it is a CNC software solution, ie a Gcode interpreter and
trajectory planner. It does have an editable GUI and a fair API and scripting language which allows users to adapt Mach4 to their machine.
Those extra tools (GUI editor and Lua scripting) are useful but they do not in themselves 'make chips', Mach4's primary purpose.

If you need an ultimately flexible solution then I'd suggest LinuxCNC, its a solution that rewards software developers whereas Mach4 rewards
machine builders/integrators to produce working machines but does not require software developer skills.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: How to trigger "action" with an input?
« Reply #13 on: January 11, 2023, 02:56:51 PM »
Haha, absolutely! I’ll admit that i have the mechanicals of my machine complete and have been procrastinating the sw config because of the learning curve. 

I’m just trying to learn the best practices for sure!
Re: How to trigger "action" with an input?
« Reply #14 on: January 11, 2023, 03:10:34 PM »
Hi,
my suggestion is use Mach4Hobby as is....don't worry about programming any frilly bits, just use the program and start making parts.
I suspect you'll find as I have that standard Mach4 is pretty much complete as is....you don't really need anything else. There are plenty of things
that you might like to change, for example your idea of using a joystick for jogging. Yes it can be done, but lack of its not stopping you from using
the program as is.

There is nothing like making parts to inform you of those things that you need as opposed to want.

I, in the early days, had quite a bit of custom code in my profile but over the years its shrunk, to the extent I have only a few macros related to specific work that
I do, isolation routed PCBs in particular. All the rest of them have faded away because I just don't use them.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: How to trigger "action" with an input?
« Reply #15 on: January 11, 2023, 07:45:50 PM »
Makes sense.

I'm partly using the buttons as an easy way to get to know the custom stuff, as I will need to implement the tool changer control and the remaining 2 axes (although I don't think there is much to do for the AC axes, I may find myself editing existing scripts to work with the additional axes.

I actually have another CNC that I already retrofitted with Mach4 (and all of the same electronics as for my 5 axis) as a test of my architecture and to make some parts for my scratchbuilt machine.  Luckily for me, I've actually had a great experience with it except for a few annoying buttons that I was hoping to implement with the console buttons here.

I'm a little confused about the states on the toggle buttons.  Do you know of a reference to read for me?  for example, how can a toggle be mapped to both an input and an output in the properties tab?  Is it an "and" or is it "or" between them?

Thanks!

Re: How to trigger "action" with an input?
« Reply #16 on: January 11, 2023, 08:19:20 PM »
Hi,

Quote
for example, how can a toggle be mapped to both an input and an output in the properties tab?  Is it an "and" or is it "or" between them?
The state of toggle switch is toggled  by an external input. Click the external button and the on screen toggle switch will toggle. The output is driven by the logical state
of the internal toggle switch. For instance you might have a external button to turn a coolant pump on or off and use one of Machs outputs to illuminate the external button
when the pump is energized.

Simple expedient here is to try it.....half an hour experimenting with assigning inputs and or outputs, along with various actions and/or scripts and it will be clear.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'