Class: Artoo::Adaptors::Beaglebone

Inherits:
Adaptor
  • Object
show all
Includes:
IO
Defined in:
lib/artoo/adaptors/beaglebone.rb

Overview

Connect to a beaglebone device

See Also:

  • documentation for more information

Constant Summary collapse

PINS =
{
  :P8_3 => 38,
  :P8_4 => 39,
  :P8_5 => 34,
  :P8_6 => 35,
  :P8_7 => 66,
  :P8_8 => 67,
  :P8_9 => 69,
  :P8_10 => 68,
  :P8_11 => 45,
  :P8_12 => 44,
  :P8_13 => 23,
  :P8_14 => 26,
  :P8_15 => 47,
  :P8_16 => 46,
  :P8_17 => 27,
  :P8_18 => 65,
  :P8_19 => 22,
  :P8_20 => 63,
  :P8_21 => 62,
  :P8_22 => 37,
  :P8_23 => 36,
  :P8_24 => 33,
  :P8_25 => 32,
  :P8_26 => 61,
  :P8_27 => 86,
  :P8_28 => 88,
  :P8_29 => 87,
  :P8_30 => 89,
  :P8_31 => 10,
  :P8_32 => 11,
  :P8_33 => 9,
  :P8_34 => 81,
  :P8_35 => 8,
  :P8_36 => 80,
  :P8_37 => 78,
  :P8_38 => 79,
  :P8_39 => 76,
  :P8_40 => 77,
  :P8_41 => 74,
  :P8_42 => 75,
  :P8_43 => 72,
  :P8_44 => 73,
  :P8_45 => 70,
  :P8_46 => 71,
  :P9_11 => 30,
  :P9_12 => 60,
  :P9_13 => 31,
  :P9_14 => 50,
  :P9_15 => 48,
  :P9_16 => 51,
  :P9_17 => 5,
  :P9_18 => 4,
  :P9_19 => 13,
  :P9_20 => 12,
  :P9_21 => 3,
  :P9_22 => 2,
  :P9_23 => 49,
  :P9_24 => 15,
  :P9_25 => 117,
  :P9_26 => 14,
  :P9_27 => 115,
  :P9_28 => 113,
  :P9_29 => 111,
  :P9_30 => 112,
  :P9_31 => 110
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#i2cObject (readonly)

Returns the value of attribute i2c.



78
79
80
# File 'lib/artoo/adaptors/beaglebone.rb', line 78

def i2c
  @i2c
end

#pinsObject (readonly)

Returns the value of attribute pins.



78
79
80
# File 'lib/artoo/adaptors/beaglebone.rb', line 78

def pins
  @pins
end

#pwm_pinsObject (readonly)

Returns the value of attribute pwm_pins.



78
79
80
# File 'lib/artoo/adaptors/beaglebone.rb', line 78

def pwm_pins
  @pwm_pins
end

Instance Method Details

#connectBoolean

Creates a connection with device

Returns:

  • (Boolean)


82
83
84
85
86
# File 'lib/artoo/adaptors/beaglebone.rb', line 82

def connect
  @pins = [] if @pins.nil?
  @pwm_pins = [] if @pwm_pins.nil?
  super
end

#digital_read(pin) ⇒ Object



105
106
107
108
# File 'lib/artoo/adaptors/beaglebone.rb', line 105

def digital_read pin
  pin = beaglebone_pin(pin, "r")
  pin.digital_read
end

#digital_write(pin, val) ⇒ Object



100
101
102
103
# File 'lib/artoo/adaptors/beaglebone.rb', line 100

def digital_write pin, val
  pin = beaglebone_pin(pin, "w")
  pin.digital_write(val)
end

#firmware_nameString

Name of device

Returns:

  • (String)


90
91
92
# File 'lib/artoo/adaptors/beaglebone.rb', line 90

def firmware_name
  "Beaglebone"
end

#i2c_read(len) ⇒ Object



118
119
120
# File 'lib/artoo/adaptors/beaglebone.rb', line 118

def i2c_read len
  i2c.read len
end

#i2c_start(address) ⇒ Object



110
111
112
# File 'lib/artoo/adaptors/beaglebone.rb', line 110

def i2c_start address
   @i2c = I2c.new i2c2_file, address
end

#i2c_write(*data) ⇒ Object



114
115
116
# File 'lib/artoo/adaptors/beaglebone.rb', line 114

def i2c_write *data
  i2c.write *data
end

#pwm_write(pin, period, duty = 0) ⇒ Object



122
123
124
125
# File 'lib/artoo/adaptors/beaglebone.rb', line 122

def pwm_write(pin, period, duty=0)
  pin = pwm_pin(pin)
  pin.pwm_write(period, duty)
end

#release_all_pwm_pinsObject



133
134
135
# File 'lib/artoo/adaptors/beaglebone.rb', line 133

def release_all_pwm_pins
  pwm_pins.each_value { |pwm_pin| pwm_pin.release }
end

#release_pwm(pin) ⇒ Object



127
128
129
130
131
# File 'lib/artoo/adaptors/beaglebone.rb', line 127

def release_pwm(pin)
  pin = translate_pin(pin)
  pwm_pins[pin].release
  pwm_pins[pin] = nil
end

#versionString

Version of device

Returns:

  • (String)


96
97
98
# File 'lib/artoo/adaptors/beaglebone.rb', line 96

def version
  Artoo::Beaglebone::VERSION
end