tinderfridge 0.4.0 → 0.5.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: 7f7d7c9860d6aa8495eef63beeca7be8d7122205b562c49d560d513bdd780c7f
4
- data.tar.gz: efc7ec85867758066b96df1ceccf63ff5b32eee7f0a29b7060560a2236cfe365
3
+ metadata.gz: d7b851b2ea04d7ab8385d6ca4f11cece38721b4cb09dd7afbd449e84d9e4e2a7
4
+ data.tar.gz: 19e264699bc41886fe56fa954339d04b118994d39990cb0e834d7a8b5fb1f0e2
5
5
  SHA512:
6
- metadata.gz: 8de0db5c9d6dc68b3f2fd18b434191e7b23c7bdff389b71918308846637e23fdc80b4880c3ee15b0f83b97e358a6751364c73795a1071bfe2e3ed0a99aeecf74
7
- data.tar.gz: 640bee0f79ea37182229abed010480cedbd079de16a3920623c5a6ee4cfca393482bb82d64924485a9b7b651afc194394c40bf76a787fbea8bf21e119b491f3d
6
+ metadata.gz: 7694f3b62443011a1658034d015a50485f491cee038ce87f820b58e35bf017ce857a21a25a8aae33b92602164100e04a50fc5094679da1164a0592a845852b5b
7
+ data.tar.gz: fd7b21aac321ae3b25be1857da5e6c91cbc26d7f3bc839fd5934774de35dd9730a5bdfa13ed103f8d4d3bfb4f533d87a325f01f20ec6db30991a24511a0f6e7d
@@ -66,6 +66,16 @@ module Tinkerforge
66
66
  # Returns the device's IPConnection object.
67
67
  attr_reader :ipcon
68
68
 
69
+ # Returns device information.
70
+ #
71
+ # Device information is an array:
72
+ # - 0 : Device Identifier
73
+ # - 1 : Device Display Name
74
+ # - 2 : Associated class name and source file
75
+ def device_info
76
+ Tinkerforge.device_info device_identifier
77
+ end
78
+
69
79
  # Returns a programmer-friendly representation of the device.
70
80
  def inspect
71
81
  "%s (%s@%s:%s)" % [self.class, @uid_string, ipcon.host, ipcon.port]
@@ -80,6 +80,42 @@ module Tinkerforge
80
80
  smap('ipcon').values.compact.uniq
81
81
  end
82
82
 
83
+ # Returns an array of devices in the collection matching the selector.
84
+ #
85
+ # Selector argument can be:
86
+ # - Device Identifier
87
+ # - Class name or Device Display Name (Regexp)
88
+ # Selection by regular expression is case-insensitive by default.
89
+ #
90
+ # @example Select by class name and Device Display Name
91
+ # # All 'analog' devices
92
+ # tf = Tinkerforge.connect.discover(1)
93
+ # tf.find_all /analog/
94
+ def find_all(selector)
95
+ case selector
96
+ when Integer
97
+ values.select { |v| v.device_identifier == selector}
98
+ when Regexp
99
+ r = Regexp.new selector.source, Regexp::IGNORECASE
100
+ values.select { |v| v.class.to_s.split('::').last =~ r || v.device_display_name =~ r }
101
+ end
102
+ end
103
+
104
+ # Returns the first device in the collection matching the selector.
105
+ #
106
+ # Selector argument can be:
107
+ # - Device Identifier
108
+ # - Class name or Device Display Name (Regexp)
109
+ # Selection by regular expression is case-insensitive by default.
110
+ #
111
+ # @example Select by Device Identifier
112
+ # # Remote Switch Bricklet 2.0
113
+ # tf = Tinkerforge.connect('myhost.local').discover(1)
114
+ # tf.find 289
115
+ def find(selector)
116
+ find_all(selector).first
117
+ end
118
+
83
119
  private
84
120
 
85
121
  def smap(m)
@@ -0,0 +1,20 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletAirQuality
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ av = get_all_values
8
+ super.merge(
9
+ 'iaq_index' => av[0],
10
+ 'iaq_index_accuracy' => av[1],
11
+ 'temperature' => av[2],
12
+ 'temperature_offset' => get_temperature_offset,
13
+ 'humidity' => av[3],
14
+ 'air_pressure' => av[4],
15
+ )
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,19 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletAmbientLightV3
4
+
5
+ ILLUMINANCE_RANGES = [ 64000, 32000, 16000, 8000, 1300, 600, 100000 ]
6
+
7
+ # Returns the device's state.
8
+ def state
9
+ super.merge(
10
+ 'configuration' => conf = get_configuration,
11
+ 'illuminance_range' => ILLUMINANCE_RANGES[ conf[0] ],
12
+ 'integration_time' => 50 + conf[1] * 50,
13
+ 'illuminance_raw' => get_illuminance,
14
+ )
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,15 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletJoystickV2
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ super.merge(
8
+ 'position' => get_position,
9
+ 'pressed' => is_pressed,
10
+ )
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,42 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletMotorizedLinearPoti
4
+
5
+ # Returns the position of the potentiometer (an integer in the range 0..100).
6
+ def position
7
+ get_position
8
+ end
9
+
10
+ # Moves the potentiometer to the given position.
11
+ #
12
+ # If the potentiometer was locked before, it will be locked at the new position.
13
+ # The drive mode (speed) will be the same as the last time the position was set.
14
+ def position=(position)
15
+ set_motor_position( position, *get_motor_position[1,2] )
16
+ end
17
+
18
+ alias move_to position=
19
+
20
+ # Locks the position of the potentiometer. If a position is given, moves to that position first.
21
+ def lock(position=nil)
22
+ set_motor_position( position || get_position, get_motor_position[1], true )
23
+ end
24
+
25
+ alias hold lock
26
+
27
+ # Releases the potentiometer, so its position can be changed by hand. If a position is given, moves to that position first.
28
+ def release(position=nil)
29
+ set_motor_position( position || get_position, get_motor_position[1], false )
30
+ end
31
+
32
+ # Returns the device's state.
33
+ def state
34
+ super.merge(
35
+ 'position' => get_position,
36
+ 'motor_position' => get_motor_position,
37
+ )
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,15 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletRemoteSwitchV2
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ super.merge(
8
+ 'remote_configuration' => get_remote_configuration,
9
+ 'repeats' => get_repeats,
10
+ )
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -20,6 +20,15 @@ module Tinkerforge
20
20
  true
