tinderfridge 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tinderfridge/device.rb +44 -3
- data/lib/tinderfridge/device_collection.rb +3 -1
- data/lib/tinderfridge/devices/brick_master/brick_master.json +11 -0
- data/lib/tinderfridge/devices/brick_master/brick_master.rb +11 -0
- data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.json +2 -1
- data/lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.json +2 -1
- data/lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.rb +19 -0
- data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.json +2 -1
- data/lib/tinderfridge/devices/bricklet_compass/bricklet_compass.json +2 -1
- data/lib/tinderfridge/devices/bricklet_gps_v2/bricklet_gps_v2.json +2 -1
- data/lib/tinderfridge/devices/bricklet_gps_v2/bricklet_gps_v2.rb +14 -1
- data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.json +2 -1
- data/lib/tinderfridge/devices/bricklet_multi_touch_v2/bricklet_multi_touch_v2.json +2 -1
- data/lib/tinderfridge/devices/bricklet_remote_switch_v2/bricklet_remote_switch_v2.json +2 -1
- data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb +2 -0
- data/lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.json +2 -1
- data/lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.rb +20 -0
- data/lib/tinderfridge/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a171ddfc01502cca8300d445d498c960b8cfb1304e1b60fddc5d33ad0a68ba
|
4
|
+
data.tar.gz: ebf5e97bd0fe072375c6a548615baff3e42ef77432b96373035571a41897ba8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5a6e8d3f54c3955afbbce8d48c1ded48ea46535dd078cc6118d207bf988634c7e04fbcab178a5b440ea5ff55798287df53f94465a06e0971a5d0282876f532f
|
7
|
+
data.tar.gz: 31d5cbea577e5b98279279193301e2a95062db29d7150149c3035ecb639f4301ce739854927f018fa922a9630bea7217c76dfb0329ccc5e88359b73f7c4fc7fe
|
data/lib/tinderfridge/device.rb
CHANGED
@@ -109,7 +109,13 @@ module Tinkerforge
|
|
109
109
|
[ 'ipcon' , { 'host' => ipcon.host , 'port' => ipcon.port } ],
|
110
110
|
|
111
111
|
respond_to?('get_chip_temperature' ) ? [ 'chip_temperature' , get_chip_temperature ] : nil,
|
112
|
-
|
112
|
+
|
113
|
+
if respond_to?('get_spitfp_error_count') and (method(:get_spitfp_error_count).arity == 0)
|
114
|
+
[ 'spitfp_error_count', get_spitfp_error_count ]
|
115
|
+
else
|
116
|
+
nil
|
117
|
+
end,
|
118
|
+
|
113
119
|
respond_to?('get_status_led_config' ) ? [ 'status_led_config' , get_status_led_config ] : nil,
|
114
120
|
|
115
121
|
].compact.to_h
|
@@ -131,9 +137,30 @@ module Tinkerforge
|
|
131
137
|
|
132
138
|
# Identifies a Tinkerforge device by blinking its status led.
|
133
139
|
#
|
134
|
-
# Supports recent devices. When invoked on older devices, does nothing.
|
140
|
+
# Supports recent devices. When invoked on some older devices, does nothing.
|
135
141
|
def identify(seconds=10)
|
136
|
-
|
142
|
+
case status_led_api_variety
|
143
|
+
when 1
|
144
|
+
seconds = seconds.to_i
|
145
|
+
state = is_status_led_enabled
|
146
|
+
|
147
|
+
(seconds*2).times do |n|
|
148
|
+
if n.even?
|
149
|
+
disable_status_led
|
150
|
+
else
|
151
|
+
enable_status_led
|
152
|
+
end
|
153
|
+
sleep 0.5
|
154
|
+
end
|
155
|
+
|
156
|
+
if state
|
157
|
+
enable_status_led
|
158
|
+
else
|
159
|
+
disable_status_led
|
160
|
+
end
|
161
|
+
|
162
|
+
seconds
|
163
|
+
when 2
|
137
164
|
seconds = seconds.to_i
|
138
165
|
state = get_status_led_config
|
139
166
|
|
@@ -175,6 +202,20 @@ module Tinkerforge
|
|
175
202
|
end
|
176
203
|
end
|
177
204
|
|
205
|
+
def status_led_api_variety
|
206
|
+
@status_led_api_variety ||=
|
207
|
+
if ( respond_to?('get_status_led_config') &&
|
208
|
+
respond_to?('set_status_led_config') )
|
209
|
+
2
|
210
|
+
elsif ( respond_to?('is_status_led_enabled') &&
|
211
|
+
respond_to?('enable_status_led') &&
|
212
|
+
respond_to?('disable_status_led') )
|
213
|
+
1
|
214
|
+
else
|
215
|
+
nil
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
178
219
|
end
|
179
220
|
|
180
221
|
end
|
@@ -5,6 +5,8 @@ module Tinkerforge
|
|
5
5
|
# Returns the temperatures as measured inside the microcontrollers of devices in the collection.
|
6
6
|
#
|
7
7
|
# Nil for devices that do not support the get_chip_temperature method.
|
8
|
+
#
|
9
|
+
# Note: most devices return temperature in °C, but a few return temperature in 1/10 °C.
|
8
10
|
def get_chip_temperature
|
9
11
|
smap 'get_chip_temperature'
|
10
12
|
end
|
@@ -135,7 +137,7 @@ module Tinkerforge
|
|
135
137
|
private
|
136
138
|
|
137
139
|
def smap(m)
|
138
|
-
map { |k,d| [ k, d.respond_to?(m) ? d.send(m) : nil ] }.to_h
|
140
|
+
map { |k,d| [ k, ( d.respond_to?(m) and (d.method(m).arity == 0) ) ? d.send(m) : nil ] }.to_h
|
139
141
|
end
|
140
142
|
|
141
143
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletCO2V2
|
4
|
+
|
5
|
+
# Returns the device's state.
|
6
|
+
def state
|
7
|
+
av = get_all_values
|
8
|
+
super.merge(
|
9
|
+
'co2_concentration' => av[0],
|
10
|
+
'temperature' => av[1],
|
11
|
+
'temperature_offset' => get_temperature_offset,
|
12
|
+
'humidity' => av[2],
|
13
|
+
'air_pressure' => get_air_pressure,
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -2,11 +2,24 @@ module Tinkerforge
|
|
2
2
|
|
3
3
|
class BrickletGPSV2
|
4
4
|
|
5
|
+
# Returns the device's state.
|
6
|
+
def state
|
7
|
+
super.merge(
|
8
|
+
'fix_led_config' => get_fix_led_config,
|
9
|
+
'fix' => fix?,
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns true if a fix is available.
|
14
|
+
def fix?
|
15
|
+
get_status[0]
|
16
|
+
end
|
17
|
+
|
5
18
|
# Returns latitude and longitude as reported by the GPS Bricklet.
|
6
19
|
#
|
7
20
|
# Nil when there is no fix (position not determined).
|
8
21
|
def coordinates
|
9
|
-
if
|
22
|
+
if fix?
|
10
23
|
c = get_coordinates
|
11
24
|
[
|
12
25
|
c[0] / (c[1] == 'N' ? 1000000.0 : -1000000.0),
|
@@ -6,5 +6,6 @@
|
|
6
6
|
],
|
7
7
|
"weight": 6,
|
8
8
|
"documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Motion_Detector_V2.html",
|
9
|
-
"versions_identifier": "bricklets:motion_detector_v2"
|
9
|
+
"versions_identifier": "bricklets:motion_detector_v2",
|
10
|
+
"released": "2018-02-26"
|
10
11
|
}
|
data/lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.json
CHANGED
@@ -6,5 +6,6 @@
|
|
6
6
|
],
|
7
7
|
"weight": 2.6,
|
8
8
|
"documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Sound_Pressure_Level.html",
|
9
|
-
"versions_identifier": "bricklets:sound_pressure_level"
|
9
|
+
"versions_identifier": "bricklets:sound_pressure_level",
|
10
|
+
"released": "2018-06-07"
|
10
11
|
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletSoundPressureLevel
|
4
|
+
|
5
|
+
WEIGHTINGS = [ 'dB(A)', 'dB(B)','dB(C)', 'dB(D)', 'dB(Z)', 'ITU-R 468']
|
6
|
+
|
7
|
+
# Returns the device's state.
|
8
|
+
def state
|
9
|
+
super.merge(
|
10
|
+
'configuration' => conf = get_configuration,
|
11
|
+
'weighting' => WEIGHTINGS[ conf[1] ],
|
12
|
+
'sampling_rate' => 2 ** (3 - conf[0]) * 10,
|
13
|
+
'bin_size' => 2 ** (3 - conf[0]) * 40,
|
14
|
+
'sound_pressure' => get_decibel,
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/tinderfridge/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinderfridge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lllist.eu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tinkerforge
|
@@ -45,6 +45,8 @@ files:
|
|
45
45
|
- lib/tinderfridge/devices/brick_hat/brick_hat.rb
|
46
46
|
- lib/tinderfridge/devices/brick_hat_zero/brick_hat_zero.json
|
47
47
|
- lib/tinderfridge/devices/brick_hat_zero/brick_hat_zero.rb
|
48
|
+
- lib/tinderfridge/devices/brick_master/brick_master.json
|
49
|
+
- lib/tinderfridge/devices/brick_master/brick_master.rb
|
48
50
|
- lib/tinderfridge/devices/bricklet_accelerometer_v2/bricklet_accelerometer_v2.json
|
49
51
|
- lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.json
|
50
52
|
- lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.rb
|
@@ -55,6 +57,7 @@ files:
|
|
55
57
|
- lib/tinderfridge/devices/bricklet_barometer_v2/bricklet_barometer_v2.json
|
56
58
|
- lib/tinderfridge/devices/bricklet_can_v2/bricklet_can_v2.json
|
57
59
|
- lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.json
|
60
|
+
- lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.rb
|
58
61
|
- lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.json
|
59
62
|
- lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.rb
|
60
63
|
- lib/tinderfridge/devices/bricklet_compass/bricklet_compass.json
|
@@ -129,6 +132,7 @@ files:
|
|
129
132
|
- lib/tinderfridge/devices/bricklet_silent_stepper_v2/bricklet_silent_stepper_v2.json
|
130
133
|
- lib/tinderfridge/devices/bricklet_solid_state_relay_v2/bricklet_solid_state_relay_v2.json
|
131
134
|
- lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.json
|
135
|
+
- lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.rb
|
132
136
|
- lib/tinderfridge/devices/bricklet_temperature_ir_v2/bricklet_temperature_ir_v2.json
|
133
137
|
- lib/tinderfridge/devices/bricklet_temperature_v2/bricklet_temperature_v2.json
|
134
138
|
- lib/tinderfridge/devices/bricklet_thermal_imaging/bricklet_thermal_imaging.json
|
@@ -162,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
166
|
- !ruby/object:Gem::Version
|
163
167
|
version: '0'
|
164
168
|
requirements: []
|
165
|
-
rubygems_version: 3.
|
169
|
+
rubygems_version: 3.2.32
|
166
170
|
signing_key:
|
167
171
|
specification_version: 4
|
168
172
|
summary: Extending Tinkerforge in fun and useful ways.
|