Class: MonomeSerial::Examples::Toggle
- Inherits:
-
Object
- Object
- MonomeSerial::Examples::Toggle
- Defined in:
- lib/monome_serial/examples/toggle.rb
Instance Method Summary collapse
-
#initialize ⇒ Toggle
constructor
A new instance of Toggle.
-
#start ⇒ Object
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.
Constructor Details
#initialize ⇒ Toggle
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
#start ⇒ Object
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 |