Class: Pigpio::I2C

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pi, i2c_bus, i2c_addr) ⇒ I2C

Returns a new instance of I2C.



4
5
6
7
# File 'lib/pigpio/i2c.rb', line 4

def initialize(pi, i2c_bus, i2c_addr)
  @pi = pi
  @handle = IF.i2c_open(@pi, i2c_bus, i2c_addr, 0)
end

Instance Attribute Details

#handleObject (readonly)

Returns the value of attribute handle.



3
4
5
# File 'lib/pigpio/i2c.rb', line 3

def handle
  @handle
end

#piObject (readonly)

Returns the value of attribute pi.



3
4
5
# File 'lib/pigpio/i2c.rb', line 3

def pi
  @pi
end

Instance Method Details

#block_process_call(i2c_reg, buf) ⇒ Object



61
62
63
# File 'lib/pigpio/i2c.rb', line 61

def block_process_call(i2c_reg, buf)
  IF.i2c_block_process_call(@pi, @handle, i2c_reg, buf)
end

#closeObject



9
10
11
# File 'lib/pigpio/i2c.rb', line 9

def close
  IF.i2c_close(@pi, @handle)
end

#process_call(i2c_reg, wVal) ⇒ Object



41
42
43
# File 'lib/pigpio/i2c.rb', line 41

def process_call(i2c_reg, wVal)
  IF.i2c_process_call(@pi, @handle, i2c_reg, wVal)
end

#read_block_data(i2c_reg) ⇒ Object



45
46
47
# File 'lib/pigpio/i2c.rb', line 45

def read_block_data(i2c_reg)
  IF.i2c_read_block_data(@pi, @handle, i2c_reg)
end

#read_byteObject



21
22
23
# File 'lib/pigpio/i2c.rb', line 21

def read_byte
  IF.i2c_read_byte(@pi, @handle)
end

#read_byte_data(i2c_reg) ⇒ Object



33
34
35
# File 'lib/pigpio/i2c.rb', line 33

def read_byte_data(i2c_reg)
  IF.i2c_read_byte_data(@pi, @handle, i2c_reg)
end

#read_device(count) ⇒ Object



65
66
67
# File 'lib/pigpio/i2c.rb', line 65

def read_device(count)
  IF.i2c_read_device(@pi, @handle, count)
end

#read_i2c_block_data(i2c_reg, count) ⇒ Object



49
50
51
# File 'lib/pigpio/i2c.rb', line 49

def read_i2c_block_data(i2c_reg, count)
  IF.i2c_read_i2c_block_data(@pi, @handle, i2c_reg, count)
end

#read_word_data(i2c_reg) ⇒ Object



37
38
39
# File 'lib/pigpio/i2c.rb', line 37

def read_word_data(i2c_reg)
  IF.i2c_read_word_data(@pi, @handle, i2c_reg)
end

#write_block_data(i2c_reg, buf) ⇒ Object



53
54
55
# File 'lib/pigpio/i2c.rb', line 53

def write_block_data(i2c_reg, buf)
  IF.i2c_write_block_data(@pi, @handle, i2c_reg, buf)
end

#write_byte(bVal) ⇒ Object



17
18
19
# File 'lib/pigpio/i2c.rb', line 17

def write_byte(bVal)
  IF.i2c_write_byte(@pi, @handle, bVal)
end

#write_byte_data(i2c_reg, bVal) ⇒ Object



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

def write_byte_data(i2c_reg, bVal)
  IF.i2c_write_byte_data(@pi, @handle, i2c_reg, bVal)
end

#write_device(buf) ⇒ Object



69
70
71
# File 'lib/pigpio/i2c.rb', line 69

def write_device(buf)
  IF.i2c_write_device(@pi, @handle, buf)
end

#write_i2c_block_data(i2c_reg, buf) ⇒ Object



57
58
59
# File 'lib/pigpio/i2c.rb', line 57

def write_i2c_block_data(i2c_reg, buf)
  IF.i2c_write_i2c_block_data(@pi, @handle, i2c_reg, buf)
end

#write_quick(bit) ⇒ Object



13
14
15
# File 'lib/pigpio/i2c.rb', line 13

def write_quick(bit)
  IF.i2c_write_quick(@pi, @handle, bit)
end

#write_word_data(i2c_reg, wVal) ⇒ Object



29
30
31
# File 'lib/pigpio/i2c.rb', line 29

def write_word_data(i2c_reg, wVal)
  IF.i2c_write_word_data(@pi, @handle, i2c_reg, wVal)
end

#zip(inBuf, outLen) ⇒ Object



73
74
75
# File 'lib/pigpio/i2c.rb', line 73

def zip(inBuf, outLen)
  IF.i2c_zip(@pi, @handle, inBuf, outLen)
end