Page 1 of 2

button macros whilst executing gcode

PostPosted: Mon Jul 23, 2018 1:00 pm
by stirling
Hi, new to UCCNC and just got up and running last week with a UC300ETH_5LPT and licensed software (V1.2047) so I may be missing something.

It appears that button macros are ignored whilst gcode is executing. Is this the case?

Thanks

Ian

Re: button macros whilst executing gcode

PostPosted: Mon Jul 23, 2018 3:16 pm
by cncdrive
You could handle the custom buttons from macroloops, those always running in the background.

Re: button macros whilst executing gcode

PostPosted: Mon Jul 23, 2018 5:32 pm
by stirling
Hi Terry - thanks - how's it going with you? - been a while.

@cncdrive - can you explain a little please about the use of the macro pump to handle custom buttons? How would a macro pump be alerted that you've hit a user button?

Here's my need.

In my Mach3 plasma setup using my THC the operator can fine tune/adjust the Set Volts up or down whilst cutting. They can do this either by typing in a new value into a DRO or more conveniently by hitting up/down buttons to increase/decrease the Set Volts. Unfortunately in UCCNC not only can you not change the value in a DRO whilst gcode is running but you can't implement the up/down voltage buttons either.

Thanks

Re: button macros whilst executing gcode

PostPosted: Mon Jul 23, 2018 8:17 pm
by cncdrive
20000 to 20999 DROs you can access even when running g-code.
The macro call buttons you really can't use while running g-code, what you could do is to write a macro loop which senses the presses of those buttons and doing things then just like if it was a buttonpress event.

Re: button macros whilst executing gcode

PostPosted: Mon Jul 23, 2018 11:00 pm
by stirling
cncdrive wrote:what you could do is to write a macro loop which senses the presses of those buttons and doing things then just like if it was a buttonpress event.


OK - that works fine. Thanks.

Just one small issue though: my user button is buttonnumber 20900 so that's what I monitor in the pump with:

if (AS3.Getbutton(20900))
{
//do stuff
}

However although that works just fine, I also get the error "File:/Profiles/Macro_RazordanceTHC\M20900.txt Could not read!" in the Status Message label. Presumably this is because there is not an actual macro associated with this button.

To prevent this error message I created a completely empty button macro M20900.txt but this seems a little kludgy - is there something I'm missing here?

Re: button macros whilst executing gcode

PostPosted: Mon Jul 23, 2018 11:23 pm
by ger21
Normally, the button would "do stuff", and the macroloop is just used to monitor the button press.

I guess they never thought that someone would want a button that didn't do anything. :D

Re: button macros whilst executing gcode

PostPosted: Tue Jul 24, 2018 1:05 am
by cncdrive
Your example simple macro works fine here, I see no problem, it works, it just not doing anything, but if I change it like:

Code: Select all
if (AS3.Getbutton(20900))
{
MessageBox.Show("pressed");
}


Then is shows the messagebox when the button is pressed.

Re: button macros whilst executing gcode

PostPosted: Tue Jul 24, 2018 8:22 am
by stirling
cncdrive wrote:Your example simple macro works fine here, I see no problem, it works, it just not doing anything, but if I change it like:

Code: Select all
if (AS3.Getbutton(20900))
{
MessageBox.Show("pressed");
}


Then is shows the messagebox when the button is pressed.


OK, I maybe didn't explain things very well. Of course I have code in the macroloop, I just put //do stuff above to save typing - my bad. :geek:

Anyway using your example: here, if I just press the button whilst gcode is running yes it displays the message box. So far so good.

However if you press YOUR button when gcode is NOT running, yes it still displays the message box but it also generates an error in the status message box which says: "File:/Profiles/<your profile>\M20900.txt Could not read!"

HOWEVER, if you now create an EMPTY M20900.txt and press your button when no gcode is running - you don't get the error message any more. Why? because the system now has something to read i.e. M20900.txt even though its empty and therefore does nothing.

Is it the same on your system?

If so - I'm just asking if there's a more elegant way of suppressing the error message than creating an otherwise useless empty button macro.

Re: button macros whilst executing gcode

PostPosted: Tue Jul 24, 2018 8:34 am
by dezsoe
You cannot suppress the error message, because UCCNC must run that macro. The only way you can work around is to write a plugin where you can handle the keypress even while code is running and you use a button code out of the 20000..21999 range to prevent UCCNC from searching for the macro file.

Re: button macros whilst executing gcode

PostPosted: Tue Jul 24, 2018 9:32 am
by cncdrive
I'm still not sure what you wanna achive nor do I understand it clearly what you doing?!
I mean I read your post about 20 times now and got even more confused about it.

Are you saying that if there is no M20900 macro file, if the file does not exist in other words then you get an error message and you want to get rid of that message?