Sha256: 55668cfa23f45abcadfab6ec0eead2bb25de4905714a812d66ff4a95510b685e

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'launchpad'

interaction = Launchpad::Interaction.new

def brightness(action)
  action[:state] == :down ? :hi : :off
end

# yellow feedback for grid buttons
interaction.response_to(:grid) do |interaction, action|
  b = brightness(action)
  interaction.device.change(:grid, action.merge(:red => b, :green => b))
end

# red feedback for top control buttons
interaction.response_to([:up, :down, :left, :right, :session, :user1, :user2, :mixer]) do |interaction, action|
  interaction.device.change(action[:type], :red => brightness(action))
end

# green feedback for scene buttons
interaction.response_to([:scene1, :scene2, :scene3, :scene4, :scene5, :scene6, :scene7, :scene8]) do |interaction, action|
  interaction.device.change(action[:type], :green => brightness(action))
end

# mixer button terminates interaction on button up
interaction.response_to(:mixer, :up) do |interaction, action|
  interaction.stop
end

# start interacting
interaction.start

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

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mrjoy-launchpad-0.4.0 examples/feedback.rb
launchpad-0.3.0 examples/feedback.rb