tinkerforge 2.0.11 → 2.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/lib/tinkerforge/brick_dc.rb +2 -2
  2. data/lib/tinkerforge/brick_imu.rb +2 -2
  3. data/lib/tinkerforge/brick_master.rb +2 -2
  4. data/lib/tinkerforge/brick_servo.rb +3 -3
  5. data/lib/tinkerforge/brick_stepper.rb +2 -2
  6. data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
  7. data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
  8. data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
  9. data/lib/tinkerforge/bricklet_barometer.rb +2 -2
  10. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  11. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  12. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  13. data/lib/tinkerforge/bricklet_distance_us.rb +183 -0
  14. data/lib/tinkerforge/bricklet_dual_button.rb +123 -0
  15. data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
  16. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  17. data/lib/tinkerforge/bricklet_hall_effect.rb +163 -0
  18. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  19. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +3 -3
  20. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
  21. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  22. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
  23. data/lib/tinkerforge/bricklet_io16.rb +2 -2
  24. data/lib/tinkerforge/bricklet_io4.rb +2 -2
  25. data/lib/tinkerforge/bricklet_joystick.rb +2 -2
  26. data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
  27. data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
  28. data/lib/tinkerforge/bricklet_led_strip.rb +134 -0
  29. data/lib/tinkerforge/bricklet_line.rb +160 -0
  30. data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
  31. data/lib/tinkerforge/bricklet_moisture.rb +180 -0
  32. data/lib/tinkerforge/bricklet_motion_detector.rb +73 -0
  33. data/lib/tinkerforge/bricklet_multi_touch.rb +143 -0
  34. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  35. data/lib/tinkerforge/bricklet_piezo_speaker.rb +107 -0
  36. data/lib/tinkerforge/bricklet_ptc.rb +2 -2
  37. data/lib/tinkerforge/bricklet_remote_switch.rb +104 -0
  38. data/lib/tinkerforge/bricklet_rotary_encoder.rb +179 -0
  39. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  40. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +110 -0
  41. data/lib/tinkerforge/bricklet_sound_intensity.rb +160 -0
  42. data/lib/tinkerforge/bricklet_temperature.rb +2 -2
  43. data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
  44. data/lib/tinkerforge/bricklet_tilt.rb +99 -0
  45. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  46. data/lib/tinkerforge/bricklet_voltage_current.rb +3 -3
  47. data/lib/tinkerforge/version.rb +1 -1
  48. metadata +16 -2
