def note(type, opts)
      note = TYPE_TO_NOTE[type]
      if note.nil?
        x = (opts[:x] || -1).to_i
        y = (opts[:y] || -1).to_i
        if x < 0 || x > 7 || y < 0 || y > 7
          logger.error "wrong coordinates specified: x=#{x}, y=#{y}"
          raise NoValidGridCoordinatesError.new("you need to specify valid coordinates (x/y, 0-7, from top left), you specified: x=#{x}, y=#{y}")
        end
        note = y * 16 + x
      end
      note
    end
def note(type, opts)
      note = TYPE_TO_NOTE[type]
      if note.nil?
        x = (opts[:x] || -1).to_i
        y = (opts[:y] || -1).to_i
        if x < 0 || x > 7 || y < 0 || y > 7
          logger.error "wrong coordinates specified: x=#{x}, y=#{y}"
          raise NoValidGridCoordinatesError.new("you need to specify valid coordinates (x/y, 0-7, from top left), you specified: x=#{x}, y=#{y}")
        end
        note = y * 16 + x
      end
      note
    end
Calculates the MIDI data 1 value (note) for a button.

 Parameters (see Launchpad for values):

 [+type+] type of the button

 Options hash:

 [<tt>:x</tt>]     x coordinate
 [<tt>:y</tt>]     y coordinate

 Returns:

 integer to be used for MIDI data 1

 Errors raised:

 [Launchpad::NoValidGridCoordinatesError] when coordinates aren't within the valid range