class UdooNeoRest::Direction

Public Instance Methods

direction_get_gpio(gpio) click to toggle source

Get the direction for a specific gpio

gpio : the gpio to get

# File lib/udooneorest/direction.rb, line 60
def direction_get_gpio(gpio)

  # validate the gpio
  gpio_          = ValidateGpio.new gpio
  return gpio_.error_message unless gpio_.valid?

  # get the direction
  UdooNeoRest::Base.cat_and_status "#{BASE_PATH}gpio#{gpio}/direction"
end
direction_get_pin(pin) click to toggle source

Get the value for a specific pin

pin : the pin to be set (will be translated to GPIO)

# File lib/udooneorest/direction.rb, line 45
def direction_get_pin(pin)

  # Validate the pin
  pin_ = ValidatePin.new pin
  return pin_.error_message unless pin_.valid?

  # Get the value after translating to gpio
  direction_get_gpio pin_.to_gpio
end
direction_set_gpio(gpio, direction) click to toggle source

Set a specific gpio to the nominated direction

gpio : the gpio to be set direction : the direction to be used

# File lib/udooneorest/direction.rb, line 92
def direction_set_gpio(gpio, direction)

  # validate the gpio
  gpio_          = ValidateGpio.new gpio
  return gpio_.error_message unless gpio_.valid?

  # validate the direction
  direction_     = ValidateDirection.new direction
  return direction_.error_message unless direction_.valid?

  # Send the command and if no error return an OK result else return the error
  result         = UdooNeoRest::Base.echo direction, "#{BASE_PATH}gpio#{gpio}/direction"
  result.empty? ? UdooNeoRest::Base.status_ok : UdooNeoRest::Base.status_error(result)
end
direction_set_pin(pin, direction) click to toggle source

Set a specific pin to the nominated direction

pin : the pin to be set (will be translated to GPIO) direction : the direction to be used

# File lib/udooneorest/direction.rb, line 76
def direction_set_pin(pin, direction)

  # valide the pin
  pin_ = ValidatePin.new pin
  return pin_.error_message unless pin_.valid?

  # Set the direction after translating to gpio
  direction_set_gpio pin_.to_gpio, direction
end