class RubyBuzz::Light
Each Pad
has one LED light under the buzzer button.
There are four Light
objects, each controls one of these lights.
Accessed via Pad:
‘RubyBuzz::Pad.light`
Controlled individually:
-
‘RubyBuzz::Pad.light.on`
-
‘RubyBuzz::Pad.light.off`
Controlled together:
Attributes
file[RW]
Public Class Methods
all_off()
click to toggle source
Turn all lights off
# File lib/ruby_buzz/light.rb, line 57 def self.all_off @@lights.each{|l|l.off} return nil end
all_on()
click to toggle source
Turn all lights on
# File lib/ruby_buzz/light.rb, line 65 def self.all_on @@lights.each{|l|l.on } return nil end
new(index)
click to toggle source
Initialize a buzzer by index 0 to 3.
Arguments:
-
index - Integer, 0 to 3, which light does this represent.
# File lib/ruby_buzz/light.rb, line 33 def initialize(index) @file = `ls /sys/class/leds/*buzz#{index + 1}/brightness` @@lights << self end
Public Instance Methods
off()
click to toggle source
Turn the light off
# File lib/ruby_buzz/light.rb, line 49 def off `echo 0 > #{file}` return nil end
on()
click to toggle source
Turn the light on
# File lib/ruby_buzz/light.rb, line 41 def on `echo 1 > #{file}` return nil end