Script for MIDI out toggle on button press?

Discussion in 'PangoScript, Universe and Midi Templates' started by Chris Harris, May 4, 2017.

  1. Chris Harris

    Chris Harris Member

    I'm reprogramming the "select" buttons on my APC40mkII to include some groups of projection zones, using code similar to the following:

    ToggleSelectZone 1,2,3,4,5,6,7
    FocusZone 1
    Exit

    The buttons are selecting the projection zones as expected. However, I would like to include MidiOut code to toggle the light on and off on the APC40mkII button. How can I do this?

    Additionally, I would also like to program some main grid buttons on a second APC40mkII to turn on QuickFX. I have figured out how to program the buttons to select the QuickFX. But, I know the code should be different here for toggling the state of the button light, since it won't just toggle on and off with the button press, but will also need to turn off if another button is pressed.

    I'm sorry if this is unclear. I'm just learning PangoScript. I've found MidiOut and understand that. I just don't know how to tell it "If this button is pressed, send this midi out command, and if the button is pressed again, or another button is pressed, then send this other midi out command." ;)
     
  2. Chris Harris

    Chris Harris Member

    This is the code I've come up with. Unfortunately, it's not working.

    OnChange:
    ToggleSelectZone 9
    FocusZone 9
    if (value>0.5) goto LightOn
    MidiOut 0x90, 0x33, 0x00 // ‘LightOff’
    exit
    LightOn:
    MidiOut 0x90, 0x33, 0x7F // ‘LightOn’
    exit

    The red is the bad code according to the Midi to Pangoscript editor.

    Any ideas where I'm going wrong?

    I want the lights to go on and off based on the UI button state, rather than the zone state, because I'm using some zones in more than one select "group" and doing it by zone state makes other select buttons that include that zone light up.
     
  3. Chris Harris

    Chris Harris Member

    UPDATE:

    If I go to the initialization script and define the variable:

    GlobalVar value
    value = 1

    Then, my script works to turn on the light. But, it doesn't turn off the light on the second button push. What am I missing? Any scripting masters who can help me fix this?

    I can't tie the state of the light to the state of the zones because I have several zone group selects, many of which contain some of the same zones. If I tie the light to the state of the zones, it turns on all lights for each button that includes those zones. I need to tie the state of the light to the button push on the controller.
     

Share This Page