Class: PiWire::OutputPin
- Defined in:
- lib/pi_wire/output_pin.rb,
ext/pi_wire/pi_wire_output_pin.c
Instance Attribute Summary
Attributes inherited from Pin
Instance Method Summary collapse
- #high! ⇒ Object
- #high? ⇒ Boolean
-
#initialize(number) ⇒ OutputPin
constructor
A new instance of OutputPin.
- #low! ⇒ Object
- #low? ⇒ Boolean
- #read ⇒ Object
- #toggle! ⇒ Object
- #write(rb_int) ⇒ Object (also: #<<)
Constructor Details
#initialize(number) ⇒ OutputPin
Returns a new instance of OutputPin.
3 4 5 6 |
# File 'lib/pi_wire/output_pin.rb', line 3 def initialize(number) @number = number self.mode = PiWire::OUTPUT_MODE end |
Instance Method Details
#high! ⇒ Object
20 21 22 |
# File 'lib/pi_wire/output_pin.rb', line 20 def high! write PiWire::HIGH end |
#high? ⇒ Boolean
12 13 14 |
# File 'lib/pi_wire/output_pin.rb', line 12 def high? read == PiWire::HIGH end |
#read ⇒ Object
3 4 5 6 |
# File 'ext/pi_wire/pi_wire_output_pin.c', line 3 static VALUE read(VALUE self) { int pin_value = digitalRead(pin_number(self)); return INT2FIX(pin_value); } |
#toggle! ⇒ Object
24 25 26 |
# File 'lib/pi_wire/output_pin.rb', line 24 def toggle! low? ? high! : low! end |
#write(rb_int) ⇒ Object Also known as: <<
8 9 10 11 |
# File 'ext/pi_wire/pi_wire_output_pin.c', line 8
static VALUE write(VALUE self, VALUE rb_int) {
digitalWrite(pin_number(self), NUM2INT(rb_int));
return Qtrue;
}
|