tinkerforge 2.1.4 → 2.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/lib/tinkerforge/brick_dc.rb +42 -4
  2. data/lib/tinkerforge/brick_imu.rb +49 -11
  3. data/lib/tinkerforge/brick_imu_v2.rb +506 -0
  4. data/lib/tinkerforge/brick_master.rb +86 -46
  5. data/lib/tinkerforge/brick_red.rb +36 -5
  6. data/lib/tinkerforge/brick_servo.rb +53 -15
  7. data/lib/tinkerforge/brick_stepper.rb +43 -14
  8. data/lib/tinkerforge/bricklet_accelerometer.rb +229 -0
  9. data/lib/tinkerforge/bricklet_ambient_light.rb +10 -9
  10. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +216 -0
  11. data/lib/tinkerforge/bricklet_analog_in.rb +13 -12
  12. data/lib/tinkerforge/bricklet_analog_in_v2.rb +259 -0
  13. data/lib/tinkerforge/bricklet_analog_out.rb +5 -4
  14. data/lib/tinkerforge/bricklet_analog_out_v2.rb +66 -0
  15. data/lib/tinkerforge/bricklet_barometer.rb +11 -9
  16. data/lib/tinkerforge/bricklet_color.rb +11 -9
  17. data/lib/tinkerforge/bricklet_current12.rb +5 -4
  18. data/lib/tinkerforge/bricklet_current25.rb +5 -4
  19. data/lib/tinkerforge/bricklet_distance_ir.rb +8 -7
  20. data/lib/tinkerforge/bricklet_distance_us.rb +9 -8
  21. data/lib/tinkerforge/bricklet_dual_button.rb +5 -4
  22. data/lib/tinkerforge/bricklet_dual_relay.rb +5 -4
  23. data/lib/tinkerforge/bricklet_dust_detector.rb +178 -0
  24. data/lib/tinkerforge/bricklet_gps.rb +6 -5
  25. data/lib/tinkerforge/bricklet_hall_effect.rb +5 -4
  26. data/lib/tinkerforge/bricklet_humidity.rb +8 -7
  27. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +137 -0
  28. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +8 -7
  29. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +5 -4
  30. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +6 -5
  31. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +209 -0
  32. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +5 -4
  33. data/lib/tinkerforge/bricklet_io16.rb +8 -7
  34. data/lib/tinkerforge/bricklet_io4.rb +8 -7
  35. data/lib/tinkerforge/bricklet_joystick.rb +5 -4
  36. data/lib/tinkerforge/bricklet_laser_range_finder.rb +324 -0
  37. data/lib/tinkerforge/bricklet_lcd_16x2.rb +7 -6
  38. data/lib/tinkerforge/bricklet_lcd_20x4.rb +11 -10
  39. data/lib/tinkerforge/bricklet_led_strip.rb +12 -10
  40. data/lib/tinkerforge/bricklet_line.rb +5 -4
  41. data/lib/tinkerforge/bricklet_linear_poti.rb +8 -7
  42. data/lib/tinkerforge/bricklet_load_cell.rb +261 -0
  43. data/lib/tinkerforge/bricklet_moisture.rb +6 -5
  44. data/lib/tinkerforge/bricklet_motion_detector.rb +5 -4
  45. data/lib/tinkerforge/bricklet_multi_touch.rb +5 -4
  46. data/lib/tinkerforge/bricklet_nfc_rfid.rb +38 -46
  47. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +5 -4
  48. data/lib/tinkerforge/bricklet_piezo_speaker.rb +6 -5
  49. data/lib/tinkerforge/bricklet_ptc.rb +5 -4
  50. data/lib/tinkerforge/bricklet_remote_switch.rb +9 -8
  51. data/lib/tinkerforge/bricklet_rotary_encoder.rb +5 -4
  52. data/lib/tinkerforge/bricklet_rotary_poti.rb +5 -4
  53. data/lib/tinkerforge/bricklet_rs232.rb +183 -0
  54. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +8 -5
  55. data/lib/tinkerforge/bricklet_solid_state_relay.rb +5 -4
  56. data/lib/tinkerforge/bricklet_sound_intensity.rb +6 -5
  57. data/lib/tinkerforge/bricklet_temperature.rb +7 -6
  58. data/lib/tinkerforge/bricklet_temperature_ir.rb +7 -6
  59. data/lib/tinkerforge/bricklet_tilt.rb +5 -4
  60. data/lib/tinkerforge/bricklet_voltage.rb +8 -7
  61. data/lib/tinkerforge/bricklet_voltage_current.rb +5 -4
  62. data/lib/tinkerforge/version.rb +1 -1
  63. metadata +13 -2
