Class: I2CDevice

Inherits:
Object
  • Object
show all
Defined in:
lib/i2c.rb

Direct Known Subclasses

ADT7410, HD44780, MPL115A2

Defined Under Namespace

Modules: Driver Classes: I2CBUSBusy, I2CException, I2CIOError

Constant Summary collapse

VERSION =
"0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ I2CDevice

Returns a new instance of I2CDevice.



10
11
12
13
14
15
16
17
18
# File 'lib/i2c.rb', line 10

def initialize(args={})
  if args[:driver].nil?
    require "i2c/driver/i2c-dev"
    args[:driver] = I2CDevice::Driver::I2CDev.new
  end

  @driver  = args[:driver]
  @address = args[:address] or raise I2CException, "args[:address] required"
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



8
9
10
# File 'lib/i2c.rb', line 8

def address
  @address
end

Instance Method Details

#i2cget(param, length = 1) ⇒ Object



20
21
22
# File 'lib/i2c.rb', line 20

def i2cget(param, length=1)
  @driver.i2cget(@address, param, length)
end

#i2cset(*data) ⇒ Object



24
25
26
# File 'lib/i2c.rb', line 24

def i2cset(*data)
  @driver.i2cset(@address, *data)
end