def velocity(opts)
      if opts.is_a?(Hash)
        red = brightness(opts[:red] || 0)
        green = brightness(opts[:green] || 0)
        color = 16 * green + red
        flags = case opts[:mode]
                when :flashing  then  8
                when :buffering then  0
                else                  12
                end
        color + flags
      else
        opts.to_i + 12
      end
    end
def velocity(opts)
      if opts.is_a?(Hash)
        red = brightness(opts[:red] || 0)
        green = brightness(opts[:green] || 0)
        color = 16 * green + red
        flags = case opts[:mode]
                when :flashing  then  8
                when :buffering then  0
                else                  12
                end
        color + flags
      else
        opts.to_i + 12
      end
    end
Calculates the MIDI data 2 value (velocity) for given brightness and mode values.

 Options hash:

 [<tt>:red</tt>]   brightness of red LED
 [<tt>:green</tt>] brightness of green LED
 [<tt>:mode</tt>]  button mode, defaults to <tt>:normal</tt>, one of:
                   [<tt>:normal/tt>]     updates the LED for all circumstances (the new value will be written to both buffers)
                   [<tt>:flashing/tt>]   updates the LED for flashing (the new value will be written to buffer 0 while in buffer 1, the value will be :off, see )
                   [<tt>:buffering/tt>]  updates the LED for the current update_buffer only

 Returns:

 integer to be used for MIDI data 2

 Errors raised:

 [Launchpad::NoValidBrightnessError] when brightness values aren't within the valid range