Class: ExtremeFeedbackDevice::Pi
- Inherits:
-
Object
- Object
- ExtremeFeedbackDevice::Pi
- Defined in:
- lib/extreme_feedback_device/pi.rb
Instance Attribute Summary collapse
-
#leds ⇒ Object
readonly
Returns the value of attribute leds.
Instance Method Summary collapse
-
#initialize(num_leds, spi_device = nil) ⇒ Pi
constructor
A new instance of Pi.
- #leds_black ⇒ Object
- #leds_black! ⇒ Object
- #leds_white ⇒ Object
- #leds_white! ⇒ Object
- #write! ⇒ Object
Constructor Details
#initialize(num_leds, spi_device = nil) ⇒ Pi
Returns a new instance of Pi.
9 10 11 12 13 |
# File 'lib/extreme_feedback_device/pi.rb', line 9 def initialize(num_leds, spi_device=nil) @leds = [] num_leds.times { @leds << ::Color::RGB.new } @spi_device = spi_device end |
Instance Attribute Details
#leds ⇒ Object (readonly)
Returns the value of attribute leds.
7 8 9 |
# File 'lib/extreme_feedback_device/pi.rb', line 7 def leds @leds end |
Instance Method Details
#leds_black ⇒ Object
23 24 25 |
# File 'lib/extreme_feedback_device/pi.rb', line 23 def leds_black leds.map! { |led| ::Color::RGB::Black } end |
#leds_black! ⇒ Object
27 28 29 |
# File 'lib/extreme_feedback_device/pi.rb', line 27 def leds_black! leds_black && write! end |
#leds_white ⇒ Object
15 16 17 |
# File 'lib/extreme_feedback_device/pi.rb', line 15 def leds_white leds.map! { |led| ::Color::RGB::White } end |
#leds_white! ⇒ Object
19 20 21 |
# File 'lib/extreme_feedback_device/pi.rb', line 19 def leds_white! leds_white && write! end |
#write! ⇒ Object
31 32 33 |
# File 'lib/extreme_feedback_device/pi.rb', line 31 def write! spi.write_colors(colors) end |