tinderfridge 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e18a7294bb3132350b0d3f1062527eaff38f2b9a90a5bc1057ffd59da58d6389
4
- data.tar.gz: cc269b3ff4508d928ccd00af98fa0574d21ab27f970a113d04f39a4ba65ed516
3
+ metadata.gz: 7f7d7c9860d6aa8495eef63beeca7be8d7122205b562c49d560d513bdd780c7f
4
+ data.tar.gz: efc7ec85867758066b96df1ceccf63ff5b32eee7f0a29b7060560a2236cfe365
5
5
  SHA512:
6
- metadata.gz: e235a1c592b8323a591469684c3a21526e5dda8a61eb539bcaf493dff7094e20e87b67168b90032b610925fdfbc724ac44b649d0c5a531510e275a2b48e288b9
7
- data.tar.gz: abedb8f8ed9b7be27bbb263f3225cb0097b0a2e711e4d71122fda6210f20010cece9b1e034ec715bddc5a0778f34d364b1dcfaf7742cd9abd3c6d18f7236f48a
6
+ metadata.gz: 8de0db5c9d6dc68b3f2fd18b434191e7b23c7bdff389b71918308846637e23fdc80b4880c3ee15b0f83b97e358a6751364c73795a1071bfe2e3ed0a99aeecf74
7
+ data.tar.gz: 640bee0f79ea37182229abed010480cedbd079de16a3920623c5a6ee4cfca393482bb82d64924485a9b7b651afc194394c40bf76a787fbea8bf21e119b491f3d
@@ -0,0 +1,18 @@
1
+ module Tinkerforge
2
+
3
+ class BrickHAT
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ volts = get_voltages
8
+ super.merge(
9
+ 'bricklet_power' => get_bricklet_power,
10
+ 'usb_voltage' => volts[0],
11
+ 'dc_voltage' => volts[1],
12
+ 'sleep_mode' => get_sleep_mode,
13
+ )
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,14 @@
1
+ module Tinkerforge
2
+
3
+ class BrickHATZero
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ super.merge(
8
+ 'usb_voltage' => get_usb_voltage,
9
+ )
10
+ end
11
+
12
+ end
13
+
14
+ end
@@ -0,0 +1,18 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletDMX
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ super.merge(
8
+ 'dmx_mode' => get_dmx_mode,
9
+ 'frame_duration' => get_frame_duration,
10
+ 'frame_error_count' => get_frame_error_count,
11
+ 'communication_led_config' => get_communication_led_config,
12
+ 'error_led_config' => get_error_led_config,
13
+ )
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1,20 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletIndustrialDualRelay
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ super.merge(
8
+ 'relays' => get_value.each_with_index.map do |v,i|
9
+ {
10
+ 'value' => v,
11
+ 'output' => v ? 'A' : 'B',
12
+ 'monoflop' => ['time', 'time_remaining'].zip( get_monoflop(i)[1,2] ).to_h,
13
+ }
14
+ end
15
+ )
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -20,6 +20,18 @@ module Tinkerforge
20
20
  end
21
21
  end
22
22
 
23
+ # Returns the device's state.
24
+ def state
25
+ super.merge(
26
+ 'chip_type' => get_chip_type,
27
+ 'channel_mapping' => get_channel_mapping,
28
+ 'channels' => channels,
29
+ 'frame_duration' => get_frame_duration,
30
+ 'clock_frequency' => get_clock_frequency,
31
+ 'supply_voltage' => get_supply_voltage,
32
+ )
33
+ end
34
+
23
35
  private
24
36
 
25
37
  def lookup_channel_mapping(selector=nil)
