Creating a TOGGLE screen button to turn an output on and off
Posted: Tue Jul 23, 2024 6:49 pm
I have several devices I want to be able to turn on and off with buttons on the UCCNC 1.2113 screen. The buttons will control an output on my C76 control board.
I've created macros to turn these features on and off. One macro turns it on and a second one turns it off. As such I can type the macro name into the MDI and activate the feature. But I want to be able to do it with the mouse on screen so need the buttons.
I've created an up/down button image for each of the three features. I can make either the up or down image show by changing the state to true or false in the screen editor. I currently have that set so the OFF image (no green perimeter) is showing.
I've assigned a macro to activate the output in the 20000 to 21999 range for each of the three features.
When I click the new screen button the output on the C76 activates and the needed feature turns on. However the button image does not change top the green border ON state and pressing it a second time does not turn off the feature. Obviously this is because my macro tied to the new screen button is the ON macro.
So I can solve this one of two ways that I know of:
1) Make two buttons for each feature, one for the ON macro and one for the OFF macro.
or...............
2) Figure out how to do a toggle with the single button so it turns the output on when depressed and off when depressed a 2nd time. Just like turning the spindle on and off with the CW spindle toggle for example. But I haven't been able to figure out how to do that. For reference I have them set at:
BLINK=FALSE ......... TOGGLETYPE=TRUE...........ISON=FALSE
I know that certain button numbers are reserved for certain types of functions so perhaps that has something to do with it.
Perhaps I can do it in the macro? Maybe something similar to this that turns my spindle off at the end of a predetermined warmup period:
}
// stop the spindle
exec.Stopspin();
// switch the state to "off"
AS3.Switchbutton(false, 20001);
AS3.Setfieldtext("OK", 20001);
}
Thanks,
BH
I've created macros to turn these features on and off. One macro turns it on and a second one turns it off. As such I can type the macro name into the MDI and activate the feature. But I want to be able to do it with the mouse on screen so need the buttons.
I've created an up/down button image for each of the three features. I can make either the up or down image show by changing the state to true or false in the screen editor. I currently have that set so the OFF image (no green perimeter) is showing.
I've assigned a macro to activate the output in the 20000 to 21999 range for each of the three features.
When I click the new screen button the output on the C76 activates and the needed feature turns on. However the button image does not change top the green border ON state and pressing it a second time does not turn off the feature. Obviously this is because my macro tied to the new screen button is the ON macro.
So I can solve this one of two ways that I know of:
1) Make two buttons for each feature, one for the ON macro and one for the OFF macro.
or...............
2) Figure out how to do a toggle with the single button so it turns the output on when depressed and off when depressed a 2nd time. Just like turning the spindle on and off with the CW spindle toggle for example. But I haven't been able to figure out how to do that. For reference I have them set at:
BLINK=FALSE ......... TOGGLETYPE=TRUE...........ISON=FALSE
I know that certain button numbers are reserved for certain types of functions so perhaps that has something to do with it.
Perhaps I can do it in the macro? Maybe something similar to this that turns my spindle off at the end of a predetermined warmup period:
}
// stop the spindle
exec.Stopspin();
// switch the state to "off"
AS3.Switchbutton(false, 20001);
AS3.Setfieldtext("OK", 20001);
}
Thanks,
BH