@@ -1,18 +1,19 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2014-12-10. #
3
+ # This file was automatically generated on 2015-11-17. #
4
4
  # #
5
- # Bindings Version 2.1.4 #
5
+ # Bindings Version 2.1.6 #
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 #
9
- # to the generator git on tinkerforge.com #
9
+ # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
12
  module Tinkerforge
13
- # Device for controlling up to 4 Solid State Relays
13
+ # 4 galvanically isolated solid state relays
14
14
  class BrickletIndustrialQuadRelay < Device
15
15
  DEVICE_IDENTIFIER = 225 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'Industrial Quad Relay Bricklet' # :nodoc:
16
17
 
17
18
  # This callback is triggered whenever a monoflop timer reaches 0. The
18
19
  # parameters contain the involved pins and the current value of the pins
@@ -1,18 +1,19 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2014-12-10. #
3
+ # This file was automatically generated on 2015-11-17. #
4
4
  # #
5
- # Bindings Version 2.1.4 #
5
+ # Bindings Version 2.1.6 #
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 #
9
- # to the generator git on tinkerforge.com #
9
+ # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
12
  module Tinkerforge
13
- # Device for controlling up to 16 general purpose input/output pins
13
+ # 16-channel digital input/output
14
14
  class BrickletIO16 < Device
15
15
  DEVICE_IDENTIFIER = 28 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'IO-16 Bricklet' # :nodoc:
16
17
 
17
18
  # This callback is triggered whenever a change of the voltage level is detected
18
19
  # on pins where the interrupt was activated with BrickletIO16#set_port_interrupt.
@@ -226,7 +227,7 @@ module Tinkerforge
226
227
  # If you set the reset counter to *true*, the count is set back to 0
227
228
  # directly after it is read.
228
229
  #
229
- # .. versionadded:: 2.0.3~(Plugin)
230
+ # .. versionadded:: 2.0.3$nbsp;(Plugin)
230
231
  def get_edge_count(pin, reset_counter)
231
232
  send_request(FUNCTION_GET_EDGE_COUNT, [pin, reset_counter], 'C ?', 4, 'L')
232
233
  end
@@ -250,7 +251,7 @@ module Tinkerforge
250
251
  #
251
252
  # Default values: 0 (edge type) and 100ms (debounce time)
252
253
  #
253
- # .. versionadded:: 2.0.3~(Plugin)
254
+ # .. versionadded:: 2.0.3$nbsp;(Plugin)
254
255
  def set_edge_count_config(pin, edge_type, debounce)
255
256
  send_request(FUNCTION_SET_EDGE_COUNT_CONFIG, [pin, edge_type, debounce], 'C C C', 0, '')
256
257
  end
@@ -258,7 +259,7 @@ module Tinkerforge
258
259
  # Returns the edge type and debounce time for the selected pin of port A as set by
259
260
  # BrickletIO16#set_edge_count_config.
260
261
  #
261
- # .. versionadded:: 2.0.3~(Plugin)
262
+ # .. versionadded:: 2.0.3$nbsp;(Plugin)
262
263
  def get_edge_count_config(pin)
263
264
  send_request(FUNCTION_GET_EDGE_COUNT_CONFIG, [pin], 'C', 2, 'C C')
264
265
  end
