tinderfridge 0.12.0 → 0.13.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.rb +5 -0
- data/lib/tinderfridge/device_collection.rb +18 -1
- data/lib/tinderfridge/devices/brick_esp32_ethernet/brick_esp32_ethernet.rb +1 -1
- data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.rb +9 -0
- data/lib/tinderfridge/devices/bricklet_barometer_v2/bricklet_barometer_v2.rb +2 -5
- data/lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.rb +2 -5
- data/lib/tinderfridge/devices/bricklet_gps_v2/bricklet_gps_v2.rb +1 -1
- data/lib/tinderfridge/devices/bricklet_gps_v3/bricklet_gps_v3.rb +1 -1
- data/lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.rb +1 -1
- data/lib/tinderfridge/devices/bricklet_oled_128x64_v2/bricklet_oled_128x64_v2.rb +1 -1
- data/lib/tinderfridge/devices/bricklet_outdoor_weather/bricklet_outdoor_weather.rb +8 -3
- data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb +31 -0
- data/lib/tinderfridge/devices/bricklet_solid_state_relay_v2/bricklet_solid_state_relay_v2.rb +22 -0
- data/lib/tinderfridge/devices/bricklet_temperature_v2/bricklet_temperature_v2.rb +3 -7
- data/lib/tinderfridge/ip_connection.rb +15 -0
- data/lib/tinderfridge/tinkerforge.rb +13 -0
- data/lib/tinderfridge/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2805da1fbb45d1938cde253637d7a66119718191692caf44ceb22f5d684ed58a
|
4
|
+
data.tar.gz: 5e3dbb8a81b3a5f59975a0b4ef4f1c5cbaa76e97d1fc6d9034cd14edc0f0371b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5d86b78c3c4351b63d9bcbad1032a661d6fdd9b00457a59deaed677d358577781fdc2809ebe7f8a7c762c77638685d601349bb2065930e9f5dad8232ae61a2f
|
7
|
+
data.tar.gz: bc3e28b83f1704169827b0a4650e1f5a360714d70e5f153e62e4428f33360821e2514e31a10ff089cdfa4955225656106b26e314b03d6b24cdf91fe7190014a9
|
data/lib/tinderfridge/device.rb
CHANGED
@@ -122,6 +122,11 @@ module Tinkerforge
|
|
122
122
|
].compact.to_h
|
123
123
|
end
|
124
124
|
|
125
|
+
# Returns configuration data for the device (a mutable Hash).
|
126
|
+
def config
|
127
|
+
@config ||= {}
|
128
|
+
end
|
129
|
+
|
125
130
|
# Opens the online documentation for the device (Mac OS only).
|
126
131
|
#
|
127
132
|
# When the URL for the documentation is not known, does nothing.
|
@@ -61,7 +61,7 @@ module Tinkerforge
|
|
61
61
|
# Prints a list of devices in the collection.
|
62
62
|
def ls
|
63
63
|
keys.sort_by(&:downcase).each do |k|
|
64
|
-
puts "%-8s %.40s" % [k,
|
64
|
+
puts "%-8s %.40s" % [k, self[k].device_display_name]
|
65
65
|
end.size
|
66
66
|
end
|
67
67
|
|
@@ -77,6 +77,11 @@ module Tinkerforge
|
|
77
77
|
smap 'state'
|
78
78
|
end
|
79
79
|
|
80
|
+
# Returns configuration data of devices in the collection.
|
81
|
+
def config
|
82
|
+
smap 'config'
|
83
|
+
end
|
84
|
+
|
80
85
|
# Opens the online documentation for the devices in the collection (Mac OS only).
|
81
86
|
#
|
82
87
|
# When the URL for a device's documentation is not known, does nothing.
|
@@ -86,6 +91,18 @@ module Tinkerforge
|
|
86
91
|
|
87
92
|
alias doc open_documentation
|
88
93
|
|
94
|
+
# On Mac OS, opens a new Brick Viewer for each unique
|
95
|
+
# IP Connection used by devices in the collection.
|
96
|
+
#
|
97
|
+
# Not supported on other platforms.
|
98
|
+
#
|
99
|
+
# Requires Brick Viewer version 2.4.23 or later.
|
100
|
+
def open_brick_viewer
|
101
|
+
ipcons.map { |i| i.open_brick_viewer }
|
102
|
+
end
|
103
|
+
|
104
|
+
alias brickv open_brick_viewer
|
105
|
+
|
89
106
|
# Turns off light sources such as screens and RGB LEDs for devices in the collection.
|
90
107
|
#
|
91
108
|
# Ignores devices that do not support the blackout method.
|
@@ -14,6 +14,15 @@ module Tinkerforge
|
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
17
|
+
private
|
18
|
+
|
19
|
+
def _view_21x8
|
20
|
+
s = state
|
21
|
+
"AmbiLightV3 #{uid_string.rjust 8}\n\n\n" +
|
22
|
+
("%.2f Lux" % [0.01 * s['illuminance_raw']]).center(21) + "\n\n\n\n" +
|
23
|
+
("max %d / %d ms" % [ s['illuminance_range'], s['integration_time'] ]).center(21)
|
24
|
+
end
|
25
|
+
|
17
26
|
end
|
18
27
|
|
19
28
|
end
|
@@ -18,11 +18,8 @@ module Tinkerforge
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def _view_21x8
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#{'%7.2f hPa' % [get_air_pressure*0.001]}
|
25
|
-
ET
|
21
|
+
"BaroV2 #{uid_string.rjust 8}\n\n\n" +
|
22
|
+
('%.2f hPa' % [get_air_pressure*0.001]).center(21)
|
26
23
|
end
|
27
24
|
|
28
25
|
end
|
@@ -11,13 +11,18 @@ module Tinkerforge
|
|
11
11
|
|
12
12
|
# Returns the last measured data for all sensors.
|
13
13
|
#
|
14
|
-
# The result is a Hash, with sensor identifiers as the keys. Values per sensor are:
|
14
|
+
# The result is a Hash, with sensor identifiers (or their mapped values) as the keys. Values per sensor are:
|
15
15
|
# - 0: Temperature (°C)
|
16
16
|
# - 1: Relative humidity (%RH)
|
17
17
|
# - 2: Last change (seconds)
|
18
|
+
#
|
19
|
+
# Sensor identifiers can be mapped to descriptive strings or other values:
|
20
|
+
# @example
|
21
|
+
# my_weather_bricklet.config['sensormap'] = { 202 => 'outdoors' }
|
18
22
|
def sensors
|
23
|
+
sensormap = (config['sensormap'].class == Hash) ? config['sensormap'] : {}
|
19
24
|
get_sensor_identifiers.map do |id|
|
20
|
-
[ id, get_sensor_data(id).each_with_index.map { |v,i| i == 0 ? v/10.0 : v } ]
|
25
|
+
[ (sensormap[id] || id), get_sensor_data(id).each_with_index.map { |v,i| i == 0 ? v/10.0 : v } ]
|
21
26
|
end.to_h
|
22
27
|
end
|
23
28
|
|
@@ -26,7 +31,7 @@ module Tinkerforge
|
|
26
31
|
def _view_21x8
|
27
32
|
"Weather #{uid_string.rjust 8}\n\n" +
|
28
33
|
sensors.first(6).map do |k,v|
|
29
|
-
%Q(#{v[2] > 100 ? '
|
34
|
+
%Q(#{v[2] > 100 ? '!' : ' '}%-8.8s %5.1f°C%3d%%\n) % [k,v].flatten
|
30
35
|
end.join
|
31
36
|
end
|
32
37
|
|
data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb
CHANGED
@@ -112,7 +112,9 @@ module Tinkerforge
|
|
112
112
|
|
113
113
|
'_' => '0001000',
|
114
114
|
'-' => '0000001',
|
115
|
+
'¯' => '1000000',
|
115
116
|
'=' => '0001001',
|
117
|
+
'≡' => '1001001',
|
116
118
|
|
117
119
|
'(' => '1001110',
|
118
120
|
')' => '1111000',
|
@@ -147,6 +149,35 @@ module Tinkerforge
|
|
147
149
|
[value1, value2]
|
148
150
|
end
|
149
151
|
|
152
|
+
# Returns the current thread automatically updating the display.
|
153
|
+
def thread
|
154
|
+
@thread
|
155
|
+
end
|
156
|
+
|
157
|
+
# Stops automatic updating of the display.
|
158
|
+
def stop
|
159
|
+
if thread
|
160
|
+
thread.exit
|
161
|
+
@thread = nil
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# Continuously displays the current time, in 24-hour format.
|
166
|
+
#
|
167
|
+
# Starts a new thread automatically updating the display. Use the stop method to end.
|
168
|
+
#
|
169
|
+
# By default uses local time, or optionally UTC.
|
170
|
+
def clock(utc=false)
|
171
|
+
stop
|
172
|
+
@thread = Thread.new do
|
173
|
+
while true
|
174
|
+
t = utc ? Time.now.getutc : Time.now
|
175
|
+
print t.strftime("%H#{t.sec.even? ? ':' : ''}%M")
|
176
|
+
sleep 0.5
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
150
181
|
end
|
151
182
|
|
152
183
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletSolidStateRelayV2
|
4
|
+
|
5
|
+
# Returns the device's state.
|
6
|
+
def state
|
7
|
+
super.merge(
|
8
|
+
'value' => get_state,
|
9
|
+
'monoflop' => get_monoflop,
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def _view_21x8
|
16
|
+
"SSRelayV2 #{uid_string.rjust 8}\n\n\n" +
|
17
|
+
(get_state ? 'ON' : 'Off').center(21)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -13,13 +13,9 @@ module Tinkerforge
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def _view_21x8
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
#{'%6.2f °C' % [get_temperature*0.01]}
|
20
|
-
|
21
|
-
#{get_heater_configuration == 1 ? 'HEATER' : ''}
|
22
|
-
ET
|
16
|
+
"TempV2 #{uid_string.rjust 8}\n\n\n" +
|
17
|
+
('%.2f °C' % [get_temperature*0.01]).center(21) +
|
18
|
+
(get_heater_configuration == 1 ? "\n\n\n HEATER" : '')
|
23
19
|
end
|
24
20
|
|
25
21
|
end
|
@@ -105,6 +105,21 @@ module Tinkerforge
|
|
105
105
|
list
|
106
106
|
end
|
107
107
|
|
108
|
+
# On Mac OS, opens a new Brick Viewer,
|
109
|
+
# connected to the IP Connection's host and port.
|
110
|
+
#
|
111
|
+
# Not supported on other platforms.
|
112
|
+
#
|
113
|
+
# Requires Brick Viewer version 2.4.23 or later.
|
114
|
+
def open_brick_viewer
|
115
|
+
if RUBY_PLATFORM =~ /darwin/
|
116
|
+
`open -n -a Brickv --args #{host} --port #{port}`
|
117
|
+
"#{host}:#{port}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
alias brickv open_brick_viewer
|
122
|
+
|
108
123
|
private
|
109
124
|
|
110
125
|
# Takes the args supplied by an enumeration callback, and returns a device instance.
|
@@ -30,6 +30,19 @@ module Tinkerforge
|
|
30
30
|
connect('localhost', port).discover(0.25)
|
31
31
|
end
|
32
32
|
|
33
|
+
private
|
34
|
+
|
35
|
+
def _view_21x8
|
36
|
+
"\n" +
|
37
|
+
'Tinkerforge'.center(21) +
|
38
|
+
"\n" +
|
39
|
+
VERSION.center(21) +
|
40
|
+
"\n\n\n\n" +
|
41
|
+
"Tinderfridge #{TINDERFRIDGE_VERSION}".center(21) +
|
42
|
+
"\n" +
|
43
|
+
"Ruby #{RUBY_VERSION}".center(21)
|
44
|
+
end
|
45
|
+
|
33
46
|
end
|
34
47
|
|
35
48
|
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.13.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: 2022-
|
11
|
+
date: 2022-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tinkerforge
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/tinderfridge/devices/bricklet_servo_v2/bricklet_servo_v2.json
|
142
142
|
- lib/tinderfridge/devices/bricklet_silent_stepper_v2/bricklet_silent_stepper_v2.json
|
143
143
|
- lib/tinderfridge/devices/bricklet_solid_state_relay_v2/bricklet_solid_state_relay_v2.json
|
144
|
+
- lib/tinderfridge/devices/bricklet_solid_state_relay_v2/bricklet_solid_state_relay_v2.rb
|
144
145
|
- lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.json
|
145
146
|
- lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.rb
|
146
147
|
- lib/tinderfridge/devices/bricklet_temperature_ir_v2/bricklet_temperature_ir_v2.json
|