Class: Bus::I2C
- Inherits:
-
Object
- Object
- Bus::I2C
- 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
-
.bus ⇒ Object
Return the I2C bus file.
- .bus_number ⇒ Object
-
.bus_number=(bus = 1) ⇒ Object
Define the I2C bus number: 0 | 1 (default).
Instance Method Summary collapse
-
#device_address ⇒ Object
Return the device address.
-
#device_address=(address) ⇒ Object
Define the device address.
Class Method Details
.bus ⇒ Object
Return the I2C bus file
30 31 32 |
# File 'lib/bus.rb', line 30 def self.bus @@i2c_bus end |
.bus_number ⇒ Object
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_address ⇒ Object
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 |