Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Wallerawang on February 24, 2022, 04:31:28 AM

Title: Persistent Spindle Range DRO
Post by: Wallerawang on February 24, 2022, 04:31:28 AM
Hello
I have modified my wx4 screen set to include a DRO to set the spindle range. Is there a way to make this DRO persistent so when I start Mach4 it remembers what gear I left it in?
Thanks
Steve
Title: Re: Persistent Spindle Range DRO
Post by: Bill_O on February 24, 2022, 09:14:00 AM
I usually will do something like set a register then make the register permanent.
Then have the dro read the register.
Title: Re: Persistent Spindle Range DRO
Post by: Wallerawang on February 25, 2022, 03:56:27 PM
Thanks Bill,
I set up the register Okay but now the DRO no longer actually changes the spindle range in Mach 4. When I removed the register from the DRO properties it went back to working correctly. I will make a DYMO label to remind me to set the DRO each time.
Steve
Title: Re: Persistent Spindle Range DRO
Post by: Bill_O on February 25, 2022, 04:02:48 PM
Probably need to do some other code to make the register set the spindle range.
Title: Re: Persistent Spindle Range DRO
Post by: thosj on March 03, 2022, 12:17:08 PM
It's been a long time since I did this, but here's what I find in the screenset and mine works like I think you want.

Screen Unload Script, my entire thing:

function Mach_Screen_Unload_Script()
    inst = mc.mcGetInstance()
                     
   
    local IsOpen = mc.mcProfileGetString(inst, 'TOffParams', 'ToffDialog', '0') -- Get the Value from the profile ini.
    if (IsOpen == '1') then --The TouchOff dialog is open and we need to close it
        Tframe:Close()
        Tframe:Destroy()
    end
   
    --Saves Spindle Range to profile on screen unload
    --local inst = mc.mcGetInstance() -- not needed if already declared
    local val = mc.mcSpindleGetCurrentRange(inst)
    mc.mcProfileWriteInt(inst, 'SpindleDefaultRange','Range',val)
end



Screen Load Script, at the end

ButtonEnable()
--Screen Load Script to set Range saved in screen unload script
--Screen Load Script
--local inst = mc.mcGetInstance()  -- not needed if already declared
local val = mc.mcProfileGetInt(inst, 'SpindleDefaultRange','Range',0)
mc.mcSpindleSetRange(inst, val)
Title: Re: Persistent Spindle Range DRO
Post by: Wallerawang on March 03, 2022, 01:30:16 PM
Thanks Tom - I'll give it a go.
Steve
Title: Re: Persistent Spindle Range DRO
Post by: Wallerawang on March 08, 2022, 07:19:13 PM
Hi Tom
I just wanted to let you know that worked like a charm. Very happy with the DRO now remembering what it was at shut down.
Steve
Title: Re: Persistent Spindle Range DRO
Post by: thosj on March 09, 2022, 09:48:51 AM
Very cool, glad it worked!