tinderfridge 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11aec071db2201e67dee0935c5a37ba2f801d2337cf0dc938ea465a9c0435bd3
4
- data.tar.gz: ad2faa18ff3320c9320ded930b47f54c38e9471eba0bb52e2aa23cb48da3d108
3
+ metadata.gz: 2805da1fbb45d1938cde253637d7a66119718191692caf44ceb22f5d684ed58a
4
+ data.tar.gz: 5e3dbb8a81b3a5f59975a0b4ef4f1c5cbaa76e97d1fc6d9034cd14edc0f0371b
5
5
  SHA512:
6
- metadata.gz: 440adf1b54a1787963688f4392fe686e07b898eae1361d3f245526a244f6e677b5a29a7cd84f2f3aa0221ef4300372dcbae18b55200cef2b96d6fa7206a0c7d0
7
- data.tar.gz: 8204e15a1106392bbde997f2e65704b2cfd176c4e18066685f26e8a50a6cd62e3002b10e8fd6224f16540d946c94c66f66e96f6941b90c7255beec4e4c545a60
6
+ metadata.gz: e5d86b78c3c4351b63d9bcbad1032a661d6fdd9b00457a59deaed677d358577781fdc2809ebe7f8a7c762c77638685d601349bb2065930e9f5dad8232ae61a2f
7
+ data.tar.gz: bc3e28b83f1704169827b0a4650e1f5a360714d70e5f153e62e4428f33360821e2514e31a10ff089cdfa4955225656106b26e314b03d6b24cdf91fe7190014a9
@@ -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, Tinkerforge.device_info(self[k])[1]]
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.
@@ -5,7 +5,7 @@ module Tinkerforge
5
5
  private
6
6
 
7
7
  def _view_21x8
8
- "ESP32 Eth #{uid_string.rjust 8}"
8
+ "ESP32Eth #{uid_string.rjust 8}"
9
9
  end
10
10
 
11
11
  end
@@ -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
- <<~ET
22
- Baro #{uid_string.rjust 8}
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
@@ -17,11 +17,8 @@ module Tinkerforge
17
17
  private
18
18
 
19
19
  def _view_21x8
20
- <<~ET
21
- CO2 #{uid_string.rjust 8}
22
-
23
- #{'%5d PPM' % get_co2_concentration}
24
- ET
20
+ "CO2V2 #{uid_string.rjust 8}\n\n\n" +
21
+ ('%d PPM' % get_co2_concentration).center(21)
25
22
  end
26
23
 
27
24
  end
@@ -49,7 +49,7 @@ module Tinkerforge
49
49
  private
50
50
 
51
51
  def _view_21x8
52
- "GPSv2 #{uid_string.rjust 8}\n\n" +
52
+ "GPSV2 #{uid_string.rjust 8}\n\n" +
53
53
  ((c = coordinates) ? (" Lat %10.5f\n Lon %10.5f" % c) : ' no fix')
54
54
  end
55
55
 
@@ -49,7 +49,7 @@ module Tinkerforge
49
49
  private
50
50
 
51
51
  def _view_21x8
52
- "GPSv3 #{uid_string.rjust 8}\n\n" +
52
+ "GPSV3 #{uid_string.rjust 8}\n\n" +
53
53
  ((c = coordinates) ? (" Lat %10.5f\n Lon %10.5f" % c) : ' no fix')
54
54
  end
55
55
 
@@ -106,7 +106,7 @@ module Tinkerforge
106
106
  private
107
107
 
108
108
  def _view_21x8
109
- "LCD #{uid_string.rjust 8}"
109
+ "LCD128x64 #{uid_string.rjust 8}"
110
110
  end
111
111
 
112
112
  end
@@ -86,7 +86,7 @@ module Tinkerforge
86
86
  private
87
87
 
88
88
  def _view_21x8
89
- "OLED #{uid_string.rjust 8}"
89
+ "OLED128x64V2 #{uid_string.rjust 8}"
90
90
  end
91
91
 
92
92
  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 ? '?' : ' '} %3d %4.1f °C %2d %%\n) % [k,v].flatten
34
+ %Q(#{v[2] > 100 ? '!' : ' '}%-8.8s %5.1f°C%3d%%\n) % [k,v].flatten
30
35
  end.join
31
36
  end
32
37
 
@@ -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
- <<~ET
17
- Temp #{uid_string.rjust 8}
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
@@ -3,7 +3,7 @@ require 'tinkerforge/version'
3
3
  module Tinkerforge
4
4
 
5
5
  # Tinderfridge version.
6
- TINDERFRIDGE_VERSION = '0.12.0'
6
+ TINDERFRIDGE_VERSION = '0.13.0'
7
7
 
8
8
  # About Tinkerforge & Tinderfridge.
9
9
  def self.about
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.12.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-07-22 00:00:00.000000000 Z
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