Sha256: c43e90c3f9552ddfeaee4f68752f427f9319432630947d514e3e61da8aa96454

Contents?: true

Size: 783 Bytes

Versions: 5

Compression:

Stored size: 783 Bytes

Contents

require File.join(File.dirname(__FILE__), 'setup')

interaction = Launchpad::Interaction.new

flags = Hash.new(false)

# yellow feedback for grid buttons
interaction.response_to(:grid, :down) do |interaction, action|
  coord = 16 * action[:y] + action[:x]
  brightness = flags[coord] ? :off : :hi
  flags[coord] = !flags[coord]
  interaction.device.change(:grid, action.merge(:red => brightness, :green => brightness))
end

# mixer button terminates interaction on button up
interaction.response_to(:mixer) do |interaction, action|
  interaction.device.change(:mixer, :red => action[:state] == :down ? :hi : :off)
  interaction.stop if action[:state] == :up
end

# start interacting
interaction.start

# sleep so that the messages can be sent before the program terminates
sleep 0.1

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
launchpad-0.2.2 examples/drawing_board.rb
launchpad-0.2.1 examples/drawing_board.rb
launchpad-0.2.0 examples/drawing_board.rb
launchpad-0.1.1 examples/drawing_board.rb
launchpad-0.1.0 examples/drawing_board.rb