Hi, I did a bit more work for another user on these a few months ago. Below is a project that I believe will achieve your desired results.
I use the global variables g1 and g2 to control 64 lights. To save on global variables, I set them up to be a bit map of the buttons on your APC Mini. Each global variable uses 32 bits so I am able to achieve two states (on or off) using 2 global variables. I use bit manipulation to extract the current value. The work with toggling the button states is in preset APC Mini Light Control Translator Toggle Light with button.
We extract the button’s current state, toggle it, then stuff it back into the global variable.
When we are done, we do trigger a light refresh timer which iterates through all 64 lights putting them to their current state. This is done in the same preset under the translator “Light Refresh Timer”.
We set the initial state of lights when the project is open or the ESC key on you computer keyboard is pressed. See the “Init” Preset.
I know this might seem a little advanced, especially the bit mapping (extraction and stuffing) so feel free to ask more questions if you have them. If you want to control only a few lights then maybe bit mapping wouldn’t be needed because each light would take it’s own global variable.
For instance if you wanted button note 0 (lower left corner to toggle state you could control with ga as such):
input ; note 0 on channel one value 127
rules:
ga=ga^1
// set to green
if ga==1 then qq=127
// Set to yellow
if ga!=0 then qq=5
Output: Note on note 0 velocity qq
Attached is the more complex mapping using bitmap and the main 64 buttons of the APC Mini.
Attachments:
1517513338646_APC-Mini-Yellow-Green-Toggle-2018-02-01.bmtp