Buttons and Triggers Overview

by
BMC Documentation

A button trigger is the action on the button that will execute the corresponding event.

BMC let's you have up to 8 Events per button, each event can be assigned to a different trigger.

BMC is constantly reading buttons, button pins in BMC are pulled HIGH, that is, they are HIGH until you press the button down, then they are LOW.

BMC also handles debouncing (you can read about it here) without using the delay() function so there's no need to worry about that.

For an event in a button to be triggered 2 conditions must be met:

  1. The button MUST have a trigger assigned other than NONE/INACTIVE.
  2. The button MUST have a valid event assigned.

In other words if you have an event slot with trigger assigned but no event, nothing happens, if you have a button slot with an event but the trigger set to NONE nothing happens.

Everytime you press/release a button BMC will create triggers based on how the button is pressed you can actually see exactly what triggers are created if you have debug enabled and you type "buttons" (without the quotes) on the arduino's serial monitor, for example, pressing and releasing a button quickly will create these triggers in this order:

  1. Button PRESS
  2. Button STATE CHANGE
  3. Button RELEASE (only after Press)
  4. Button RELEASE (Always)
  5. Button STATE CHANGE

You will notice that BMC created a PRESS trigger, 2 RELEASE triggers and 2 STATE CHANGE triggers, the PRESS trigger is self-explanatory, the second trigger STATE CHANGE means that the switch went from HIGH to LOW, aka from Not Pressed to Pressed, the next one RELEASE (only after Press) was created because the last "Non-Release" trigger (STATE CHANGE doesn't count) was a PRESS trigger, therefor a RELEASE AFTER PRESS trigger was created when the switch was unpressed, the RELEASE (ALWAYS) trigger is obviously created when you release the button no matter what other triggers were created, the last trigger STATE CHANGE refers to the switch now going from LOW to HIGH aka from being Pressed to Not being pressed. The STATE CHANGE triggers were designed for Latching Switches and as examplained will be triggered anytime the button goes from LOW to HIGH or HIGH to LOW.

If you press and hold it down for 500ms (or the value you set in BMC Settings) BMC will then create the following events:

  1. Button PRESS
  2. Button STATE CHANGE
  3. Button HOLD
  4. Button RELEASE (only after Hold)
  5. Button RELEASE (Always)
  6. Button STATE CHANGE

This example works the same, however in this case the RELEASE (only after Press) was not created because the last "Non-Release" trigger was HOLD, therefor a RELEASE (only after Hold) trigger was created when the button was released, all other triggers were created the same because their corresponding parameters were met.

NOTE: when you release a button all data for triggers on that button is reset, meaning the button is just waiting for a press now.

When Layers Change

BMC will reset all buttons, at the same time, BMC will wait for any button that's being held down to be released before it allows that button to do anything and when the button is released NONE of it's events or triggers will have any effect, this is by design because you could assign a button to change Layers and this helps avoid unexpected behaviour of the button when a layer is changed.

What happens when a Trigger is created?

When a trigger is created BMC will go thru the list of the button's events and any event that has that trigger assigned will be executed, you can have multiple events with the same trigger and use any combination you want with them, events with the same trigger type will be triggered in order starting with event slot 1.

Since BMC is customizable (there's no set number of buttons you can have) it doesn't have as specific behaviour for buttons like most MIDI controllers out there, for this reason you have to assign every function to the button with events, many midi footcontrollers will send MIDI PC and MIDI CC with their footswitches, some are fixed to a specific PC/CC some are not, some will also send a MIDI CC with a value of 127 when you press the switch and a value of 0 when you release it, some toggle between 127 and 0 with each press, etc. BMC doesn't, with BMC you specficy the Channel, CC # and value that you want to send and what type of press will trigger it.

This adds an extra step in some case, for example maybe you do want to send CC value 127 when you press the button and value 0 when you release it, to do this in BMC you will have to create 2 MIDI Control Change events, one with value 0 and one with value 127, then assign the event with value 127 to the first event slot in the button and set it's trigger to PRESS, then set the event with value 0 to the next button event slot and set it's trigger to RELEASE (ALWAYS). This will ensure that the the value 127 and value 0 are always send, this is because as mentioned earlier those to are always triggered.

NOTE: even tho I say that the PRESS trigger is always created there is one case where it isn't, if your button has an event with a "2ND PRESS" trigger then the PRESS and 2ND PRESS triggers will alternate, when you first press the button it's a PRESS, next time you press it it's a 2ND PRESS, next time it's a PRESS and so on until the end of time OR until you switch Layers, then no matter what, the next press on any button will be a PRESS and continue to alternate but again this is only if the button has an event with a 2ND PRESS trigger assigned, otherwise it will always be a PRESS.

There are lots of posible ways to assign triggers to get different combinations of events being triggered, for example if you want 2 different functions on your button you could assign one event a RELEASE (PRESS) trigger and another event a HOLD trigger, this will trigger one event when you press and release the button quickly and trigger another event when you HOLD the button for the hold time, this will also only trigger one or the other and not both events at the same time.

As usual the best way to understand how things work is to try them out, try using events with different triggers in differnt combinations to get the results you want.

BMC Button Triggers are:

  • None/Inactive: the event is ignored, BMC will still read the button and create triggers but the event in the slot will not be triggered, you can leave any un-used event slots set to None/Inactive.
  • Press: Triggers event on the Rising Edge, in otherwords then the button first changes from not being press to being pressed. This trigger is always created when you first press a button unless that button has an event with a 2ND Press trigger.
  • Hold: Triggers the event after the button has been held down for a set time, this time can be changed in BMC Settings.
  • 2nd Press: Triggers the event the second time you press the button, this is reset when you change layers.
  • Double Press: Triggers the event when you double press the button, if an event has a Double Press trigger all events will be delayd a few milliseconds to allow reading the double press.
  • Continuous: Triggers the event continuously while the button is held down, this trigger will happen AFTER you reached a HOLD trigger was created.
  • State Change: Triggers the event every time the button changes state between HIGH and LOW, this was designed for latching switching.
  • Release (Always): Triggers the event everytime the button is released no matter what.
  • Release (Press): Triggers the event when you release the button but only if the last "Non-Release" trigger was a PRESS Trigger.
  • Release (Hold): Triggers the event when you release the button but only if the last "Non-Release" trigger was a HOLD Trigger.
  • Release (2nd Press): Triggers the event when you release the but only if the last "Non-Release" trigger was a 2ND PRESS Trigger.
  • Release (Dble Press): Triggers the event when you release the but only if the last "Non-Release" trigger was a DOUBLE PRESS Trigger.
  • Release (Continuous): Triggers the event when you release the but only if the last "Non-Release" trigger was a CONTINUOUS Trigger.

The STATE CHANGE trigger

This trigger is created whenever the switch goes from HIGH to LOW and Vice-Versa, in otherwords when you press the button and when you release it, this was designed to be used with latching switched, normally with digital equipment you want to use momentary (or non-latching) switches, that means that the contacts on the switch will be shorted only while the switch is held down, the the signals are disconnected when you let go of the switch, this allows the Micro Controller to handle all the actions that happen when you press/release, However, some cases may require a latching switch (think of a typical footswitch used for bypassing a guitar pedal), that's all you have available then you could use them, however, when you press and let go the button, a PRESS trigger is created, then a HOLD, then CONTINUOUS triggers, when you press it again then RELEASE for Continuous will be triggered along with RELEASE ALWAYS and so on.

This is all well and good but when you switch pages, BMC will wait for you to release all buttons before enabling that button and since that latching button is currently in PRESS position the next time you press it all it's actions will be ignored, for this case STATE CHANGE will work better, just add an Event with a STATE CHANGE trigger and everytime you press that latching button that event will be executed. NOTE: if you use this trigger type with a momentary switch the trigger will be create it when you press and release so the event attached will be triggere twice within one button press/release cycle.

Nero

About Nero

I'm a Musician, Web Developer, Graphic Designer, Sound Engineer and the list goes on!
View all posts by Nero


Sign In to leave a comment

OR

Comment as a Guest