Class: I2CDevice
- Inherits:
-
Object
- Object
- I2CDevice
- Defined in:
- lib/i2c.rb
Defined Under Namespace
Modules: Driver Classes: I2CBUSBusy, I2CException, I2CIOError
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
Instance Method Summary collapse
- #i2cget(param, length = 1) ⇒ Object
- #i2cset(*data) ⇒ Object
-
#initialize(args = {}) ⇒ I2CDevice
constructor
A new instance of I2CDevice.
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
#address ⇒ Object
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 |