@@ -0,0 +1,160 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2013-11-27. #
4
+ # #
5
+ # Bindings Version 2.0.12 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generator git on tinkerforge.com #
10
+ #############################################################
11
+
12
+ module Tinkerforge
13
+ # Device for sensing sound intensity
14
+ class BrickletSoundIntensity < Device
15
+ DEVICE_IDENTIFIER = 238 # :nodoc:
16
+
17
+ # This callback is triggered periodically with the period that is set by
18
+ # BrickletSoundIntensity#set_intensity_callback_period. The parameter is the intensity of
19
+ # the encoder.
20
+ #
21
+ # CALLBACK_INTENSITY is only triggered if the intensity has changed since the
22
+ # last triggering.
23
+ CALLBACK_INTENSITY = 8
24
+
25
+ # This callback is triggered when the threshold as set by
26
+ # BrickletSoundIntensity#set_intensity_callback_threshold is reached.
27
+ # The parameter is the intensity of the encoder.
28
+ #
29
+ # If the threshold keeps being reached, the callback is triggered periodically
30
+ # with the period as set by BrickletSoundIntensity#set_debounce_period.
31
+ CALLBACK_INTENSITY_REACHED = 9
32
+
33
+ FUNCTION_GET_INTENSITY = 1 # :nodoc:
34
+ FUNCTION_SET_INTENSITY_CALLBACK_PERIOD = 2 # :nodoc:
35
+ FUNCTION_GET_INTENSITY_CALLBACK_PERIOD = 3 # :nodoc:
36
+ FUNCTION_SET_INTENSITY_CALLBACK_THRESHOLD = 4 # :nodoc:
37
+ FUNCTION_GET_INTENSITY_CALLBACK_THRESHOLD = 5 # :nodoc:
38
+ FUNCTION_SET_DEBOUNCE_PERIOD = 6 # :nodoc:
39
+ FUNCTION_GET_DEBOUNCE_PERIOD = 7 # :nodoc:
40
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
41
+
42
+ THRESHOLD_OPTION_OFF = 'x' # :nodoc:
43
+ THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
44
+ THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
45
+ THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
46
+ THRESHOLD_OPTION_GREATER = '>' # :nodoc:
47
+
48
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
49
+ # the IP Connection <tt>ipcon</tt>.
50
+ def initialize(uid, ipcon)
51
+ super uid, ipcon
52
+
53
+ @api_version = [2, 0, 0]
54
+
55
+ @response_expected[FUNCTION_GET_INTENSITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
56
+ @response_expected[FUNCTION_SET_INTENSITY_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
57
+ @response_expected[FUNCTION_GET_INTENSITY_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
58
+ @response_expected[FUNCTION_SET_INTENSITY_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
59
+ @response_expected[FUNCTION_GET_INTENSITY_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
60
+ @response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
61
+ @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
62
+ @response_expected[CALLBACK_INTENSITY] = RESPONSE_EXPECTED_ALWAYS_FALSE
63
+ @response_expected[CALLBACK_INTENSITY_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
64
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
65
+
66
+ @callback_formats[CALLBACK_INTENSITY] = 'S'
67
+ @callback_formats[CALLBACK_INTENSITY_REACHED] = 'S'
68
+ end
69
+
70
+ # Returns the current sound intensity. The value has a range of
71
+ # 0 to 4095.
72
+ #
73
+ # The value corresponds to the `upper envelop <http://en.wikipedia.org/wiki/Envelope_(waves)>`__
74
+ # of the signal of the microphone capsule.
75
+ #
76
+ # If you want to get the intensity periodically, it is recommended to use the
77
+ # callback CALLBACK_INTENSITY and set the period with
78
+ # BrickletSoundIntensity#set_intensity_callback_period.
79
+ def get_intensity
80
+ send_request(FUNCTION_GET_INTENSITY, [], '', 2, 'S')
81
+ end
82
+
83
+ # Sets the period in ms with which the CALLBACK_INTENSITY callback is triggered
84
+ # periodically. A value of 0 turns the callback off.
85
+ #
86
+ # CALLBACK_INTENSITY is only triggered if the intensity has changed since the
87
+ # last triggering.
88
+ #
89
+ # The default value is 0.
90
+ def set_intensity_callback_period(period)
91
+ send_request(FUNCTION_SET_INTENSITY_CALLBACK_PERIOD, [period], 'L', 0, '')
92
+ end
93
+
94
+ # Returns the period as set by BrickletSoundIntensity#set_intensity_callback_period.
95
+ def get_intensity_callback_period
96
+ send_request(FUNCTION_GET_INTENSITY_CALLBACK_PERIOD, [], '', 4, 'L')
97
+ end
98
+
99
+ # Sets the thresholds for the CALLBACK_INTENSITY_REACHED callback.
100
+ #
101
+ # The following options are possible:
102
+ #
103
+ # "Option", "Description"
104
+ #
105
+ # "'x'", "Callback is turned off"
106
+ # "'o'", "Callback is triggered when the intensity is *outside* the min and max values"
107
+ # "'i'", "Callback is triggered when the intensity is *inside* the min and max values"
108
+ # "'<'", "Callback is triggered when the intensity is smaller than the min value (max is ignored)"
109
+ # "'>'", "Callback is triggered when the intensity is greater than the min value (max is ignored)"
110
+ #
111
+ # The default value is ('x', 0, 0).
112
+ def set_intensity_callback_threshold(option, min, max)
113
+ send_request(FUNCTION_SET_INTENSITY_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
114
+ end
115
+
116
+ # Returns the threshold as set by BrickletSoundIntensity#set_intensity_callback_threshold.
117
+ def get_intensity_callback_threshold
118
+ send_request(FUNCTION_GET_INTENSITY_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
119
+ end
120
+
121
+ # Sets the period in ms with which the threshold callback
122
+ #
123
+ # * CALLBACK_INTENSITY_REACHED
124
+ #
125
+ # is triggered, if the thresholds
126
+ #
127
+ # * BrickletSoundIntensity#set_intensity_callback_threshold
128
+ #
129
+ # keeps being reached.
130
+ #
131
+ # The default value is 100.
132
+ def set_debounce_period(debounce)
133
+ send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
134
+ end
135
+
136
+ # Returns the debounce period as set by BrickletSoundIntensity#set_debounce_period.
137
+ def get_debounce_period
138
+ send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
139
+ end
140
+
141
+ # Returns the UID, the UID where the Bricklet is connected to,
142
+ # the position, the hardware and firmware version as well as the
143
+ # device identifier.
144
+ #
145
+ # The position can be 'a', 'b', 'c' or 'd'.
146
+ #
147
+ # The device identifiers can be found :ref:`here <device_identifier>`.
148
+ #
149
+ # .. versionadded:: 2.0.0~(Plugin)
150
+ def get_identity
151
+ send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
152
+ end
153
+
154
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
155
+ def register_callback(id, &block)
156
+ callback = block
157
+ @registered_callbacks[id] = callback
158
+ end
159
+ end
160
+ end
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2013-09-11. #
3
+ # This file was automatically generated on 2013-11-27. #
4
4
  # #
5
- # Bindings Version 2.0.11 #
5
+ # Bindings Version 2.0.12 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2013-09-11. #
3
+ # This file was automatically generated on 2013-11-27. #
4
4
  # #
5
- # Bindings Version 2.0.11 #
5
+ # Bindings Version 2.0.12 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
@@ -0,0 +1,99 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2013-11-27. #
4
+ # #
5
+ # Bindings Version 2.0.12 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generator git on tinkerforge.com #
10
+ #############################################################
11
+
12
+ module Tinkerforge
13
+ # Device for sensing tilt and vibration
14
+ class BrickletTilt < Device
15
+ DEVICE_IDENTIFIER = 239 # :nodoc:
16
+
17
+ # This callback provides the current tilt state. It is called every time the
18
+ # state changes.
19
+ #
20
+ # See BrickletTilt#get_tilt_state for a description of the states.
21
+ CALLBACK_TILT_STATE = 5
22
+
23
+ FUNCTION_GET_TILT_STATE = 1 # :nodoc:
24
+ FUNCTION_ENABLE_TILT_STATE_CALLBACK = 2 # :nodoc:
25
+ FUNCTION_DISABLE_TILT_STATE_CALLBACK = 3 # :nodoc:
26
+ FUNCTION_IS_TILT_STATE_CALLBACK_ENABLED = 4 # :nodoc:
27
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
28
+
29
+ TILT_STATE_CLOSED = 0 # :nodoc:
30
+ TILT_STATE_OPEN = 1 # :nodoc:
31
+ TILT_STATE_CLOSED_VIBRATING = 2 # :nodoc:
32
+
33
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
34
+ # the IP Connection <tt>ipcon</tt>.
35
+ def initialize(uid, ipcon)
36
+ super uid, ipcon
37
+
38
+ @api_version = [2, 0, 0]
39
+
40
+ @response_expected[FUNCTION_GET_TILT_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
41
+ @response_expected[FUNCTION_ENABLE_TILT_STATE_CALLBACK] = RESPONSE_EXPECTED_TRUE
42
+ @response_expected[FUNCTION_DISABLE_TILT_STATE_CALLBACK] = RESPONSE_EXPECTED_TRUE
43
+ @response_expected[FUNCTION_IS_TILT_STATE_CALLBACK_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
44
+ @response_expected[CALLBACK_TILT_STATE] = RESPONSE_EXPECTED_ALWAYS_FALSE
45
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
46
+
47
+ @callback_formats[CALLBACK_TILT_STATE] = 'C'
48
+ end
49
+
50
+ # Returns the current tilt state. The state can either be
51
+ #
52
+ # * 0 = Closed: The ball in the tilt switch closes the circuit.
53
+ # * 1 = Open: The ball in the tilt switch does not close the circuit.
54
+ # * 2 = Closed Vibrating: The tilt switch is in motion (rapid change between open and close).
55
+ #
56
+ # .. image:: /Images/Bricklets/bricklet_tilt_mechanics.jpg
57
+ # :scale: 100 %
58
+ # :alt: Tilt states
59
+ # :align: center
60
+ # :target: ../../_images/Bricklets/bricklet_tilt_mechanics.jpg
61
+ def get_tilt_state
62
+ send_request(FUNCTION_GET_TILT_STATE, [], '', 1, 'C')
63
+ end
64
+
65
+ # Enables the CALLBACK_TILT_STATE callback.
66
+ def enable_tilt_state_callback
67
+ send_request(FUNCTION_ENABLE_TILT_STATE_CALLBACK, [], '', 0, '')
68
+ end
69
+
70
+ # Disables the CALLBACK_TILT_STATE callback.
71
+ def disable_tilt_state_callback
72
+ send_request(FUNCTION_DISABLE_TILT_STATE_CALLBACK, [], '', 0, '')
73
+ end
74
+
75
+ # Returns *true* if the CALLBACK_TILT_STATE callback is enabled.
76
+ def is_tilt_state_callback_enabled
77
+ send_request(FUNCTION_IS_TILT_STATE_CALLBACK_ENABLED, [], '', 1, '?')
78
+ end
79
+
80
+ # Returns the UID, the UID where the Bricklet is connected to,
81
+ # the position, the hardware and firmware version as well as the
82
+ # device identifier.
83
+ #
84
+ # The position can be 'a', 'b', 'c' or 'd'.
85
+ #
86
+ # The device identifiers can be found :ref:`here <device_identifier>`.
87
+ #
88
+ # .. versionadded:: 2.0.0~(Plugin)
89
+ def get_identity
90
+ send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
91
+ end
92
+
93
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
94
+ def register_callback(id, &block)
95
+ callback = block
96
+ @registered_callbacks[id] = callback
97
+ end
98
+ end
99
+ end
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2013-09-11. #
3
+ # This file was automatically generated on 2013-11-27. #
4
4
  # #
5
- # Bindings Version 2.0.11 #
5
+ # Bindings Version 2.0.12 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2013-09-11. #
3
+ # This file was automatically generated on 2013-11-27. #
4
4
  # #
5
- # Bindings Version 2.0.11 #
5
+ # Bindings Version 2.0.12 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
@@ -144,7 +144,7 @@ module Tinkerforge
144
144
  end
145
145
 
146
146
  # Returns the current. The value is in mA
147
- # and between 0mA and 20000mA.
147
+ # and between -20000mA and 20000mA.
148
148
  #
149
149
  # If you want to get the current periodically, it is recommended to use the
150
150
  # callback CALLBACK_CURRENT and set the period with
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Tinkerforge
3
- VERSION = '2.0.11'
3
+ VERSION = '2.0.12'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinkerforge
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.11
4
+ version: 2.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-11 00:00:00.000000000 Z
12
+ date: 2013-11-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: matthias@tinkerforge.com
@@ -23,6 +23,9 @@ files:
23
23
  - lib/tinkerforge/bricklet_industrial_digital_out_4.rb
24
24
  - lib/tinkerforge/bricklet_temperature.rb
25
25
  - lib/tinkerforge/bricklet_current25.rb
26
+ - lib/tinkerforge/bricklet_piezo_speaker.rb
27
+ - lib/tinkerforge/bricklet_rotary_encoder.rb
28
+ - lib/tinkerforge/bricklet_led_strip.rb
26
29
  - lib/tinkerforge/bricklet_lcd_20x4.rb
27
30
  - lib/tinkerforge/bricklet_ptc.rb
28
31
  - lib/tinkerforge/bricklet_current12.rb
@@ -30,20 +33,31 @@ files:
30
33
  - lib/tinkerforge/bricklet_ambient_light.rb
31
34
  - lib/tinkerforge/bricklet_distance_ir.rb
32
35
  - lib/tinkerforge/bricklet_rotary_poti.rb
36
+ - lib/tinkerforge/bricklet_hall_effect.rb
37
+ - lib/tinkerforge/bricklet_moisture.rb
38
+ - lib/tinkerforge/bricklet_multi_touch.rb
33
39
  - lib/tinkerforge/bricklet_analog_out.rb
34
40
  - lib/tinkerforge/brick_imu.rb
35
41
  - lib/tinkerforge/brick_dc.rb
42
+ - lib/tinkerforge/bricklet_motion_detector.rb
43
+ - lib/tinkerforge/bricklet_line.rb
36
44
  - lib/tinkerforge/bricklet_joystick.rb
37
45
  - lib/tinkerforge/ip_connection.rb
38
46
  - lib/tinkerforge/bricklet_lcd_16x2.rb
39
47
  - lib/tinkerforge/bricklet_dual_relay.rb
48
+ - lib/tinkerforge/bricklet_remote_switch.rb
49
+ - lib/tinkerforge/bricklet_sound_intensity.rb
40
50
  - lib/tinkerforge/brick_servo.rb
41
51
  - lib/tinkerforge/brick_master.rb
42
52
  - lib/tinkerforge/bricklet_industrial_digital_in_4.rb
53
+ - lib/tinkerforge/bricklet_tilt.rb
43
54
  - lib/tinkerforge/brick_stepper.rb
44
55
  - lib/tinkerforge/bricklet_io4.rb
45
56
  - lib/tinkerforge/bricklet_analog_in.rb
46
57
  - lib/tinkerforge/bricklet_temperature_ir.rb
58
+ - lib/tinkerforge/bricklet_dual_button.rb
59
+ - lib/tinkerforge/bricklet_segment_display_4x7.rb
60
+ - lib/tinkerforge/bricklet_distance_us.rb
47
61
  - lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb
48
62
  - lib/tinkerforge/bricklet_humidity.rb
49
63
  - lib/tinkerforge/bricklet_piezo_buzzer.rb