lib/ffi/wiring_pi/gpio.rb in ffi-wiring_pi-0.1.2 vs lib/ffi/wiring_pi/gpio.rb in ffi-wiring_pi-0.1.3
- old
+ new
@@ -47,11 +47,11 @@
# @param pin [Integer] pin position (depends on setup mode)
# @param mode [Integer] `FFI::WiringPi::GPIO::INPUT`, `FFI::WiringPi::GPIO::OUTPUT`,
# `FFI::WiringPi::GPIO::PWM_OUTPUT` or `FFI::WiringPi::GPIO::GPIO_CLOCK`
attach_function :set_pin_mode, :pinMode, [:int, :int], :void
- def get(pin, mode = FFI::WiringPi::GPIO::OUTPUT)
+ def self.get(pin, mode = FFI::WiringPi::GPIO::OUTPUT)
set_pin_mode(pin, mode)
Pin.new(pin, mode)
end
# @param pin [Integer] pin position (depends on setup mode)
@@ -61,27 +61,27 @@
# Write pin state (aka digital_write)
#
# @param pin [Integer] pin position (depends on setup mode)
# @param state [Boolean] `true` to set to HIGH, `false` to set to LOW
#
- def write(pin, state)
+ def self.write(pin, state)
digital_write(state ? HIGH : LOW)
end
# Sets pin to HIGH state
#
# @param pin [Integer] pin position (depends on setup mode)
#
- def up(pin)
+ def self.up(pin)
write(pin, true)
end
# Sets pin to LOW state
#
# @param pin [Integer] pin position (depends on setup mode)
#
- def down(pin)
+ def self.down(pin)
write(pin, false)
end
# @param pin [Integer] pin position (depends on setup mode)
#
@@ -91,10 +91,10 @@
# Read pin state (aka digital_read)
#
# @param pin [Integer] pin position (depends on setup mode)
# @returns [Boolean] `true` if pin is in high state, `false` if in low
#
- def read(pin)
+ def self.read(pin)
result = digital_read(pin)
case result
when LOW
false
when HIGH