Class: Artoo::Drivers::Neopixel
- Inherits:
-
Driver
- Object
- Driver
- Artoo::Drivers::Neopixel
- Defined in:
- lib/artoo/drivers/neopixel.rb
Constant Summary collapse
- COMMANDS =
[:on, :off, :on?, :off?].freeze
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#registered ⇒ Object
readonly
Returns the value of attribute registered.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Neopixel
constructor
A new instance of Neopixel.
- #off(index) ⇒ Object
- #off?(index) ⇒ Boolean
- #on(index, red, green, blue) ⇒ Object
- #on?(index) ⇒ Boolean
Constructor Details
#initialize(params = {}) ⇒ Neopixel
Returns a new instance of Neopixel.
10 11 12 13 14 15 16 |
# File 'lib/artoo/drivers/neopixel.rb', line 10 def initialize(params = {}) @is_on = Hash.new(false) additional_params = params.fetch(:additional_params) { Hash.new } @count = additional_params.fetch(:count) @registered = false super end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
8 9 10 |
# File 'lib/artoo/drivers/neopixel.rb', line 8 def count @count end |
#registered ⇒ Object (readonly)
Returns the value of attribute registered.
8 9 10 |
# File 'lib/artoo/drivers/neopixel.rb', line 8 def registered @registered end |
Instance Method Details
#off(index) ⇒ Object
31 32 33 34 |
# File 'lib/artoo/drivers/neopixel.rb', line 31 def off(index) change_state(index, 0, 0, 0) @is_on[index] = false end |
#off?(index) ⇒ Boolean
22 23 24 |
# File 'lib/artoo/drivers/neopixel.rb', line 22 def off?(index) !on?(index) end |
#on(index, red, green, blue) ⇒ Object
26 27 28 29 |
# File 'lib/artoo/drivers/neopixel.rb', line 26 def on(index, red, green, blue) change_state(index, red, green, blue) @is_on[index] = true end |
#on?(index) ⇒ Boolean
18 19 20 |
# File 'lib/artoo/drivers/neopixel.rb', line 18 def on?(index) @is_on[index] end |