Class: EventMachine::Gpio::Pin
- Inherits:
-
Object
- Object
- EventMachine::Gpio::Pin
- Includes:
- Callbacks
- Defined in:
- lib/em-gpio/pin.rb
Constant Summary collapse
- PINS =
0..22
- MODES =
[:in, :out]
- HIGH =
1
- LOW =
0
Constants included from Callbacks
Instance Attribute Summary collapse
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#last_value ⇒ Object
Returns the value of attribute last_value.
-
#pin ⇒ Object
Returns the value of attribute pin.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #changed? ⇒ Boolean
-
#initialize(pin, options = {}) ⇒ Pin
constructor
A new instance of Pin.
- #read ⇒ Object
- #write(value) ⇒ Object
Methods included from Callbacks
Constructor Details
#initialize(pin, options = {}) ⇒ Pin
Returns a new instance of Pin.
13 14 15 16 17 18 |
# File 'lib/em-gpio/pin.rb', line 13 def initialize(pin, ={}) @direction = [:direction] || :out @pin = pin validate setup_mode end |
Instance Attribute Details
#direction ⇒ Object
Returns the value of attribute direction.
11 12 13 |
# File 'lib/em-gpio/pin.rb', line 11 def direction @direction end |
#last_value ⇒ Object
Returns the value of attribute last_value.
11 12 13 |
# File 'lib/em-gpio/pin.rb', line 11 def last_value @last_value end |
#pin ⇒ Object
Returns the value of attribute pin.
11 12 13 |
# File 'lib/em-gpio/pin.rb', line 11 def pin @pin end |
#value ⇒ Object
Returns the value of attribute value.
11 12 13 |
# File 'lib/em-gpio/pin.rb', line 11 def value @value end |
Instance Method Details
#changed? ⇒ Boolean
29 30 31 |
# File 'lib/em-gpio/pin.rb', line 29 def changed? value != last_value end |
#read ⇒ Object
20 21 22 23 |
# File 'lib/em-gpio/pin.rb', line 20 def read @last_value = value @value = adapter.read end |
#write(value) ⇒ Object
25 26 27 |
# File 'lib/em-gpio/pin.rb', line 25 def write(value) adapter.write(value) end |