i2c-devices 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/i2c.rb +1 -1
- data/lib/i2c/device/bmp180.rb +207 -0
- data/lib/i2c/device/d6t-44l.rb +52 -0
- data/lib/i2c/driver/i2c-dev.rb +9 -4
- data/spec/device/adt7410_spec.rb +1 -1
- data/spec/device/bmp180_spec.rb +90 -0
- data/spec/device/hd44780_spec.rb +1 -1
- data/spec/driver/gpio_spec.rb +1 -1
- data/spec/i2cdevice_spec.rb +1 -1
- metadata +14 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abd7319b1639effcf37ef2584d1dd5fcc846878d
|
4
|
+
data.tar.gz: 9ac7dbc2ce4960681f32bfc80af3024754d90977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3e71d8dbb775c36e9d4339a3ece41363b555df1e6bec0e2bf3f21e53b606f907620fc4a0531a40cd43ddbb70a5ab084a31c57b20895f13b54adc7c485bcd95
|
7
|
+
data.tar.gz: 80d576eff61fc748facb7708df9731f152f38bcdcdc5d6f8a83fe05ebe55b11ca972d6aac6cdf469705c1e671d73dc1095be423fc1c40f6809db4b4d4d1967c8
|
data/README.md
CHANGED
data/lib/i2c.rb
CHANGED
@@ -0,0 +1,207 @@
|
|
1
|
+
require 'i2c'
|
2
|
+
|
3
|
+
# Implements the I2C-Device BMP085/BMP180
|
4
|
+
# This code was inspired by https://github.com/adafruit/Adafruit_Python_BMP
|
5
|
+
#
|
6
|
+
# Datasheet: https://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf
|
7
|
+
#
|
8
|
+
# Currently this code was tested on a Banana Pi with a BMP185 device. It should work on a Raspberry or any other Linux with I2C-Dev
|
9
|
+
#
|
10
|
+
# ==Example
|
11
|
+
# Using i2c-2 device (e.g. if you using a banana pi)
|
12
|
+
#
|
13
|
+
# bmp = I2CDevice::Bmp180.new(driver: I2CDevice::Driver::I2CDev.new("/dev/i2c-2"), mode: 0)
|
14
|
+
# puts "#{bmp.read_temperature / 10.0}°C"
|
15
|
+
# sleep 1
|
16
|
+
# puts "#{bmp.read_pressure / 100.0}hPa abs"
|
17
|
+
# sleep 1
|
18
|
+
# m_above_sealevel = 500 # position realtive to sealevel in m
|
19
|
+
# puts "#{bmp.read_sealevel_pressure(m_above_sealevel) / 100.0}hPa rel"
|
20
|
+
#
|
21
|
+
class I2CDevice::Bmp180 < I2CDevice
|
22
|
+
# BMP085 default address.
|
23
|
+
BMP085_I2CADDR = 0x77
|
24
|
+
|
25
|
+
# Operating Modes
|
26
|
+
BMP085_ULTRALOWPOWER = 0
|
27
|
+
BMP085_STANDARD = 1
|
28
|
+
BMP085_HIGHRES = 2
|
29
|
+
BMP085_ULTRAHIGHRES = 3
|
30
|
+
|
31
|
+
# BMP085 Registers
|
32
|
+
BMP085_CAL_AC1 = 0xAA # R Calibration data (16 bits)
|
33
|
+
BMP085_CAL_AC2 = 0xAC # R Calibration data (16 bits)
|
34
|
+
BMP085_CAL_AC3 = 0xAE # R Calibration data (16 bits)
|
35
|
+
BMP085_CAL_AC4 = 0xB0 # R Calibration data (16 bits) unsigned
|
36
|
+
BMP085_CAL_AC5 = 0xB2 # R Calibration data (16 bits) unsigned
|
37
|
+
BMP085_CAL_AC6 = 0xB4 # R Calibration data (16 bits) unsigned
|
38
|
+
BMP085_CAL_B1 = 0xB6 # R Calibration data (16 bits)
|
39
|
+
BMP085_CAL_B2 = 0xB8 # R Calibration data (16 bits)
|
40
|
+
BMP085_CAL_MB = 0xBA # R Calibration data (16 bits)
|
41
|
+
BMP085_CAL_MC = 0xBC # R Calibration data (16 bits)
|
42
|
+
BMP085_CAL_MD = 0xBE # R Calibration data (16 bits)
|
43
|
+
BMP085_CONTROL = 0xF4
|
44
|
+
BMP085_TEMPDATA = 0xF6
|
45
|
+
BMP085_PRESSUREDATA = 0xF6
|
46
|
+
|
47
|
+
# Commands
|
48
|
+
BMP085_READTEMPCMD = 0x2E
|
49
|
+
BMP085_READPRESSURECMD = 0x34
|
50
|
+
|
51
|
+
# initialize the device and read the calibration registers
|
52
|
+
#
|
53
|
+
# ==params
|
54
|
+
# * args : hash defaults to {}
|
55
|
+
# ** :mode : one of BMP085_ULTRALOWPOWER | BMP085_STANDARD | BMP085_HIGHRES | BMP085_ULTRAHIGHRES defaults to BMP085_STANDARD see datasheet for more information
|
56
|
+
# ** :address : device address defaults to 0x77
|
57
|
+
def initialize(args={})
|
58
|
+
@mode = args.delete(:mode) || BMP085_STANDARD
|
59
|
+
args = {
|
60
|
+
address: BMP085_I2CADDR
|
61
|
+
}.merge(args)
|
62
|
+
|
63
|
+
super args
|
64
|
+
|
65
|
+
raise "Mode must be between #{BMP085_ULTRALOWPOWER} and #{BMP085_ULTRAHIGHRES}" unless [BMP085_ULTRALOWPOWER, BMP085_STANDARD, BMP085_HIGHRES, BMP085_ULTRAHIGHRES].include?(@mode)
|
66
|
+
|
67
|
+
calibration
|
68
|
+
end
|
69
|
+
|
70
|
+
# read the current real temperature in 0.1°C
|
71
|
+
def read_temperature
|
72
|
+
return calc_real_temperature(read_raw_temperature)
|
73
|
+
end
|
74
|
+
|
75
|
+
# read the current relative pressure in Pa
|
76
|
+
def read_pressure
|
77
|
+
return calc_real_pressure(read_raw_temperature, read_raw_pressure)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Read current temperature and realtive pressure
|
81
|
+
#
|
82
|
+
# ==return
|
83
|
+
# * temperature in 0.1°C, pressure in Pa
|
84
|
+
def read_temperature_and_pressure
|
85
|
+
ut = read_raw_temperature
|
86
|
+
up = read_raw_pressure
|
87
|
+
|
88
|
+
return calc_real_temperature(ut), calc_real_pressure(ut, up)
|
89
|
+
end
|
90
|
+
|
91
|
+
# calculate the current pressure at sealevel from the current relative pressure and the gitven altitude
|
92
|
+
#
|
93
|
+
# ==params
|
94
|
+
# * altitude : curren altitude above sealevel in m defaults to 0
|
95
|
+
def read_sealevel_pressure(altitude = 0.0)
|
96
|
+
pressure = read_pressure()
|
97
|
+
return cacl_sealevel_pressure(pressure, altitude)
|
98
|
+
end
|
99
|
+
|
100
|
+
# calculate the current pressure at sealevel from the given relative pressure and the gitven altitude
|
101
|
+
#
|
102
|
+
# ==params
|
103
|
+
# * altitude : curren altitude above sealevel in m
|
104
|
+
# * pressure : current relative pressure in Pa
|
105
|
+
def cacl_sealevel_pressure(pressure, altitude)
|
106
|
+
return pressure.to_f / ((1.0 - altitude.to_f / 44330.0) ** 5.255)
|
107
|
+
end
|
108
|
+
|
109
|
+
# get the calibration values
|
110
|
+
#
|
111
|
+
# ==return
|
112
|
+
# array of calibration data
|
113
|
+
def get_cal
|
114
|
+
return @cal_AC1, @cal_AC2, @cal_AC3, @cal_AC4, @cal_AC5, @cal_AC6, @cal_B1, @cal_B2, @cal_MB, @cal_MC, @cal_MD
|
115
|
+
end
|
116
|
+
|
117
|
+
private
|
118
|
+
# read the current raw temperature value
|
119
|
+
def read_raw_temperature
|
120
|
+
i2cset(BMP085_CONTROL, BMP085_READTEMPCMD)
|
121
|
+
sleep 0.005
|
122
|
+
return i2cget(BMP085_TEMPDATA, 2).unpack('s>')[0]
|
123
|
+
end
|
124
|
+
|
125
|
+
# read the current raw pressure value
|
126
|
+
def read_raw_pressure
|
127
|
+
i2cset(BMP085_CONTROL, BMP085_READPRESSURECMD + (@mode << 6))
|
128
|
+
|
129
|
+
if @mode == BMP085_ULTRALOWPOWER
|
130
|
+
sleep 0.005
|
131
|
+
elsif @mode == BMP085_HIGHRES
|
132
|
+
sleep 0.014
|
133
|
+
elsif @mode == BMP085_ULTRAHIGHRES
|
134
|
+
sleep 0.026
|
135
|
+
else
|
136
|
+
sleep 0.008
|
137
|
+
end
|
138
|
+
|
139
|
+
sleep 1 # safety for testing
|
140
|
+
|
141
|
+
msb, lsb, xlsb = i2cget(BMP085_PRESSUREDATA, 3).unpack('C*')
|
142
|
+
up = ((msb << 16) + (lsb << 8) + xlsb) >> (8 - @mode)
|
143
|
+
|
144
|
+
return up
|
145
|
+
end
|
146
|
+
|
147
|
+
# load the calibration registers into instance variables
|
148
|
+
def calibration
|
149
|
+
@cal_AC1, @cal_AC2, @cal_AC3, @cal_AC4, @cal_AC5, @cal_AC6, @cal_B1, @cal_B2,
|
150
|
+
@cal_MB, @cal_MC, @cal_MD = i2cget(BMP085_CAL_AC1, 22).unpack('s>s>s>S>S>S>s>s>s>s>s>')
|
151
|
+
end
|
152
|
+
|
153
|
+
# calculate the read temperature using the calibration registers
|
154
|
+
#
|
155
|
+
# ==params
|
156
|
+
# * ut : raw templerature value
|
157
|
+
# ==return
|
158
|
+
# true temperature in 0.1°C -> 150 = 15.0 °C
|
159
|
+
def calc_real_temperature(ut)
|
160
|
+
x1 = ((ut - @cal_AC6) * @cal_AC5) / 2**15
|
161
|
+
x2 = (@cal_MC * 2**11) / (x1 + @cal_MD)
|
162
|
+
b5 = x1 + x2
|
163
|
+
t = (b5 + 8) / 2**4
|
164
|
+
|
165
|
+
return t
|
166
|
+
end
|
167
|
+
|
168
|
+
# calculate the read pressure using the calibration registers
|
169
|
+
#
|
170
|
+
# ==params
|
171
|
+
# * up : raw pressure value
|
172
|
+
# ==return
|
173
|
+
# true pressure in Pa
|
174
|
+
def calc_real_pressure(ut, up)
|
175
|
+
x1 = ((ut - @cal_AC6) * @cal_AC5) / 2**15
|
176
|
+
x2 = (@cal_MC * 2**11) / (x1 + @cal_MD)
|
177
|
+
b5 = x1 + x2
|
178
|
+
|
179
|
+
# Pressure Calculations
|
180
|
+
b6 = b5 - 4000
|
181
|
+
x1 = (@cal_B2 * (b6 * b6) / 2**12) / 2**11
|
182
|
+
x2 = (@cal_AC2 * b6) / 2**11
|
183
|
+
x3 = x1 + x2
|
184
|
+
b3 = (((@cal_AC1 * 4 + x3) << @mode) + 2) / 4
|
185
|
+
|
186
|
+
x1 = (@cal_AC3 * b6) / 2**13
|
187
|
+
x2 = (@cal_B1 * ((b6 * b6) / 2**12)) / 2**16
|
188
|
+
x3 = ((x1 + x2) + 2) / 2**2
|
189
|
+
b4 = (@cal_AC4 * (x3 + 32768)) / 2**15
|
190
|
+
|
191
|
+
b7 = (up - b3) * (50000 >> @mode)
|
192
|
+
|
193
|
+
if b7 < 0x80000000
|
194
|
+
pr = (b7 * 2) / b4
|
195
|
+
else
|
196
|
+
pr = (b7 / b4) * 2
|
197
|
+
end
|
198
|
+
|
199
|
+
x1 = (pr / 2**8) * (pr / 2**8)
|
200
|
+
x1 = (x1 * 3038) / 2**16
|
201
|
+
x2 = (-7357 * pr) / 2**16
|
202
|
+
pr += ((x1 + x2 + 3791) / 2**4)
|
203
|
+
|
204
|
+
return pr
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
class I2CDevice::D6T44L < I2CDevice
|
5
|
+
class InvalidParityException < Exception; end
|
6
|
+
|
7
|
+
def initialize(args={})
|
8
|
+
args[:address] = 0x0a
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def read_data
|
13
|
+
data = i2cget(0x4c, 35)
|
14
|
+
unless checkPEC(data, false)
|
15
|
+
raise InvalidParityException
|
16
|
+
end
|
17
|
+
|
18
|
+
# PTAT はセンサ内部の参照温度データ
|
19
|
+
ptat, *pixels = data[0..-2].unpack("v*")
|
20
|
+
{
|
21
|
+
:PTAT => ptat,
|
22
|
+
:PIXELS => pixels.each_slice(4).to_a
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def calc_crc(data)
|
28
|
+
8.times do
|
29
|
+
tmp = data
|
30
|
+
data = (data << 1) & 0xff
|
31
|
+
if tmp & 0x80 != 0
|
32
|
+
data ^= 0x07
|
33
|
+
end
|
34
|
+
end
|
35
|
+
data
|
36
|
+
end
|
37
|
+
|
38
|
+
def checkPEC(data, userr=true)
|
39
|
+
crc = 0
|
40
|
+
if userr
|
41
|
+
crc = calc_crc(0x14)
|
42
|
+
crc = calc_crc(0x4c ^ crc)
|
43
|
+
crc = calc_crc(0x15 ^ crc)
|
44
|
+
else
|
45
|
+
crc = calc_crc(0x15)
|
46
|
+
end
|
47
|
+
(data.size - 1).times do |i|
|
48
|
+
crc = calc_crc(data[i].ord ^ crc)
|
49
|
+
end
|
50
|
+
data[data.size-1].ord == crc
|
51
|
+
end
|
52
|
+
end
|
data/lib/i2c/driver/i2c-dev.rb
CHANGED
@@ -18,9 +18,13 @@ class I2CDevice::Driver::I2CDev < I2CDevice::Driver::Base
|
|
18
18
|
|
19
19
|
# This depends on /dev/i2c-* (i2c-dev) feature on Linux. You may load i2c-dev kernel module.
|
20
20
|
# <tt>path</tt> :: [String] Path to /dev/i2c-* file.
|
21
|
-
#
|
21
|
+
# <tt>force</tt> :: [Boolean] Force the driver to read or set values even if the device is in use.
|
22
|
+
# This is dangerous, as it can seriously confuse the kernel driver in question.
|
23
|
+
# It can also cause i2cget and i2cset to writ to the wrong register.
|
24
|
+
# Use at your own risk and only if you know what you're doing.
|
25
|
+
#
|
22
26
|
# If _path_ is not specified, this method use <tt>Dir.glob("/dev/i2c-*").last</tt> for _path_
|
23
|
-
def initialize(path=nil)
|
27
|
+
def initialize(path=nil, force=false)
|
24
28
|
if path.nil?
|
25
29
|
path = Dir.glob("/dev/i2c-*").sort.last
|
26
30
|
end
|
@@ -30,12 +34,13 @@ class I2CDevice::Driver::I2CDev < I2CDevice::Driver::Base
|
|
30
34
|
end
|
31
35
|
|
32
36
|
@path = path
|
37
|
+
@slave_command = force ? I2C_SLAVE_FORCE : I2C_SLAVE
|
33
38
|
end
|
34
39
|
|
35
40
|
# Interface of I2CDevice::Driver
|
36
41
|
def i2cget(address, param, length)
|
37
42
|
i2c = File.open(@path, "r+")
|
38
|
-
i2c.ioctl(
|
43
|
+
i2c.ioctl(@slave_command, address)
|
39
44
|
i2c.syswrite(param.chr) unless param.nil?
|
40
45
|
ret = i2c.sysread(length)
|
41
46
|
i2c.close
|
@@ -47,7 +52,7 @@ class I2CDevice::Driver::I2CDev < I2CDevice::Driver::Base
|
|
47
52
|
# Interface of I2CDevice::Driver
|
48
53
|
def i2cset(address, *data)
|
49
54
|
i2c = File.open(@path, "r+")
|
50
|
-
i2c.ioctl(
|
55
|
+
i2c.ioctl(@slave_command, address)
|
51
56
|
i2c.syswrite(data.pack("C*"))
|
52
57
|
i2c.close
|
53
58
|
rescue Errno::EIO => e
|
data/spec/device/adt7410_spec.rb
CHANGED
@@ -0,0 +1,90 @@
|
|
1
|
+
#!rspec
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift "lib"
|
4
|
+
|
5
|
+
require "tempfile"
|
6
|
+
|
7
|
+
require "i2c/device/bmp180"
|
8
|
+
require "i2c/driver/i2c-dev"
|
9
|
+
require "spec/mocki2cdevice"
|
10
|
+
|
11
|
+
describe I2CDevice::Bmp180 do
|
12
|
+
before do
|
13
|
+
@mock = MockI2CDevice.new
|
14
|
+
allow(File).to receive(:open) do
|
15
|
+
@mock.open
|
16
|
+
end
|
17
|
+
|
18
|
+
(0x00..0xFF).each do |i|
|
19
|
+
@mock.memory[i] =0x00
|
20
|
+
end
|
21
|
+
|
22
|
+
# Write example calibration data from datasheet
|
23
|
+
@mock.memory[0xAA] = 0x01
|
24
|
+
@mock.memory[0xAB] = 0x98
|
25
|
+
@mock.memory[0xAC] = 0xFF
|
26
|
+
@mock.memory[0xAD] = 0xB8
|
27
|
+
@mock.memory[0xAE] = 0xC7
|
28
|
+
@mock.memory[0xAF] = 0xD1
|
29
|
+
@mock.memory[0xB0] = 0x7F
|
30
|
+
@mock.memory[0xB1] = 0xE5
|
31
|
+
@mock.memory[0xB2] = 0x7F
|
32
|
+
@mock.memory[0xB3] = 0xF5
|
33
|
+
@mock.memory[0xB4] = 0x5A
|
34
|
+
@mock.memory[0xB5] = 0x71
|
35
|
+
@mock.memory[0xB6] = 0x18
|
36
|
+
@mock.memory[0xB7] = 0x2E
|
37
|
+
@mock.memory[0xB8] = 0x00
|
38
|
+
@mock.memory[0xB9] = 0x04
|
39
|
+
@mock.memory[0xBA] = 0x80
|
40
|
+
@mock.memory[0xBB] = 0x01
|
41
|
+
@mock.memory[0xBC] = 0xDD
|
42
|
+
@mock.memory[0xBD] = 0XF9
|
43
|
+
@mock.memory[0xBE] = 0x0B
|
44
|
+
@mock.memory[0xBF] = 0x34
|
45
|
+
|
46
|
+
@driver = I2CDevice::Driver::I2CDev.new(@mock.path)
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "do read and calculate temperature" do
|
50
|
+
it "should reand and calculate temperature" do
|
51
|
+
bmp = I2CDevice::Bmp180.new(driver: @driver)
|
52
|
+
expect(bmp.get_cal).to eq([408, -72, -14383, 32741, 32757, 23153, 6190, 4, -32767, -8711, 2868])
|
53
|
+
@mock.memory[0xF6] = 0x6C
|
54
|
+
@mock.memory[0xF7] = 0xFA
|
55
|
+
|
56
|
+
expect(bmp.read_temperature).to eq(150) # Temperature 0.1C -> 15.0C
|
57
|
+
expect(@mock.memory[0XF4]).to eq(0x2E)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "do read and calculate pressure" do
|
62
|
+
it "should reand and calculate pressure" do
|
63
|
+
bmp = I2CDevice::Bmp180.new(driver: @driver)
|
64
|
+
expect(bmp.get_cal).to eq([408, -72, -14383, 32741, 32757, 23153, 6190, 4, -32767, -8711, 2868])
|
65
|
+
@mock.memory[0xF6] = 0x5D
|
66
|
+
@mock.memory[0xF7] = 0x33
|
67
|
+
|
68
|
+
# expect(bmp.read_pressure).to eq(69964) # datasheet test at 15.0C
|
69
|
+
|
70
|
+
# Using 0x5D, 0x33 as temp and pressure -> 63524Pa at -26.8C
|
71
|
+
expect(bmp.read_pressure).to eq(63524) # pressure in Pa
|
72
|
+
expect(@mock.memory[0xF4]).to eq(0x74) # 0x34 + (mode << 6) with mode = 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "do read and calculate relative pressure" do
|
77
|
+
it "should reand and calculate relative pressure" do
|
78
|
+
bmp = I2CDevice::Bmp180.new(driver: @driver)
|
79
|
+
expect(bmp.get_cal).to eq([408, -72, -14383, 32741, 32757, 23153, 6190, 4, -32767, -8711, 2868])
|
80
|
+
@mock.memory[0xF6] = 0x5D
|
81
|
+
@mock.memory[0xF7] = 0x33
|
82
|
+
|
83
|
+
# at sea level
|
84
|
+
expect(bmp.read_sealevel_pressure(0)).to eq(63524) # pressure in Pa
|
85
|
+
# at 500m above sea level
|
86
|
+
expect(bmp.read_sealevel_pressure(500).to_i).to eq(67425) # pressure in Pa
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
data/spec/device/hd44780_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe I2CDevice::HD44780 do
|
|
29
29
|
@temp = Tempfile.new("i2c")
|
30
30
|
file = nil
|
31
31
|
open = File.method(:open)
|
32
|
-
File.
|
32
|
+
allow(File).to receive(:open) do
|
33
33
|
file = open.call(@temp.path, "r+")
|
34
34
|
file.define_singleton_method(:ioctl) {|cmd,arg| ioctl.call(ioctl) }
|
35
35
|
file.define_singleton_method(:syswrite) {|str| syswrite.call(str) }
|
data/spec/driver/gpio_spec.rb
CHANGED
@@ -331,7 +331,7 @@ describe I2CDevice::Driver::GPIO do
|
|
331
331
|
describe "i2c abstract interface:" do
|
332
332
|
it "should initialize with sda, scl properties" do
|
333
333
|
expect { I2CDevice::Driver::GPIO.new() }.to raise_error(/required/)
|
334
|
-
expect { I2CDevice::Driver::GPIO.new(sda: 1) }.to raise_error
|
334
|
+
expect { I2CDevice::Driver::GPIO.new(sda: 1) }.to raise_error(/required/)
|
335
335
|
expect { I2CDevice::Driver::GPIO.new(sda: 1, scl: 2) }.not_to raise_error
|
336
336
|
end
|
337
337
|
|
data/spec/i2cdevice_spec.rb
CHANGED
@@ -27,7 +27,7 @@ describe I2CDevice do
|
|
27
27
|
@temp = Tempfile.new("i2c")
|
28
28
|
file = nil
|
29
29
|
open = File.method(:open)
|
30
|
-
File.
|
30
|
+
allow(File).to receive(:open) do
|
31
31
|
file = open.call(@temp.path, "r+")
|
32
32
|
file.define_singleton_method(:ioctl) {|cmd,arg| ioctl.call(cmd, arg) }
|
33
33
|
file.define_singleton_method(:syswrite) {|str| syswrite.call(str) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i2c-devices
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cho45
|
@@ -14,28 +14,28 @@ dependencies:
|
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: i2c-devices is a drivers for i2c devices
|
@@ -45,7 +45,7 @@ extensions: []
|
|
45
45
|
extra_rdoc_files:
|
46
46
|
- README.md
|
47
47
|
files:
|
48
|
-
-
|
48
|
+
- .gitignore
|
49
49
|
- ChangeLog
|
50
50
|
- README.md
|
51
51
|
- Rakefile
|
@@ -54,6 +54,8 @@ files:
|
|
54
54
|
- lib/i2c/device/acm1602ni.rb
|
55
55
|
- lib/i2c/device/adt7410.rb
|
56
56
|
- lib/i2c/device/aqm0802.rb
|
57
|
+
- lib/i2c/device/bmp180.rb
|
58
|
+
- lib/i2c/device/d6t-44l.rb
|
57
59
|
- lib/i2c/device/hd44780.rb
|
58
60
|
- lib/i2c/device/hdc1000.rb
|
59
61
|
- lib/i2c/device/mpl115a2.rb
|
@@ -61,6 +63,7 @@ files:
|
|
61
63
|
- lib/i2c/driver/gpio.rb
|
62
64
|
- lib/i2c/driver/i2c-dev.rb
|
63
65
|
- spec/device/adt7410_spec.rb
|
66
|
+
- spec/device/bmp180_spec.rb
|
64
67
|
- spec/device/hd44780_spec.rb
|
65
68
|
- spec/driver/gpio_spec.rb
|
66
69
|
- spec/i2cdevice_spec.rb
|
@@ -77,28 +80,29 @@ licenses:
|
|
77
80
|
metadata: {}
|
78
81
|
post_install_message:
|
79
82
|
rdoc_options:
|
80
|
-
-
|
83
|
+
- --main
|
81
84
|
- README.md
|
82
85
|
require_paths:
|
83
86
|
- lib
|
84
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
88
|
requirements:
|
86
|
-
- -
|
89
|
+
- - '>='
|
87
90
|
- !ruby/object:Gem::Version
|
88
91
|
version: '0'
|
89
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
93
|
requirements:
|
91
|
-
- -
|
94
|
+
- - '>='
|
92
95
|
- !ruby/object:Gem::Version
|
93
96
|
version: '0'
|
94
97
|
requirements: []
|
95
98
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.0.14.1
|
97
100
|
signing_key:
|
98
101
|
specification_version: 4
|
99
102
|
summary: i2c device drivers
|
100
103
|
test_files:
|
101
104
|
- spec/device/adt7410_spec.rb
|
105
|
+
- spec/device/bmp180_spec.rb
|
102
106
|
- spec/device/hd44780_spec.rb
|
103
107
|
- spec/driver/gpio_spec.rb
|
104
108
|
- spec/i2cdevice_spec.rb
|