21
21
  end
22
22
 
23
+ # Returns the device's state.
24
+ def state
25
+ super.merge(
26
+ 'color_rgb' => get_color,
27
+ 'color_calibration' => get_color_calibration,
28
+ 'pressed' => ( get_button_state == 0 ) ? true : false,
29
+ )
30
+ end
31
+
23
32
  end
24
33
 
25
34
  end
@@ -20,6 +20,13 @@ module Tinkerforge
20
20
  true
21
21
  end
22
22
 
23
+ # Returns the device's state.
24
+ def state
25
+ super.merge(
26
+ 'color_rgb' => get_rgb_value,
27
+ )
28
+ end
29
+
23
30
  end
24
31
 
25
32
  end
@@ -0,0 +1,20 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletRotaryEncoderV2
4
+
5
+ # Returns the current count of the encoder.
6
+ def count
7
+ get_count(false)
8
+ end
9
+
10
+ # Returns the device's state.
11
+ def state
12
+ super.merge(
13
+ 'count' => count,
14
+ 'pressed' => is_pressed,
15
+ )
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -15,6 +15,11 @@ module Tinkerforge
15
15
  "%s (%s:%s)" % [self.class, host, port]
16
16
  end
17
17
 
18
+ # Returns true if connected to localhost, false if connected via the network.
19
+ def localhost?
20
+ @localhost ||= %w(localhost 127.0.0.1 ::1).include? host
21
+ end
22
+
18
23
  # Returns a Tinkerforge::DeviceCollection with devices discovered for this IP Connection. Discovery may take a few moments.
19
24
  #
20
25
  # Accepts an optional argument for the number of seconds to wait, otherwise returns immediately.
@@ -3,7 +3,7 @@ require 'tinkerforge/version'
3
3
  module Tinkerforge
4
4
 
5
5
  # Tinderfridge version.
6
- TINDERFRIDGE_VERSION = '0.4.0'
6
+ TINDERFRIDGE_VERSION = '0.5.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.4.0
4
+ version: 0.5.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: 2021-02-20 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tinkerforge
@@ -43,16 +43,22 @@ files:
43
43
  - lib/tinderfridge/device_info.txt
44
44
  - lib/tinderfridge/devices/brick_hat.rb
45
45
  - lib/tinderfridge/devices/brick_hat_zero.rb
46
+ - lib/tinderfridge/devices/bricklet_air_quality.rb
47
+ - lib/tinderfridge/devices/bricklet_ambient_light_v3.rb
46
48
  - lib/tinderfridge/devices/bricklet_dmx.rb
47
49
  - lib/tinderfridge/devices/bricklet_gps_v2.rb
48
50
  - lib/tinderfridge/devices/bricklet_industrial_dual_relay.rb
51
+ - lib/tinderfridge/devices/bricklet_joystick_v2.rb
49
52
  - lib/tinderfridge/devices/bricklet_lcd_128x64.rb
50
53
  - lib/tinderfridge/devices/bricklet_led_strip_v2.rb
54
+ - lib/tinderfridge/devices/bricklet_motorized_linear_poti.rb
51
55
  - lib/tinderfridge/devices/bricklet_multi_touch_v2.rb
52
56
  - lib/tinderfridge/devices/bricklet_nfc.rb
53
57
  - lib/tinderfridge/devices/bricklet_outdoor_weather.rb
58
+ - lib/tinderfridge/devices/bricklet_remote_switch_v2.rb
54
59
  - lib/tinderfridge/devices/bricklet_rgb_led_button.rb
55
60
  - lib/tinderfridge/devices/bricklet_rgb_led_v2.rb
61
+ - lib/tinderfridge/devices/bricklet_rotary_encoder_v2.rb
56
62
  - lib/tinderfridge/devices/bricklet_segment_display_4x7_v2.rb
57
63
  - lib/tinderfridge/ip_connection.rb
58
64
  - lib/tinderfridge/tinkerforge.rb