tinderfridge 0.16.0 → 0.17.0
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/lib/tinderfridge/device/configuration.rb +35 -7
- data/lib/tinderfridge/device_collection.rb +17 -8
- data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.rb +6 -0
- data/lib/tinderfridge/devices/bricklet_barometer_v2/bricklet_barometer_v2.rb +6 -0
- data/lib/tinderfridge/devices/bricklet_gps_v2/bricklet_gps_v2.rb +3 -52
- data/lib/tinderfridge/devices/bricklet_gps_v3/bricklet_gps_v3.rb +3 -52
- data/lib/tinderfridge/devices/bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.rb +8 -0
- data/lib/tinderfridge/devices/bricklet_led_strip_v2/bricklet_led_strip_v2.rb +22 -0
- data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.rb +8 -0
- data/lib/tinderfridge/devices/bricklet_outdoor_weather/bricklet_outdoor_weather.rb +2 -2
- data/lib/tinderfridge/devices/bricklet_particulate_matter/bricklet_particulate_matter.rb +6 -0
- data/lib/tinderfridge/devices/bricklet_rgb_led_button/bricklet_rgb_led_button.rb +8 -0
- data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb +8 -0
- data/lib/tinderfridge/shared/gps.rb +68 -0
- data/lib/tinderfridge/version.rb +1 -1
- data/lib/tinderfridge.rb +6 -15
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d72a23621805a4527cf80a4e35d0ad49fff4cb362a94fe1e916a36130f5fe844
|
|
4
|
+
data.tar.gz: 8e5422de11c1e78dcedfe354fbd35829bf2f09254c33363040091e83d595cc6c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 576e9b5d51bc93fee968f6a0788dd5bb71c451b0b5e4860f789e1603b1d2ce98cf48e0e8d7825ede45ae4510b3b15c54920f18eb153d21fc1d3424e6f5f1f06a
|
|
7
|
+
data.tar.gz: 908a10df2b8722fad35b5caf3e243c4d202658f2fe9a53575a59b905cb6e61962dcf1a46b8b5a6b0995f9decb7ad7606fff5ab1b7442ad747d46010500a72189
|
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
module Tinkerforge
|
|
2
2
|
class Device
|
|
3
3
|
|
|
4
|
-
# Returns
|
|
5
|
-
def
|
|
6
|
-
@
|
|
4
|
+
# Returns settings for the device (a mutable Hash).
|
|
5
|
+
def settings
|
|
6
|
+
@settings ||= {}
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
alias config settings
|
|
10
|
+
|
|
11
|
+
# Defines settings for the device (a Hash).
|
|
12
|
+
def settings=(settings_hash)
|
|
13
|
+
raise(ArgumentError, 'Invalid settings') unless settings_hash.class == Hash
|
|
14
|
+
@settings = settings_hash
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
alias config= settings=
|
|
18
|
+
|
|
19
|
+
# Configures the device by applying settings.
|
|
20
|
+
def configure
|
|
21
|
+
if settings.any?
|
|
22
|
+
logger_debug "Configuring #{settings.keys.map(&:to_s).join(', ')}"
|
|
23
|
+
case status_led_api_variety
|
|
24
|
+
when 2
|
|
25
|
+
if settings.has_key? 'status_led_config'
|
|
26
|
+
set_status_led_config settings['status_led_config'].to_i
|
|
27
|
+
end
|
|
28
|
+
when 1
|
|
29
|
+
if settings.has_key? 'status_led_enabled'
|
|
30
|
+
if !!settings['status_led_enabled']
|
|
31
|
+
enable_status_led
|
|
32
|
+
else
|
|
33
|
+
disable_status_led
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
if respond_to?(:custom_configure, true)
|
|
38
|
+
custom_configure
|
|
39
|
+
end
|
|
40
|
+
end
|
|
13
41
|
end
|
|
14
42
|
|
|
15
43
|
end
|
|
@@ -79,21 +79,30 @@ module Tinkerforge
|
|
|
79
79
|
smap 'state'
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
# Returns
|
|
83
|
-
def
|
|
84
|
-
smap '
|
|
82
|
+
# Returns settings for the devices in the collection.
|
|
83
|
+
def settings
|
|
84
|
+
smap 'settings'
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
alias config settings
|
|
88
|
+
|
|
89
|
+
# Defines settings for the devices in the collection.
|
|
90
|
+
def settings=(settings_hash)
|
|
91
|
+
raise ArgumentError, 'invalid settings' unless (settings_hash.class == Hash)
|
|
90
92
|
each do |k,v|
|
|
91
|
-
if
|
|
92
|
-
v.
|
|
93
|
+
if settings_hash[k]
|
|
94
|
+
v.settings = settings_hash[k]
|
|
93
95
|
end
|
|
94
96
|
end
|
|
95
97
|
end
|
|
96
98
|
|
|
99
|
+
alias config= settings=
|
|
100
|
+
|
|
101
|
+
# Configures the devices in the collection by applying settings.
|
|
102
|
+
def configure
|
|
103
|
+
smap 'configure'
|
|
104
|
+
end
|
|
105
|
+
|
|
97
106
|
# Opens the online documentation for the devices in the collection (Mac OS only).
|
|
98
107
|
#
|
|
99
108
|
# When the URL for a device's documentation is not known, does nothing.
|
|
@@ -17,6 +17,12 @@ module Tinkerforge
|
|
|
17
17
|
|
|
18
18
|
private
|
|
19
19
|
|
|
20
|
+
def custom_configure
|
|
21
|
+
if settings.has_key? 'sensor_configuration'
|
|
22
|
+
set_sensor_configuration *settings['sensor_configuration']
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
20
26
|
def _view_21x8
|
|
21
27
|
"BaroV2 #{uid_string.rjust 8}\n\n\n" +
|
|
22
28
|
('%.2f hPa' % [get_air_pressure*0.001]).center(21)
|
|
@@ -1,58 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
require 'tinderfridge/shared/gps'
|
|
2
2
|
|
|
3
|
+
module Tinkerforge
|
|
3
4
|
class BrickletGPSV2
|
|
4
5
|
|
|
5
|
-
|
|
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
|
-
|
|
18
|
-
# Returns latitude and longitude as reported by the GPS Bricklet.
|
|
19
|
-
#
|
|
20
|
-
# Nil when there is no fix (position not determined).
|
|
21
|
-
def coordinates
|
|
22
|
-
if fix?
|
|
23
|
-
c = get_coordinates
|
|
24
|
-
[
|
|
25
|
-
c[0] / (c[1] == 'N' ? 1000000.0 : -1000000.0),
|
|
26
|
-
c[2] / (c[3] == 'E' ? 1000000.0 : -1000000.0)
|
|
27
|
-
]
|
|
28
|
-
else
|
|
29
|
-
nil
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Returns a Time object representing the time as reported by the GPS Bricklet.
|
|
34
|
-
def time
|
|
35
|
-
# FIXME: This will not work after 31-Dec-2099.
|
|
36
|
-
dt = get_date_time.map &:to_s
|
|
37
|
-
dt = dt[0].rjust(6,'0').unpack('a2a2a2').reverse + dt[1].rjust(9,'0').concat('000').unpack('a2a2a2a6')
|
|
38
|
-
dt[0].prepend '20'
|
|
39
|
-
Time.gm *dt.map(&:to_i)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Returns a URL for viewing the current coordinates on OpenStreetMap.
|
|
43
|
-
def openstreetmap_marker_url(zoom=12)
|
|
44
|
-
if c = coordinates
|
|
45
|
-
"https://www.openstreetmap.org/?mlat=%f&mlon=%f&zoom=%d" % [c, zoom].flatten
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
def _view_21x8
|
|
52
|
-
"GPSV2 #{uid_string.rjust 8}\n\n" +
|
|
53
|
-
((c = coordinates) ? (" Lat %10.5f\n Lon %10.5f" % c) : ' no fix')
|
|
54
|
-
end
|
|
6
|
+
include Tinkerforge::Shared::GPS
|
|
55
7
|
|
|
56
8
|
end
|
|
57
|
-
|
|
58
9
|
end
|
|
@@ -1,58 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
require 'tinderfridge/shared/gps'
|
|
2
2
|
|
|
3
|
+
module Tinkerforge
|
|
3
4
|
class BrickletGPSV3
|
|
4
5
|
|
|
5
|
-
|
|
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
|
-
|
|
18
|
-
# Returns latitude and longitude as reported by the GPS Bricklet.
|
|
19
|
-
#
|
|
20
|
-
# Nil when there is no fix (position not determined).
|
|
21
|
-
def coordinates
|
|
22
|
-
if fix?
|
|
23
|
-
c = get_coordinates
|
|
24
|
-
[
|
|
25
|
-
c[0] / (c[1] == 'N' ? 1000000.0 : -1000000.0),
|
|
26
|
-
c[2] / (c[3] == 'E' ? 1000000.0 : -1000000.0)
|
|
27
|
-
]
|
|
28
|
-
else
|
|
29
|
-
nil
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Returns a Time object representing the time as reported by the GPS Bricklet.
|
|
34
|
-
def time
|
|
35
|
-
# FIXME: This will not work after 31-Dec-2099.
|
|
36
|
-
dt = get_date_time.map &:to_s
|
|
37
|
-
dt = dt[0].rjust(6,'0').unpack('a2a2a2').reverse + dt[1].rjust(9,'0').concat('000').unpack('a2a2a2a6')
|
|
38
|
-
dt[0].prepend '20'
|
|
39
|
-
Time.gm *dt.map(&:to_i)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Returns a URL for viewing the current coordinates on OpenStreetMap.
|
|
43
|
-
def openstreetmap_marker_url(zoom=12)
|
|
44
|
-
if c = coordinates
|
|
45
|
-
"https://www.openstreetmap.org/?mlat=%f&mlon=%f&zoom=%d" % [c, zoom].flatten
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
def _view_21x8
|
|
52
|
-
"GPSV3 #{uid_string.rjust 8}\n\n" +
|
|
53
|
-
((c = coordinates) ? (" Lat %10.5f\n Lon %10.5f" % c) : ' no fix')
|
|
54
|
-
end
|
|
6
|
+
include Tinkerforge::Shared::GPS
|
|
55
7
|
|
|
56
8
|
end
|
|
57
|
-
|
|
58
9
|
end
|
|
@@ -34,6 +34,28 @@ module Tinkerforge
|
|
|
34
34
|
|
|
35
35
|
private
|
|
36
36
|
|
|
37
|
+
def custom_configure
|
|
38
|
+
if settings.has_key? 'chip_type'
|
|
39
|
+
if settings['chip_type'].to_i != get_chip_type
|
|
40
|
+
set_chip_type settings['chip_type'].to_i
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
if settings.has_key? 'channel_mapping'
|
|
45
|
+
set_channel_mapping settings['channel_mapping'].to_i
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
if settings.has_key? 'frame_duration'
|
|
49
|
+
set_frame_duration settings['frame_duration'].to_i
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
if settings.has_key? 'clock_frequency'
|
|
53
|
+
if settings['clock_frequency'].to_i != get_clock_frequency
|
|
54
|
+
set_clock_frequency settings['clock_frequency'].to_i
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
37
59
|
def lookup_channel_mapping(selector=nil)
|
|
38
60
|
@@channel_mapping_table ||= self.class.constants.map do |c|
|
|
39
61
|
(c.to_s =~ /^CHANNEL_MAPPING_(\w{3,4})$/ ) ? [self.class.const_get(c), $1] : nil
|
|
@@ -18,9 +18,9 @@ module Tinkerforge
|
|
|
18
18
|
#
|
|
19
19
|
# Sensor identifiers can be mapped to descriptive strings or other values:
|
|
20
20
|
# @example
|
|
21
|
-
# my_weather_bricklet.
|
|
21
|
+
# my_weather_bricklet.settings['sensormap'] = { 202 => 'outdoors' }
|
|
22
22
|
def sensors
|
|
23
|
-
sensormap = (
|
|
23
|
+
sensormap = (settings['sensormap'].class == Hash) ? settings['sensormap'] : {}
|
|
24
24
|
get_sensor_identifiers.map do |id|
|
|
25
25
|
[ (sensormap[id] || id), get_sensor_data(id).each_with_index.map { |v,i| i == 0 ? v/10.0 : v } ]
|
|
26
26
|
end.to_h
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
module Tinkerforge
|
|
2
|
+
module Shared
|
|
3
|
+
|
|
4
|
+
# Mixin for GPS Bricklet versions 2 & 3.
|
|
5
|
+
module GPS
|
|
6
|
+
|
|
7
|
+
# Returns the device's state.
|
|
8
|
+
def state
|
|
9
|
+
super.merge(
|
|
10
|
+
'fix_led_config' => get_fix_led_config,
|
|
11
|
+
'fix' => fix?,
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Returns true if a fix is available.
|
|
16
|
+
def fix?
|
|
17
|
+
get_status[0]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Returns latitude and longitude as reported by the GPS Bricklet.
|
|
21
|
+
#
|
|
22
|
+
# Nil when there is no fix (position not determined).
|
|
23
|
+
def coordinates
|
|
24
|
+
if fix?
|
|
25
|
+
c = get_coordinates
|
|
26
|
+
[
|
|
27
|
+
c[0] / (c[1] == 'N' ? 1000000.0 : -1000000.0),
|
|
28
|
+
c[2] / (c[3] == 'E' ? 1000000.0 : -1000000.0)
|
|
29
|
+
]
|
|
30
|
+
else
|
|
31
|
+
nil
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Returns a Time object representing the time as reported by the GPS Bricklet.
|
|
36
|
+
def time
|
|
37
|
+
# FIXME: This will not work after 31-Dec-2099.
|
|
38
|
+
dt = get_date_time.map &:to_s
|
|
39
|
+
dt = dt[0].rjust(6,'0').unpack('a2a2a2').reverse + dt[1].rjust(9,'0').concat('000').unpack('a2a2a2a6')
|
|
40
|
+
dt[0].prepend '20'
|
|
41
|
+
Time.gm *dt.map(&:to_i)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Returns a URL for viewing the current coordinates on OpenStreetMap.
|
|
45
|
+
def openstreetmap_marker_url(zoom=12)
|
|
46
|
+
if c = coordinates
|
|
47
|
+
"https://www.openstreetmap.org/?mlat=%f&mlon=%f&zoom=%d" % [c, zoom].flatten
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def custom_configure
|
|
54
|
+
if settings.has_key? 'fix_led_config'
|
|
55
|
+
set_fix_led_config settings['fix_led_config'].to_i
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def _view_21x8
|
|
60
|
+
@label21x8 ||= self.class.to_s[-5,5]
|
|
61
|
+
"#{@label21x8} #{uid_string.rjust 8}\n\n" +
|
|
62
|
+
((c = coordinates) ? (" Lat %10.5f\n Lon %10.5f" % c) : ' no fix')
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
68
|
+
end
|
data/lib/tinderfridge/version.rb
CHANGED
data/lib/tinderfridge.rb
CHANGED
|
@@ -2,18 +2,9 @@ if defined? Tinkerforge
|
|
|
2
2
|
raise 'Tinkerforge was already loaded, so Tinderfridge can not reliably extend it!'
|
|
3
3
|
end
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
device
|
|
12
|
-
|
|
13
|
-
tinkerforge
|
|
14
|
-
|
|
15
|
-
device_info
|
|
16
|
-
|
|
17
|
-
device_collection
|
|
18
|
-
|
|
19
|
-
).each { |m| require "tinderfridge/#{m}" }
|
|
5
|
+
require 'tinderfridge/version'
|
|
6
|
+
require 'tinderfridge/ip_connection'
|
|
7
|
+
require 'tinderfridge/device'
|
|
8
|
+
require 'tinderfridge/tinkerforge'
|
|
9
|
+
require 'tinderfridge/device_info'
|
|
10
|
+
require 'tinderfridge/device_collection'
|
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.17.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: 2026-01-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: tinkerforge
|
|
@@ -159,15 +159,16 @@ files:
|
|
|
159
159
|
- lib/tinderfridge/devices/bricklet_xmc1400_breakout/bricklet_xmc1400_breakout.json
|
|
160
160
|
- lib/tinderfridge/ip_connection.rb
|
|
161
161
|
- lib/tinderfridge/shared/display_ibm437_encoding.rb
|
|
162
|
+
- lib/tinderfridge/shared/gps.rb
|
|
162
163
|
- lib/tinderfridge/shared/logger.rb
|
|
163
164
|
- lib/tinderfridge/tinkerforge.rb
|
|
164
165
|
- lib/tinderfridge/version.rb
|
|
165
|
-
homepage: https://
|
|
166
|
+
homepage: https://codeberg.org/lllisteu/tinderfridge
|
|
166
167
|
licenses:
|
|
167
168
|
- CC0-1.0
|
|
168
169
|
metadata:
|
|
169
|
-
homepage_uri: https://
|
|
170
|
-
changelog_uri: https://
|
|
170
|
+
homepage_uri: https://codeberg.org/lllisteu/tinderfridge
|
|
171
|
+
changelog_uri: https://codeberg.org/lllisteu/tinderfridge/src/branch/master/History.md
|
|
171
172
|
documentation_uri: https://www.rubydoc.info/gems/tinderfridge
|
|
172
173
|
post_install_message:
|
|
173
174
|
rdoc_options: []
|