Using custom buttons in a macro
Posted: Mon Sep 19, 2016 6:18 pm
I'm trying to write some macros that will allow me to use custom screenset buttons to control some external devices via selected Port/Pins. To check the feasibility of doing this, I created two custom screenset button types and a custom LED, wrote several simple macros, and setup the macros to loop (one at a time).
I was successful in getting a macro to read the state of a custom non-toggle button and to then set the custom LED accordingly (which in turn set an output Port/Pin that I had associated with the custom LED). When the button was pressed (and held) the button state changed and the LED and output pin tracked it. When the button was released, the LED and output pin returned to their original state. The macro code is:
bool button = AS3.Getbutton(1060); //read the state of custom non-toggle button 1060
AS3.SetLED(button, 950); //set custom LED 950 to state of button 1060
I was unsuccessful in getting a macro to read the state of a custom toggle button. The macro code is:
bool button = AS3.Getbuttonstate(1050); //read the state of custom toggle button 1050
AS3.SetLED(button, 950); //set custom LED 950 to state of button 1050
This code does not work (for me) -- apparently the state is not being read from the custom toggle button (the button does visibly change when pressed). But, interestingly, if I change the button number to an existing screenset toggle button (for example, 114 -- spindle on CW) the code works fine (I get the right responses).
So, I'd appreciate any advice (or examples) on how to read the state of a custom toggle button (I'm assuming some additional code is needed). I'm not a programmer, so I may be missing something important needed to make this work.
Thank you, Frank
I was successful in getting a macro to read the state of a custom non-toggle button and to then set the custom LED accordingly (which in turn set an output Port/Pin that I had associated with the custom LED). When the button was pressed (and held) the button state changed and the LED and output pin tracked it. When the button was released, the LED and output pin returned to their original state. The macro code is:
bool button = AS3.Getbutton(1060); //read the state of custom non-toggle button 1060
AS3.SetLED(button, 950); //set custom LED 950 to state of button 1060
I was unsuccessful in getting a macro to read the state of a custom toggle button. The macro code is:
bool button = AS3.Getbuttonstate(1050); //read the state of custom toggle button 1050
AS3.SetLED(button, 950); //set custom LED 950 to state of button 1050
This code does not work (for me) -- apparently the state is not being read from the custom toggle button (the button does visibly change when pressed). But, interestingly, if I change the button number to an existing screenset toggle button (for example, 114 -- spindle on CW) the code works fine (I get the right responses).
So, I'd appreciate any advice (or examples) on how to read the state of a custom toggle button (I'm assuming some additional code is needed). I'm not a programmer, so I may be missing something important needed to make this work.
Thank you, Frank