@@ -1,18 +1,19 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2014-12-10. #
3
+ # This file was automatically generated on 2015-11-17. #
4
4
  # #
5
- # Bindings Version 2.1.4 #
5
+ # Bindings Version 2.1.6 #
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 #
9
- # to the generator git on tinkerforge.com #
9
+ # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
12
  module Tinkerforge
13
- # Device for controlling up to 4 general purpose input/output pins
13
+ # 4-channel digital input/output
14
14
  class BrickletIO4 < Device
15
15
  DEVICE_IDENTIFIER = 29 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'IO-4 Bricklet' # :nodoc:
16
17
 
17
18
  # This callback is triggered whenever a change of the voltage level is detected
18
19
  # on pins where the interrupt was activated with BrickletIO4#set_interrupt.
@@ -224,7 +225,7 @@ module Tinkerforge
224
225
  # If you set the reset counter to *true*, the count is set back to 0
225
226
  # directly after it is read.
226
227
  #
227
- # .. versionadded:: 2.0.1~(Plugin)
228
+ # .. versionadded:: 2.0.1$nbsp;(Plugin)
228
229
  def get_edge_count(pin, reset_counter)
229
230
  send_request(FUNCTION_GET_EDGE_COUNT, [pin, reset_counter], 'C ?', 4, 'L')
230
231
  end
@@ -247,7 +248,7 @@ module Tinkerforge
247
248
  #
248
249
  # Default values: 0 (edge type) and 100ms (debounce time)
249
250
  #
250
- # .. versionadded:: 2.0.1~(Plugin)
251
+ # .. versionadded:: 2.0.1$nbsp;(Plugin)
251
252
  def set_edge_count_config(selection_mask, edge_type, debounce)
252
253
  send_request(FUNCTION_SET_EDGE_COUNT_CONFIG, [selection_mask, edge_type, debounce], 'C C C', 0, '')
253
254
  end
@@ -255,7 +256,7 @@ module Tinkerforge
255
256
  # Returns the edge type and debounce time for the selected pin as set by
256
257
  # BrickletIO4#set_edge_count_config.
257
258
  #
258
- # .. versionadded:: 2.0.1~(Plugin)
259
+ # .. versionadded:: 2.0.1$nbsp;(Plugin)
259
260
  def get_edge_count_config(pin)
260
261
  send_request(FUNCTION_GET_EDGE_COUNT_CONFIG, [pin], 'C', 2, 'C C')
261
262
  end
@@ -1,18 +1,19 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2014-12-10. #
3
+ # This file was automatically generated on 2015-11-17. #
4
4
  # #
5
- # Bindings Version 2.1.4 #
5
+ # Bindings Version 2.1.6 #
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 #
9
- # to the generator git on tinkerforge.com #
9
+ # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
12
  module Tinkerforge
13
- # Dual-Axis Joystick with Button
13
+ # 2-axis joystick with push-button
14
14
  class BrickletJoystick < Device
15
15
  DEVICE_IDENTIFIER = 210 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'Joystick Bricklet' # :nodoc:
16
17
 
17
18
  # This callback is triggered periodically with the period that is set by
18
19
  # BrickletJoystick#set_position_callback_period. The parameter is the position of the
