Class: BBB::Components::Led

Inherits:
Object
  • Object
show all
Includes:
Pinnable
Defined in:
lib/BBB/components/led.rb

Overview

The LED class is the component interface into a digital pin. In a way it’s nothing more than a straight forward port of a digital pin. You can use a led component when you want to use digital pins, or simply define your own class and extend it from the LED.

The Led class does not perform any sort of caching or smart calls, it forwards everything to the pin. In your own applications you might want to tune this behavior by adding some kind of caching.

Instance Attribute Summary

Attributes included from Pinnable

#pins

Instance Method Summary collapse

Methods included from Pinnable

#after_pin_initialization, included, #initialize_pins, #pinnable?, #verify_pin_position_count

Instance Method Details

#off!Object

Turns off the LED

Returns:

  • void



39
40
41
# File 'lib/BBB/components/led.rb', line 39

def off!
  pin.off!
end

#off?Boolean

Checks if the LED is turned off.

Returns:

  • (Boolean)

    Boolean



57
58
59
# File 'lib/BBB/components/led.rb', line 57

def off?
  pin.off?
end

#on!Object

Turns on the LED

Returns:

  • void



31
32
33
# File 'lib/BBB/components/led.rb', line 31

def on!
  pin.on!
end

#on?Boolean

Checks if the LED is turned on.

Returns:

  • (Boolean)

    Boolean



48
49
50
# File 'lib/BBB/components/led.rb', line 48

def on?
  pin.on?
end

#pinObject

Convenience method to grab the first pin in the pins array

Returns:

  • BBB::Pins::DigitalOutputPin



23
24
25
# File 'lib/BBB/components/led.rb', line 23

def pin
  pins.first
end