Hello Guest it is May 28, 2026, 05:10:25 PM

Author Topic: Assign Button to Call M132  (Read 2267 times)

0 Members and 1 Guest are viewing this topic.

Re: Assign Button to Call M132
« Reply #10 on: March 18, 2026, 12:34:20 PM »
Just a warning as well, at this time, if you add a new dashboard, it will mimic the dashboard you selected. Basically at this time there is only one instance of a dashboard type. For example, if I added a duplicate dashboard type like in the image, all elements will reflect the other dashboard. So a change to one will change the other.
Thanks,

Paul
Re: Assign Button to Call M132
« Reply #11 on: March 18, 2026, 02:01:03 PM »
Yep - I've explored the implementation a bit and can confirm your comments. For now, the Control Group is hidden, which I had discovered in the screen config. The File group is hidden in the Screen set for now.
Re: Assign Button to Call M132
« Reply #12 on: May 17, 2026, 06:21:18 PM »
Can I assume that if the button ends up being Red, it's bad?
Re: Assign Button to Call M132
« Reply #13 on: May 17, 2026, 08:40:19 PM »
Screenshot?  Does it go red even though you've set the colors to something else?  Is it Red when the system is enabled or disabled?
Re: Assign Button to Call M132
« Reply #14 on: May 18, 2026, 06:36:20 AM »
here's a pic.


and the function. It's probably something stupid I've done.

function UserGUIModule.CreateUserCommands()
    local function RunM(code)
        -- fire and return immediately; the m-code handles any waiting/prompting
        w.api("mcCntlMdiExecute", inst, code)
    end
    w.CreateSimpleCommand("DustBoot") -- this creates the button and names it
    w.CreateCommandActionOption("DustBoot", function() RunM("m2221") end) -- this gives the button logic
   w.SetCommandButtonColors("DustBoot", "#FF0000", "#00FF00")
   w.SetCommandButtonLabels("Dustboot", "DustBoot on", "DustBoot off")
end
Re: Assign Button to Call M132
« Reply #15 on: May 18, 2026, 07:57:22 AM »
Now I'm getting somewhere. Just need to figure out why it's not running the scripts. My goal here is to create a button that will dock a dust boot and pick it up again. The Signal needs to be setup within the Mach Outputs, and assigned to the function AutoDustBoot. Signal 100 is arbritrary. Button now toggles back and forth and toggles color. I believe that the color's Paul showed were Red and Green and along with everything else was just confusing. There are probably much better ways of doing this. But for now, this works. A register that saves would be ideal, but then it's a whole nother ball of wax. Next I'll work on a probe autoload function.


function UserGUIModule.CreateUserCommands()
    local function RunM(code)
        -- fire and return immediately; the m-code handles any waiting/prompting
       local state = w.GetSignalState(mc.OSIG_OUTPUT100)

       if state == 1 then
          w.api("mcCntlMdiExecute", inst, "m2222")
       else
          w.api("mcCntlMdiExecute", inst, "m2223")
       end
 ---       w.api("mcCntlMdiExecute", inst, code)
        w.SetSignalState(mc.OSIG_OUTPUT100, not state)
    end
    w.CreateSimpleCommand("AutoDustBoot") -- this creates the button and names it
    w.CreateCommandActionOption("AutoDustBoot", function()RunM("AutoDustBoot") end) -- this gives the button logic
--   w.SetCommandButtonColors("AutoDustBoot", "#FF0000", "#00FF00")
   w.SetCommandButtonLabels("AutoDustBoot", "DustBoot on", "DustBoot off")
   return true, true, w.FunctionCompleted()
end
Re: Assign Button to Call M132
« Reply #16 on: May 18, 2026, 09:42:28 AM »
Yes, the example I had shown were very custom and designed for a lathe with three separate running states. So there were three different buttons interacting with each other. I'll try to create easier examples in the future. That was just the example I had available at the time.

SetCommandButtonColors Sets your label colors based if it is activated or deactivated.
Here is our documented info on it. The color codes are Hex color codes.

---------------------------------------------------------------------------------
WrapperModule SetCommandButtonColors   (   cmd_name   ,
off_color   ,
on_color    )
Set the on and off background colors for a command's button.

Updates the BgOffColor and BgOnColor fields of the command entry in m.Commands. Has no effect if m.Commands is nil or the command does not exist.

Parameters
cmd_name   (string) The name of the command whose button colors are to be set
off_color   (string) The background color when the command feedback state is off (e.g., "#FFFFFF")
on_color   (string) The background color when the command feedback state is on (e.g., "#00FF00")

Thanks,

Paul
Re: Assign Button to Call M132
« Reply #17 on: May 18, 2026, 09:47:16 AM »
my problem was the color code. It would be nice if the color picker would specify the hex color code. Might make it easiler than doing a screen shot, putting into paint and using the color picker edit to find the hex value. :)
Re: Assign Button to Call M132
« Reply #18 on: May 18, 2026, 09:55:45 AM »
and of course there's the problem that we never run the mcode script. I'm loathe to add it into the UserMCodeModule.

Also, what's the differance between these two functions? Other than the _

function UserMCodeModule.m222(hVars)
   return true, true, w.FunctionCompleted()
end

function UserMCodeModule._m225(hVars)
   return true, true, w.FunctionCompleted()
end

function UserMCodeModule.LubeSystem()
   return true, true, w.FunctionCompleted()
end
There is already a script for this. Do these cascade? one after another or would this replace LubeSystem.mcs?