Class: PiDriver::I2CMaster
- Inherits:
-
Object
- Object
- PiDriver::I2CMaster
- Defined in:
- lib/pi_driver/i2c_master.rb
Instance Method Summary collapse
- #ack ⇒ Object
-
#initialize(options = {}) ⇒ I2CMaster
constructor
A new instance of I2CMaster.
- #read ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #write(byte) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ I2CMaster
Returns a new instance of I2CMaster.
3 4 5 6 7 8 9 10 |
# File 'lib/pi_driver/i2c_master.rb', line 3 def initialize( = {}) @frequency = 100_000 @delta_time = @frequency ** -1.0 @clock_pin = [:clock_pin] @data_pin = [:data_pin] @num_bits = 8 stop end |
Instance Method Details
#ack ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/pi_driver/i2c_master.rb', line 32 def ack release_data_pin release_clock_pin success = @data_pin.clear? drive_clock_pin success end |
#read ⇒ Object
27 28 29 30 |
# File 'lib/pi_driver/i2c_master.rb', line 27 def read release_data_pin read_data end |
#start ⇒ Object
17 18 19 20 |
# File 'lib/pi_driver/i2c_master.rb', line 17 def start drive_data_pin drive_clock_pin end |
#stop ⇒ Object
12 13 14 15 |
# File 'lib/pi_driver/i2c_master.rb', line 12 def stop release_clock_pin release_data_pin end |
#write(byte) ⇒ Object
22 23 24 25 |
# File 'lib/pi_driver/i2c_master.rb', line 22 def write(byte) send_data byte byte end |