Class: Bus::I2C

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

Overview

I2C interface to devices

Constant Summary collapse

@@bus_number =
1
@@i2c_bus =
'/dev/i2c-1'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.busObject

Return the I2C bus file



30
31
32
# File 'lib/bus.rb', line 30

def self.bus
  @@i2c_bus
end

.bus_numberObject



25
26
27
# File 'lib/bus.rb', line 25

def self.bus_number
  @@bus_number
end

.bus_number=(bus = 1) ⇒ Object

Define the I2C bus number: 0 | 1 (default)



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

def self.bus_number=(bus=1)
  @@bus_number = bus
  @@i2c_bus = "/dev/i2c-#{bus}"
end

Instance Method Details

#device_addressObject

Return the device address



40
41
42
# File 'lib/bus.rb', line 40

def device_address
  @device_address
end

#device_address=(address) ⇒ Object

Define the device address



35
36
37
# File 'lib/bus.rb', line 35

def device_address=(address)
  @device_address = address
end