@@ -0,0 +1,16 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletMultiTouchV2
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ super.merge(
8
+ 'electrode_config' => get_electrode_config.map { |c| c ? '1' : '0' }.join,
9
+ 'electrode_sensitivity' => get_electrode_sensitivity,
10
+ 'touch_led_config' => get_touch_led_config,
11
+ )
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,16 @@
1
+ module Tinkerforge
2
+
3
+ class BrickletNFC
4
+
5
+ # Returns the device's state.
6
+ def state
7
+ super.merge(
8
+ 'mode' => get_mode,
9
+ 'detection_led_config' => get_detection_led_config,
10
+ 'maximum_timeout' => get_maximum_timeout,
11
+ )
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -15,6 +15,114 @@ module Tinkerforge
15
15
  send_request FUNCTION_GET_SEGMENTS, [], '', 14, '?35'
16
16
  end
17
17
 
18
+ # Sets the state of all 35 segments.
19
+ def segments=(*segments)
20
+ segs = segments.flatten
21
+ set_segments segs[0,8], segs[8,8], segs[16,8], segs[24,8], segs[32,2], segs[34]
22
+ end
23
+
24
+ # Returns the state of all 35 segments as a string of 1s and 0s.
25
+ def segments_string
26
+ segments.map { |s| s ? '1' : '0' }.join
27
+ end
28
+
29
+ # Sets the state of all 35 segments using a string of 1s and 0s.
30
+ #
31
+ # For readability, the string may include spaces and underscores, which will be ignored.
32
+ # @example
33
+ # my_bricklet.segments_string = '10000110 11000110 11000110 00000110 00 0'
34
+ def segments_string=(segments)
35
+ self.segments = segments.gsub(/[ _]/, '').ljust(35, '0').chars.map { |s| s == '1' }
36
+ end
37
+
38
+ # Returns the device's state.
39
+ def state
40
+ super.merge( 'brightness' => get_brightness )
41
+ end
42
+
43
+ # Displays a string.
44
+ def print(text='')
45
+ out = ''
46
+ colon = false
47
+
48
+ text.to_s.chars.each do |c|
49
+ if glyphs.key? c
50
+ out << glyphs[c] << '0'
51
+ elsif c == '.' and out[-1] == '0'
52
+ out[-1] = '1'
53
+ elsif c == ':' and out.size == 16
54
+ colon = true
55
+ else
56
+ raise "Can not display '#{text}'"
57
+ end
58
+ end
59
+
60
+ self.segments_string = out[0,32].ljust(32,'0') + ( colon ? '110' : '000' )
61
+ nil
62
+ end
63
+
64
+ # Returns the definition of glyphs for Unicode chracters.
65
+ def glyphs
66
+ @@glyphs ||= {
67
+
68
+ '0' => '1111110',
69
+ '1' => '0110000',
70
+ '2' => '1101101',
71
+ '3' => '1111001',
72
+ '4' => '0110011',
73
+ '5' => '1011011',
74
+ '6' => '1011111',
75
+ '7' => '1110000',
76
+ '8' => '1111111',
77
+ '9' => '1111011',
78
+
79
+ 'A' => '1110111',
80
+ 'b' => '0011111',
81
+ 'c' => '0001101',
82
+ 'C' => '1001110',
83
+ 'd' => '0111101',
84
+ 'E' => '1001111',
85
+ 'F' => '1000111',
86
+ 'G' => '1011110',
87
+ 'H' => '0110111',
88
+ 'h' => '0010111',
89
+ 'I' => '0110000',
90
+ 'i' => '0010000',
91
+ 'J' => '0111000',
92
+ 'L' => '0001110',
93
+ 'l' => '0001100',
94
+ 'n' => '0010101',
95
+ 'O' => '1111110',
96
+ 'o' => '0011101',
97
+ 'P' => '1100111',
98
+ 'q' => '1110011',
99
+ 'r' => '0000101',
100
+ 'S' => '1011011',
101
+ 't' => '0001111',
102
+ 'U' => '0111110',
103
+ 'u' => '0011100',
104
+ 'V' => '0111110',
105
+ 'v' => '0011100',
106
+ 'y' => '0110011',
107
+
108
+ 'ö' => '1011101',
109
+ 'ü' => '1011100',
110
+
111
+ ' ' => '0000000',
112
+
113
+ '_' => '0001000',
114
+ '-' => '0000001',
115
+ '=' => '0001001',
116
+
117
+ '(' => '1001110',
118
+ ')' => '1111000',
119
+
120
+ '[' => '1001110',
121
+ ']' => '1111000',
122
+
123
+ }
124
+ end
125
+
18
126
  end
