Hello Guest it is June 10, 2023, 07:15:52 AM

Author Topic: Screen GUI keyboard control  (Read 961 times)

0 Members and 1 Guest are viewing this topic.

Offline mzc

  •  11 11
    • View Profile
Screen GUI keyboard control
« on: August 08, 2021, 03:46:06 AM »
Hi All,

So I've recently upgraded from Mach3 + cheap USB controller to Mach4 + ESS on my newly re-built 3 axis CNC.

Way better on all accounts from what I've seen so far.

What I'm trying to do is edit the screen script and associated lua code to allow me to use a mini USB number keypad as a 'pendant', so I can use that at the machine to jog/zero and start/stop jobs, including adjusting the FRO and RRO (and ultimately spindle once I get a proper spindle) as jobs run.

I'm using the keyboard plugin, linking key presses to signals, and then assigning lua code to those signals in the signal handler script (which actually calls the signal table that's defined in the screen start script).

So for example, to have a keypress decrease the FRO by 10% (like clicking on the "-" button on the Feed Rate panel on the GUI), I do something like (in the screen load script's siglib):

[mc.ISIG_INPUT45] = function (state)
    if( state == 0) then
   -- FRO up
   mc.mcCntlSetLastError(inst, "FRO increase selected")   

So this works great, just like clicking on the button in the GUI.
The slider and dros are updated fine.

Now comes the hard part...

I want to do the same thing for the jog rate slider!
There is no buttons (and associated lua functions defined that I can find) that process the gui button event.

I can't find anywhere any hints at how SLIDERS in the GUI map to existing screen functionality.

I can see how to add custom functionality to sliders (not what I need to do as I don't want to interact with the GUI as such), and I can map custom functions to keypress events (and I almost had the jog rate changing) but the slider was not updating correctly.

So the general question (which will help me resolve this specific case), is where is the lua code that processes the slider data when it's changed in the screen gui?