@@ -0,0 +1,324 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2015-11-17. #
4
+ # #
5
+ # Bindings Version 2.1.6 #
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 generators git repository on tinkerforge.com #
10
+ #############################################################
11
+
12
+ module Tinkerforge
13
+ # Measures distance up to 40m with laser light
14
+ class BrickletLaserRangeFinder < Device
15
+ DEVICE_IDENTIFIER = 255 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'Laser Range Finder Bricklet' # :nodoc:
17
+
18
+ # This callback is triggered periodically with the period that is set by
19
+ # BrickletLaserRangeFinder#set_distance_callback_period. The parameter is the distance value
20
+ # of the sensor.
21
+ #
22
+ # CALLBACK_DISTANCE is only triggered if the distance value has changed since the
23
+ # last triggering.
24
+ CALLBACK_DISTANCE = 20
25
+
26
+ # This callback is triggered periodically with the period that is set by
27
+ # BrickletLaserRangeFinder#set_velocity_callback_period. The parameter is the velocity value
28
+ # of the sensor.
29
+ #
30
+ # CALLBACK_VELOCITY is only triggered if the velocity has changed since the
31
+ # last triggering.
32
+ CALLBACK_VELOCITY = 21
33
+
34
+ # This callback is triggered when the threshold as set by
35
+ # BrickletLaserRangeFinder#set_distance_callback_threshold is reached.
36
+ # The parameter is the distance value of the sensor.
37
+ #
38
+ # If the threshold keeps being reached, the callback is triggered periodically
39
+ # with the period as set by BrickletLaserRangeFinder#set_debounce_period.
40
+ CALLBACK_DISTANCE_REACHED = 22
41
+
42
+ # This callback is triggered when the threshold as set by
43
+ # BrickletLaserRangeFinder#set_velocity_callback_threshold is reached.
44
+ # The parameter is the velocity value of the sensor.
45
+ #
46
+ # If the threshold keeps being reached, the callback is triggered periodically
47
+ # with the period as set by BrickletLaserRangeFinder#set_debounce_period.
48
+ CALLBACK_VELOCITY_REACHED = 23
49
+
50
+ FUNCTION_GET_DISTANCE = 1 # :nodoc:
51
+ FUNCTION_GET_VELOCITY = 2 # :nodoc:
52
+ FUNCTION_SET_DISTANCE_CALLBACK_PERIOD = 3 # :nodoc:
53
+ FUNCTION_GET_DISTANCE_CALLBACK_PERIOD = 4 # :nodoc:
54
+ FUNCTION_SET_VELOCITY_CALLBACK_PERIOD = 5 # :nodoc:
55
+ FUNCTION_GET_VELOCITY_CALLBACK_PERIOD = 6 # :nodoc:
56
+ FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD = 7 # :nodoc:
57
+ FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD = 8 # :nodoc:
58
+ FUNCTION_SET_VELOCITY_CALLBACK_THRESHOLD = 9 # :nodoc:
59
+ FUNCTION_GET_VELOCITY_CALLBACK_THRESHOLD = 10 # :nodoc:
60
+ FUNCTION_SET_DEBOUNCE_PERIOD = 11 # :nodoc:
61
+ FUNCTION_GET_DEBOUNCE_PERIOD = 12 # :nodoc:
62
+ FUNCTION_SET_MOVING_AVERAGE = 13 # :nodoc:
63
+ FUNCTION_GET_MOVING_AVERAGE = 14 # :nodoc:
64
+ FUNCTION_SET_MODE = 15 # :nodoc:
65
+ FUNCTION_GET_MODE = 16 # :nodoc:
66
+ FUNCTION_ENABLE_LASER = 17 # :nodoc:
67
+ FUNCTION_DISABLE_LASER = 18 # :nodoc:
68
+ FUNCTION_IS_LASER_ENABLED = 19 # :nodoc:
69
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
70
+
71
+ THRESHOLD_OPTION_OFF = 'x' # :nodoc:
72
+ THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
73
+ THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
74
+ THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
75
+ THRESHOLD_OPTION_GREATER = '>' # :nodoc:
76
+ MODE_DISTANCE = 0 # :nodoc:
77
+ MODE_VELOCITY_MAX_13MS = 1 # :nodoc:
78
+ MODE_VELOCITY_MAX_32MS = 2 # :nodoc:
79
+ MODE_VELOCITY_MAX_64MS = 3 # :nodoc:
80
+ MODE_VELOCITY_MAX_127MS = 4 # :nodoc:
81
+
82
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
83
+ # the IP Connection <tt>ipcon</tt>.
84
+ def initialize(uid, ipcon)
85
+ super uid, ipcon
86
+
87
+ @api_version = [2, 0, 0]
88
+
89
+ @response_expected[FUNCTION_GET_DISTANCE] = RESPONSE_EXPECTED_ALWAYS_TRUE
90
+ @response_expected[FUNCTION_GET_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
91
+ @response_expected[FUNCTION_SET_DISTANCE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
92
+ @response_expected[FUNCTION_GET_DISTANCE_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
93
+ @response_expected[FUNCTION_SET_VELOCITY_CALLBACK_PERIOD] = RESPONSE_EXPECTED_TRUE
94
+ @response_expected[FUNCTION_GET_VELOCITY_CALLBACK_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
95
+ @response_expected[FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
96
+ @response_expected[FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
97
+ @response_expected[FUNCTION_SET_VELOCITY_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_TRUE
98
+ @response_expected[FUNCTION_GET_VELOCITY_CALLBACK_THRESHOLD] = RESPONSE_EXPECTED_ALWAYS_TRUE
99
+ @response_expected[FUNCTION_SET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_TRUE
100
+ @response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
101
+ @response_expected[FUNCTION_SET_MOVING_AVERAGE] = RESPONSE_EXPECTED_FALSE
102
+ @response_expected[FUNCTION_GET_MOVING_AVERAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
103
+ @response_expected[FUNCTION_SET_MODE] = RESPONSE_EXPECTED_FALSE
104
+ @response_expected[FUNCTION_GET_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
105
+ @response_expected[FUNCTION_ENABLE_LASER] = RESPONSE_EXPECTED_FALSE
106
+ @response_expected[FUNCTION_DISABLE_LASER] = RESPONSE_EXPECTED_FALSE
107
+ @response_expected[FUNCTION_IS_LASER_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
108
+ @response_expected[CALLBACK_DISTANCE] = RESPONSE_EXPECTED_ALWAYS_FALSE
109
+ @response_expected[CALLBACK_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_FALSE
110
+ @response_expected[CALLBACK_DISTANCE_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
111
+ @response_expected[CALLBACK_VELOCITY_REACHED] = RESPONSE_EXPECTED_ALWAYS_FALSE
112
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
113
+
114
+ @callback_formats[CALLBACK_DISTANCE] = 'S'
115
+ @callback_formats[CALLBACK_VELOCITY] = 's'
116
+ @callback_formats[CALLBACK_DISTANCE_REACHED] = 'S'
117
+ @callback_formats[CALLBACK_VELOCITY_REACHED] = 's'
118
+ end
119
+
120
+ # Returns the measured distance. The value has a range of 0 to 4000
121
+ # and is given in cm.
122
+ #
123
+ # The Laser Range Finder Bricklet knows different modes. Distances
124
+ # are only measured in the distance measurement mode,
125
+ # see BrickletLaserRangeFinder#set_mode. Also the laser has to be enabled, see
126
+ # BrickletLaserRangeFinder#enable_laser.
127
+ #
128
+ # If you want to get the distance periodically, it is recommended to
129
+ # use the callback CALLBACK_DISTANCE and set the period with
130
+ # BrickletLaserRangeFinder#set_distance_callback_period.
131
+ def get_distance
132
+ send_request(FUNCTION_GET_DISTANCE, [], '', 2, 'S')
133
+ end
134
+
135
+ # Returns the measured velocity. The value has a range of 0 to 12700
136
+ # and is given in 1/100 m/s.
137
+ #
138
+ # The Laser Range Finder Bricklet knows different modes. Velocity
139
+ # is only measured in the velocity measurement modes,
140
+ # see BrickletLaserRangeFinder#set_mode. Also the laser has to be enabled, see
141
+ # BrickletLaserRangeFinder#enable_laser.
142
+ #
143
+ # If you want to get the velocity periodically, it is recommended to
144
+ # use the callback CALLBACK_VELOCITY and set the period with
145
+ # BrickletLaserRangeFinder#set_velocity_callback_period.
146
+ def get_velocity
147
+ send_request(FUNCTION_GET_VELOCITY, [], '', 2, 's')
148
+ end
149
+
150
+ # Sets the period in ms with which the CALLBACK_DISTANCE callback is triggered
151
+ # periodically. A value of 0 turns the callback off.
152
+ #
153
+ # CALLBACK_DISTANCE is only triggered if the distance value has changed since the
154
+ # last triggering.
155
+ #
156
+ # The default value is 0.
157
+ def set_distance_callback_period(period)
158
+ send_request(FUNCTION_SET_DISTANCE_CALLBACK_PERIOD, [period], 'L', 0, '')
159
+ end
160
+
161
+ # Returns the period as set by BrickletLaserRangeFinder#set_distance_callback_period.
162
+ def get_distance_callback_period
163
+ send_request(FUNCTION_GET_DISTANCE_CALLBACK_PERIOD, [], '', 4, 'L')
164
+ end
165
+
166
+ # Sets the period in ms with which the CALLBACK_VELOCITY callback is triggered
167
+ # periodically. A value of 0 turns the callback off.
168
+ #
169
+ # CALLBACK_VELOCITY is only triggered if the velocity value has changed since the
170
+ # last triggering.
171
+ #
172
+ # The default value is 0.
173
+ def set_velocity_callback_period(period)
174
+ send_request(FUNCTION_SET_VELOCITY_CALLBACK_PERIOD, [period], 'L', 0, '')
175
+ end
176
+
177
+ # Returns the period as set by BrickletLaserRangeFinder#set_velocity_callback_period.
178
+ def get_velocity_callback_period
179
+ send_request(FUNCTION_GET_VELOCITY_CALLBACK_PERIOD, [], '', 4, 'L')
180
+ end
181
+
182
+ # Sets the thresholds for the CALLBACK_DISTANCE_REACHED callback.
183
+ #
184
+ # The following options are possible:
185
+ #
186
+ # "Option", "Description"
187
+ #
188
+ # "'x'", "Callback is turned off"
189
+ # "'o'", "Callback is triggered when the distance value is *outside* the min and max values"
190
+ # "'i'", "Callback is triggered when the distance value is *inside* the min and max values"
191
+ # "'<'", "Callback is triggered when the distance value is smaller than the min value (max is ignored)"
192
+ # "'>'", "Callback is triggered when the distance value is greater than the min value (max is ignored)"
193
+ #
194
+ # The default value is ('x', 0, 0).
195
+ def set_distance_callback_threshold(option, min, max)
196
+ send_request(FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, '')
197
+ end
198
+
199
+ # Returns the threshold as set by BrickletLaserRangeFinder#set_distance_callback_threshold.
200
+ def get_distance_callback_threshold
201
+ send_request(FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD, [], '', 5, 'k S S')
202
+ end
203
+
204
+ # Sets the thresholds for the CALLBACK_VELOCITY_REACHED callback.
205
+ #
206
+ # The following options are possible:
207
+ #
208
+ # "Option", "Description"
209
+ #
210
+ # "'x'", "Callback is turned off"
211
+ # "'o'", "Callback is triggered when the velocity is *outside* the min and max values"
212
+ # "'i'", "Callback is triggered when the velocity is *inside* the min and max values"
213
+ # "'<'", "Callback is triggered when the velocity is smaller than the min value (max is ignored)"
214
+ # "'>'", "Callback is triggered when the velocity is greater than the min value (max is ignored)"
215
+ #
216
+ # The default value is ('x', 0, 0).
217
+ def set_velocity_callback_threshold(option, min, max)
218
+ send_request(FUNCTION_SET_VELOCITY_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 0, '')
219
+ end
220
+
221
+ # Returns the threshold as set by BrickletLaserRangeFinder#set_velocity_callback_threshold.
222
+ def get_velocity_callback_threshold
223
+ send_request(FUNCTION_GET_VELOCITY_CALLBACK_THRESHOLD, [], '', 5, 'k s s')
224
+ end
225
+
226
+ # Sets the period in ms with which the threshold callbacks
227
+ #
228
+ # * CALLBACK_DISTANCE_REACHED,
229
+ # * CALLBACK_VELOCITY_REACHED,
230
+ #
231
+ # are triggered, if the thresholds
232
+ #
233
+ # * BrickletLaserRangeFinder#set_distance_callback_threshold,
234
+ # * BrickletLaserRangeFinder#set_velocity_callback_threshold,
235
+ #
236
+ # keep being reached.
237
+ #
238
+ # The default value is 100.
239
+ def set_debounce_period(debounce)
240
+ send_request(FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, '')
241
+ end
242
+
243
+ # Returns the debounce period as set by BrickletLaserRangeFinder#set_debounce_period.
244
+ def get_debounce_period
245
+ send_request(FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L')
246
+ end
247
+
248
+ # Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
249
+ # for the distance and velocity.
250
+ #
251
+ # Setting the length to 0 will turn the averaging completely off. With less
252
+ # averaging, there is more noise on the data.
253
+ #
254
+ # The range for the averaging is 0-30.
255
+ #
256
+ # The default value is 10.
257
+ def set_moving_average(distance_average_length, velocity_average_length)
258
+ send_request(FUNCTION_SET_MOVING_AVERAGE, [distance_average_length, velocity_average_length], 'C C', 0, '')
259
+ end
260
+
261
+ # Returns the length moving average as set by BrickletLaserRangeFinder#set_moving_average.
262
+ def get_moving_average
263
+ send_request(FUNCTION_GET_MOVING_AVERAGE, [], '', 2, 'C C')
264
+ end
265
+
266
+ # The LIDAR has five different modes. One mode is for distance
267
+ # measurements and four modes are for velocity measurements with
268
+ # different ranges.
269
+ #
270
+ # The following modes are available:
271
+ #
272
+ # * 0: Distance is measured with resolution 1.0 cm and range 0-400 cm
273
+ # * 1: Velocity is measured with resolution 0.1 m/s and range is 0-12.7 m/s
274
+ # * 2: Velocity is measured with resolution 0.25 m/s and range is 0-31.75 m/s
275
+ # * 3: Velocity is measured with resolution 0.5 m/s and range is 0-63.5 m/s
276
+ # * 4: Velocity is measured with resolution 1.0 m/s and range is 0-127 m/s
277
+ #
278
+ # The default mode is 0 (distance is measured).
279
+ def set_mode(mode)
280
+ send_request(FUNCTION_SET_MODE, [mode], 'C', 0, '')
281
+ end
282
+
283
+ # Returns the mode as set by BrickletLaserRangeFinder#set_mode.
284
+ def get_mode
285
+ send_request(FUNCTION_GET_MODE, [], '', 1, 'C')
286
+ end
287
+
288
+ # Activates the laser of the LIDAR.
289
+ #
290
+ # We recommend that you wait 250ms after enabling the laser before
291
+ # the first call of BrickletLaserRangeFinder#get_distance to ensure stable measurements.
292
+ def enable_laser
293
+ send_request(FUNCTION_ENABLE_LASER, [], '', 0, '')
294
+ end
295
+
296
+ # Deactivates the laser of the LIDAR.
297
+ def disable_laser
298
+ send_request(FUNCTION_DISABLE_LASER, [], '', 0, '')
299
+ end
300
+
301
+ # Returns *true* if the laser is enabled, *false* otherwise.
302
+ def is_laser_enabled
303
+ send_request(FUNCTION_IS_LASER_ENABLED, [], '', 1, '?')
304
+ end
305
+
306
+ # Returns the UID, the UID where the Bricklet is connected to,
307
+ # the position, the hardware and firmware version as well as the
308
+ # device identifier.
309
+ #
310
+ # The position can be 'a', 'b', 'c' or 'd'.
311
+ #
312
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
313
+ # |device_identifier_constant|
314
+ def get_identity
315
+ send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
316
+ end
317
+
318
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
319
+ def register_callback(id, &block)
320
+ callback = block
321
+ @registered_callbacks[id] = callback
322
+ end
323
+ end
324
+ end