Class: WiringPi::I2C
- Inherits:
-
Object
- Object
- WiringPi::I2C
- Defined in:
- lib/wiringpi/i2c.rb
Instance Method Summary collapse
-
#initialize(device_address) ⇒ I2C
constructor
A new instance of I2C.
- #read ⇒ Object
- #read_reg_16(reg) ⇒ Object
- #read_reg_8(reg) ⇒ Object
- #write(data) ⇒ Object
- #write_reg_16(reg, data) ⇒ Object
- #write_reg_8(reg, data) ⇒ Object
Constructor Details
#initialize(device_address) ⇒ I2C
Returns a new instance of I2C.
4 5 6 |
# File 'lib/wiringpi/i2c.rb', line 4 def initialize(device_address) @device_id = Wiringpi.wiringPiI2CSetup(device_address) end |
Instance Method Details
#read ⇒ Object
7 8 9 |
# File 'lib/wiringpi/i2c.rb', line 7 def read() return Wiringpi.wiringPiI2CRead(@device_id) end |
#read_reg_16(reg) ⇒ Object
19 20 21 |
# File 'lib/wiringpi/i2c.rb', line 19 def read_reg_16(reg) return Wiringpi.wiringPiI2CReadReg16(@device_id,reg) end |
#read_reg_8(reg) ⇒ Object
13 14 15 |
# File 'lib/wiringpi/i2c.rb', line 13 def read_reg_8(reg) return Wiringpi.wiringPiI2CReadReg8(@device_id,reg) end |
#write(data) ⇒ Object
10 11 12 |
# File 'lib/wiringpi/i2c.rb', line 10 def write(data) return Wiringpi.wiringPiI2CWrite(@device_id,data) end |
#write_reg_16(reg, data) ⇒ Object
22 23 24 |
# File 'lib/wiringpi/i2c.rb', line 22 def write_reg_16(reg,data) return Wiringpi.wiringPiI2CWriteReg16(@device_id,reg,data) end |
#write_reg_8(reg, data) ⇒ Object
16 17 18 |
# File 'lib/wiringpi/i2c.rb', line 16 def write_reg_8(reg,data) return Wiringpi.wiringPiI2CWriteReg8(@device_id,reg,data) end |