Class: Artoo::Drivers::Led
Overview
Instance Attribute Summary
Attributes inherited from Driver
#parent
Instance Method Summary
collapse
Methods inherited from Driver
#connection, #event_topic_name, #initialize, #interval, #method_missing, #pin, #start_driver
Methods included from Celluloid
#timers
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Artoo::Drivers::Driver
Instance Method Details
#brightness(level = 0) ⇒ Object
31
32
33
34
|
# File 'lib/artoo/drivers/led.rb', line 31
def brightness(level=0)
connection.set_pin_mode(pin, Firmata::Board::PWM)
connection.analog_write(pin, level)
end
|
#is_off? ⇒ Boolean
11
12
13
|
# File 'lib/artoo/drivers/led.rb', line 11
def is_off?
(@is_on ||= false) == false
end
|
#is_on? ⇒ Boolean
7
8
9
|
# File 'lib/artoo/drivers/led.rb', line 7
def is_on?
(@is_on ||= false) == true
end
|
#off ⇒ Object
21
22
23
24
25
|
# File 'lib/artoo/drivers/led.rb', line 21
def off
@is_on = false
connection.set_pin_mode(pin, Firmata::Board::OUTPUT)
connection.digital_write(pin, Firmata::Board::LOW)
end
|
#on ⇒ Object
15
16
17
18
19
|
# File 'lib/artoo/drivers/led.rb', line 15
def on
@is_on = true
connection.set_pin_mode(pin, Firmata::Board::OUTPUT)
connection.digital_write(pin, Firmata::Board::HIGH)
end
|
#toggle ⇒ Object
27
28
29
|
# File 'lib/artoo/drivers/led.rb', line 27
def toggle
is_off? ? on : off
end
|