Class: MonomeSerial::Examples::Toggle

Inherits:
Object
  • Object
show all
Defined in:
lib/monome_serial/examples/toggle.rb

Instance Method Summary collapse

Constructor Details

#initializeToggle

Returns a new instance of Toggle.



4
5
6
7
8
# File 'lib/monome_serial/examples/toggle.rb', line 4

def initialize

  @monome = MonomeSerial.detect_monome
  @light_lit = Hash.new(false)
end

Instance Method Details

#startObject

Enter a loop in which you read events from the monome and if the event is a :keypress, then toggle the led on the monome



12
13
14
15
16
17
18
19
# File 'lib/monome_serial/examples/toggle.rb', line 12

def start
  Thread.new do
    loop do
      action, x, y = @monome.read
      toggle_led(x,y) if action == :keydown
    end
  end
end