19
127
 
20
128
  end
@@ -15,22 +15,24 @@ module Tinkerforge
15
15
  "%s (%s:%s)" % [self.class, host, port]
16
16
  end
17
17
 
18
- # Returns a Tinkerforge::DeviceCollection with devices discovered for this IP Connection.
18
+ # Returns a Tinkerforge::DeviceCollection with devices discovered for this IP Connection. Discovery may take a few moments.
19
19
  #
20
- # Discovery may take a few seconds, but will return a Tinkerforge::DeviceCollection immediately.
21
- #
22
- # It is therefore a good idea to store the result in a variable.
23
- # This variable will be filled with devices as they are found. See examples.
20
+ # Accepts an optional argument for the number of seconds to wait, otherwise returns immediately.
24
21
  #
22
+ # A good idea is to store the result in a variable, which will then be filled with devices as they are found.
25
23
  # @example Using Tinkerforge.connect
26
24
  # my_devices = Tinkerforge.connect.discover
27
25
  #
26
+ # @example Wait 1 second
27
+ # Tinkerforge.connect.discover(1).ls
28
+ #
28
29
  # @example Classic
29
30
  # ipcon = Tinkerforge::IPConnection.new
30
31
  # ipcon.connect 'localhost', 4223
31
32
  # my_devices = ipcon.discover
32
- def discover
33
+ def discover(seconds=nil)
33
34
  list = Tinkerforge::DeviceCollection.new
35
+
34
36
  self.register_callback(CALLBACK_ENUMERATE) do |*args|
35
37
  case args[6]
36
38
  when 0, 1
@@ -43,7 +45,9 @@ module Tinkerforge
43
45
  raise "Unknown Enumeration Type: #{args[6]}"
44
46
  end
45
47
  end
48
+
46
49
  self.enumerate
50
+ sleep(seconds.to_f) if seconds
47
51
  list
48
52
  end
49
53
 
@@ -3,7 +3,7 @@ require 'tinkerforge/version'
3
3
  module Tinkerforge
4
4
 
5
5
  # Tinderfridge version.
6
- TINDERFRIDGE_VERSION = '0.3.0'
6
+ TINDERFRIDGE_VERSION = '0.4.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.3.0
4
+ version: 0.4.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-01-18 00:00:00.000000000 Z
11
+ date: 2021-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tinkerforge
@@ -41,9 +41,15 @@ files:
41
41
  - lib/tinderfridge/device_collection.rb
42
42
  - lib/tinderfridge/device_info.rb
43
43
  - lib/tinderfridge/device_info.txt
44
+ - lib/tinderfridge/devices/brick_hat.rb
45
+ - lib/tinderfridge/devices/brick_hat_zero.rb
46
+ - lib/tinderfridge/devices/bricklet_dmx.rb
44
47
  - lib/tinderfridge/devices/bricklet_gps_v2.rb
48
+ - lib/tinderfridge/devices/bricklet_industrial_dual_relay.rb
45
49
  - lib/tinderfridge/devices/bricklet_lcd_128x64.rb
46
50
  - lib/tinderfridge/devices/bricklet_led_strip_v2.rb
51
+ - lib/tinderfridge/devices/bricklet_multi_touch_v2.rb
52
+ - lib/tinderfridge/devices/bricklet_nfc.rb
47
53
  - lib/tinderfridge/devices/bricklet_outdoor_weather.rb
48
54
  - lib/tinderfridge/devices/bricklet_rgb_led_button.rb
49
55
  - lib/tinderfridge/devices/bricklet_rgb_led_v2.rb