tinkerforge 2.1.23 → 2.1.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +156 -75
  3. data/lib/tinkerforge/brick_hat.rb +109 -30
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +191 -86
  6. data/lib/tinkerforge/brick_imu_v2.rb +219 -118
  7. data/lib/tinkerforge/brick_master.rb +495 -195
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +186 -102
  10. data/lib/tinkerforge/brick_silent_stepper.rb +248 -168
  11. data/lib/tinkerforge/brick_stepper.rb +212 -100
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +107 -63
  14. data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
  18. data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
  21. data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
  24. data/lib/tinkerforge/bricklet_barometer.rb +108 -58
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
  26. data/lib/tinkerforge/bricklet_can.rb +84 -24
  27. data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
  28. data/lib/tinkerforge/bricklet_co2.rb +36 -25
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
  30. data/lib/tinkerforge/bricklet_color.rb +75 -47
  31. data/lib/tinkerforge/bricklet_color_v2.rb +91 -47
  32. data/lib/tinkerforge/bricklet_compass.rb +81 -40
  33. data/lib/tinkerforge/bricklet_current12.rb +61 -40
  34. data/lib/tinkerforge/bricklet_current25.rb +61 -40
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
  37. data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +68 -33
  39. data/lib/tinkerforge/bricklet_dmx.rb +92 -48
  40. data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +81 -40
  46. data/lib/tinkerforge/bricklet_gps.rb +72 -48
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
  50. data/lib/tinkerforge/bricklet_humidity.rb +54 -38
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
  52. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  53. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
  54. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
  55. data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
  62. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  63. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
  65. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
  66. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
  67. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
  68. data/lib/tinkerforge/bricklet_io16.rb +57 -32
  69. data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
  70. data/lib/tinkerforge/bricklet_io4.rb +56 -31
  71. data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
  72. data/lib/tinkerforge/bricklet_isolator.rb +111 -35
  73. data/lib/tinkerforge/bricklet_joystick.rb +63 -42
  74. data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
  75. data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
  76. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +99 -51
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +219 -131
  78. data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
  79. data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
  80. data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
  81. data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
  82. data/lib/tinkerforge/bricklet_line.rb +35 -22
  83. data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
  84. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
  85. data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
  86. data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
  87. data/lib/tinkerforge/bricklet_moisture.rb +43 -30
  88. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  89. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
  90. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
  91. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
  92. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -39
  93. data/lib/tinkerforge/bricklet_nfc.rb +130 -80
  94. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  95. data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
  96. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +75 -40
  97. data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
  98. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  99. data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
  100. data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
  101. data/lib/tinkerforge/bricklet_performance_dc.rb +676 -0
  102. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
  103. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  104. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  105. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  106. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  107. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  108. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  109. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  110. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  111. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  112. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  113. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  114. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  115. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  116. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  117. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  118. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -26
  119. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  120. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  121. data/lib/tinkerforge/bricklet_rs485.rb +250 -164
  122. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  123. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  124. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  125. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  126. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  127. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  128. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  129. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  130. data/lib/tinkerforge/bricklet_temperature_ir.rb +61 -47
  131. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +74 -44
  132. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  133. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  134. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  135. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  136. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  137. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  138. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  139. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  140. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  141. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +92 -77
  142. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +81 -36
  143. data/lib/tinkerforge/device_display_names.rb +167 -0
  144. data/lib/tinkerforge/ip_connection.rb +156 -33
  145. data/lib/tinkerforge/version.rb +1 -1
  146. metadata +8 -3
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-08-23. #
3
+ # This file was automatically generated on 2021-01-15. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.23 #
5
+ # Ruby Bindings Version 2.1.28 #
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
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # 2-axis joystick with push-button
14
16
  class BrickletJoystickV2 < Device
@@ -66,7 +68,7 @@ module Tinkerforge
66
68
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
67
69
  # the IP Connection <tt>ipcon</tt>.
68
70
  def initialize(uid, ipcon)
69
- super uid, ipcon
71
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
70
72
 
71
73
  @api_version = [2, 0, 0]
72
74
 
@@ -90,20 +92,22 @@ module Tinkerforge
90
92
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
91
93
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
92
94
 
93
- @callback_formats[CALLBACK_POSITION] = 's s'
94
- @callback_formats[CALLBACK_PRESSED] = '?'
95
+ @callback_formats[CALLBACK_POSITION] = [12, 's s']
96
+ @callback_formats[CALLBACK_PRESSED] = [9, '?']
95
97
 
98
+ @ipcon.add_device self
96
99
  end
97
100
 
98
- # Returns the position of the joystick. The value ranges between -100 and
99
- # 100 for both axis. The middle position of the joystick is x=0, y=0. The
100
- # returned values are averaged and calibrated (see BrickletJoystickV2#calibrate).
101
+ # Returns the position of the joystick. The middle position of the joystick is x=0, y=0.
102
+ # The returned values are averaged and calibrated (see BrickletJoystickV2#calibrate).
101
103
  #
102
104
  # If you want to get the position periodically, it is recommended to use the
103
105
  # CALLBACK_POSITION callback and set the period with
104
106
  # BrickletJoystickV2#set_position_callback_configuration.
105
107
  def get_position
106
- send_request FUNCTION_GET_POSITION, [], '', 4, 's s'
108
+ check_validity
109
+
110
+ send_request FUNCTION_GET_POSITION, [], '', 12, 's s'
107
111
  end
108
112
 
109
113
  # Returns *true* if the button is pressed and *false* otherwise.
@@ -112,7 +116,9 @@ module Tinkerforge
112
116
  # CALLBACK_PRESSED callback and set the period with
113
117
  # BrickletJoystickV2#set_pressed_callback_configuration.
114
118
  def is_pressed
115
- send_request FUNCTION_IS_PRESSED, [], '', 1, '?'
119
+ check_validity
120
+
121
+ send_request FUNCTION_IS_PRESSED, [], '', 9, '?'
116
122
  end
117
123
 
118
124
  # Calibrates the middle position of the joystick. If your Joystick Bricklet 2.0
@@ -122,10 +128,12 @@ module Tinkerforge
122
128
  # The resulting calibration will be saved in non-volatile memory,
123
129
  # thus you only have to calibrate it once.
124
130
  def calibrate
125
- send_request FUNCTION_CALIBRATE, [], '', 0, ''
131
+ check_validity
132
+
133
+ send_request FUNCTION_CALIBRATE, [], '', 8, ''
126
134
  end
127
135
 
128
- # The period in ms is the period with which the CALLBACK_POSITION
136
+ # The period is the period with which the CALLBACK_POSITION
129
137
  # callback is triggered periodically. A value of 0 turns the callback off.
130
138
  #
131
139
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -134,19 +142,21 @@ module Tinkerforge
134
142
  #
135
143
  # If it is set to false, the callback is continuously triggered with the period,
136
144
  # independent of the value.
137
- #
138
- # The default value is (0, false).
139
145
  def set_position_callback_configuration(period, value_has_to_change)
140
- send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
146
+ check_validity
147
+
148
+ send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
141
149
  end
142
150
 
143
151
  # Returns the callback configuration as set by
144
152
  # BrickletJoystickV2#set_position_callback_configuration.
145
153
  def get_position_callback_configuration
146
- send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
154
+ check_validity
155
+
156
+ send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
147
157
  end
148
158
 
149
- # The period in ms is the period with which the CALLBACK_PRESSED
159
+ # The period is the period with which the CALLBACK_PRESSED
150
160
  # callback is triggered periodically. A value of 0 turns the callback off.
151
161
  #
152
162
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -155,16 +165,18 @@ module Tinkerforge
155
165
  #
156
166
  # If it is set to false, the callback is continuously triggered with the period,
157
167
  # independent of the value.
158
- #
159
- # The default value is (0, false).
160
168
  def set_pressed_callback_configuration(period, value_has_to_change)
161
- send_request FUNCTION_SET_PRESSED_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
169
+ check_validity
170
+
171
+ send_request FUNCTION_SET_PRESSED_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
162
172
  end
163
173
 
164
174
  # Returns the callback configuration as set by
165
175
  # BrickletJoystickV2#set_pressed_callback_configuration.
166
176
  def get_pressed_callback_configuration
167
- send_request FUNCTION_GET_PRESSED_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
177
+ check_validity
178
+
179
+ send_request FUNCTION_GET_PRESSED_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
168
180
  end
169
181
 
170
182
  # Returns the error count for the communication between Brick and Bricklet.
@@ -179,7 +191,9 @@ module Tinkerforge
179
191
  # The errors counts are for errors that occur on the Bricklet side. All
180
192
  # Bricks have a similar function that returns the errors on the Brick side.
181
193
  def get_spitfp_error_count
182
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
194
+ check_validity
195
+
196
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
183
197
  end
184
198
 
185
199
  # Sets the bootloader mode and returns the status after the requested
@@ -192,12 +206,16 @@ module Tinkerforge
192
206
  # This function is used by Brick Viewer during flashing. It should not be
193
207
  # necessary to call it in a normal user program.
194
208
  def set_bootloader_mode(mode)
195
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
209
+ check_validity
210
+
211
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
196
212
  end
197
213
 
198
214
  # Returns the current bootloader mode, see BrickletJoystickV2#set_bootloader_mode.
199
215
  def get_bootloader_mode
200
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
216
+ check_validity
217
+
218
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
201
219
  end
202
220
 
203
221
  # Sets the firmware pointer for BrickletJoystickV2#write_firmware. The pointer has
@@ -207,7 +225,9 @@ module Tinkerforge
207
225
  # This function is used by Brick Viewer during flashing. It should not be
208
226
  # necessary to call it in a normal user program.
209
227
  def set_write_firmware_pointer(pointer)
210
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
228
+ check_validity
229
+
230
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
211
231
  end
212
232
 
213
233
  # Writes 64 Bytes of firmware at the position as written by
@@ -219,7 +239,9 @@ module Tinkerforge
219
239
  # This function is used by Brick Viewer during flashing. It should not be
220
240
  # necessary to call it in a normal user program.
221
241
  def write_firmware(data)
222
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
242
+ check_validity
243
+
244
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
223
245
  end
224
246
 
225
247
  # Sets the status LED configuration. By default the LED shows
@@ -230,22 +252,28 @@ module Tinkerforge
230
252
  #
231
253
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
232
254
  def set_status_led_config(config)
233
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
255
+ check_validity
256
+
257
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
234
258
  end
235
259
 
236
260
  # Returns the configuration as set by BrickletJoystickV2#set_status_led_config
237
261
  def get_status_led_config
238
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
262
+ check_validity
263
+
264
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
239
265
  end
240
266
 
241
- # Returns the temperature in °C as measured inside the microcontroller. The
267
+ # Returns the temperature as measured inside the microcontroller. The
242
268
  # value returned is not the ambient temperature!
243
269
  #
244
270
  # The temperature is only proportional to the real temperature and it has bad
245
271
  # accuracy. Practically it is only useful as an indicator for
246
272
  # temperature changes.
247
273
  def get_chip_temperature
248
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
274
+ check_validity
275
+
276
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
249
277
  end
250
278
 
251
279
  # Calling this function will reset the Bricklet. All configurations
@@ -255,7 +283,9 @@ module Tinkerforge
255
283
  # calling functions on the existing ones will result in
256
284
  # undefined behavior!
257
285
  def reset
258
- send_request FUNCTION_RESET, [], '', 0, ''
286
+ check_validity
287
+
288
+ send_request FUNCTION_RESET, [], '', 8, ''
259
289
  end
260
290
 
261
291
  # Writes a new UID into flash. If you want to set a new UID
@@ -264,25 +294,31 @@ module Tinkerforge
264
294
  #
265
295
  # We recommend that you use Brick Viewer to change the UID.
266
296
  def write_uid(uid)
267
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
297
+ check_validity
298
+
299
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
268
300
  end
269
301
 
270
302
  # Returns the current UID as an integer. Encode as
271
303
  # Base58 to get the usual string version.
272
304
  def read_uid
273
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
305
+ check_validity
306
+
307
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
274
308
  end
275
309
 
276
310
  # Returns the UID, the UID where the Bricklet is connected to,
277
311
  # the position, the hardware and firmware version as well as the
278
312
  # device identifier.
279
313
  #
280
- # The position can be 'a', 'b', 'c' or 'd'.
314
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
315
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
316
+ # position 'z'.
281
317
  #
282
318
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
283
319
  # |device_identifier_constant|
284
320
  def get_identity
285
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
321
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
286
322
  end
287
323
 
288
324
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-08-23. #
3
+ # This file was automatically generated on 2021-01-15. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.23 #
5
+ # Ruby Bindings Version 2.1.28 #
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
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # Measures distance up to 40m with laser light
14
16
  class BrickletLaserRangeFinder < Device
@@ -87,7 +89,7 @@ module Tinkerforge
87
89
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
88
90
  # the IP Connection <tt>ipcon</tt>.
89
91
  def initialize(uid, ipcon)
90
- super uid, ipcon
92
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
91
93
 
92
94
  @api_version = [2, 0, 1]
93
95
 
@@ -115,15 +117,15 @@ module Tinkerforge
115
117
  @response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
116
118
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
117
119
 
118
- @callback_formats[CALLBACK_DISTANCE] = 'S'
119
- @callback_formats[CALLBACK_VELOCITY] = 's'
120
- @callback_formats[CALLBACK_DISTANCE_REACHED] = 'S'
121
- @callback_formats[CALLBACK_VELOCITY_REACHED] = 's'
120
+ @callback_formats[CALLBACK_DISTANCE] = [10, 'S']
121
+ @callback_formats[CALLBACK_VELOCITY] = [10, 's']
122
+ @callback_formats[CALLBACK_DISTANCE_REACHED] = [10, 'S']
123
+ @callback_formats[CALLBACK_VELOCITY_REACHED] = [10, 's']
122
124
 
125
+ @ipcon.add_device self
123
126
  end
124
127
 
125
- # Returns the measured distance. The value has a range of 0 to 4000
126
- # and is given in cm.
128
+ # Returns the measured distance.
127
129
  #
128
130
  # Sensor hardware version 1 (see BrickletLaserRangeFinder#get_sensor_hardware_version) cannot
129
131
  # measure distance and velocity at the same time. Therefore, the distance mode
@@ -135,11 +137,12 @@ module Tinkerforge
135
137
  # use the CALLBACK_DISTANCE callback and set the period with
136
138
  # BrickletLaserRangeFinder#set_distance_callback_period.
137
139
  def get_distance
138
- send_request FUNCTION_GET_DISTANCE, [], '', 2, 'S'
140
+ check_validity
141
+
142
+ send_request FUNCTION_GET_DISTANCE, [], '', 10, 'S'
139
143
  end
140
144
 
141
- # Returns the measured velocity. The value has a range of -12800 to 12700
142
- # and is given in 1/100 m/s.
145
+ # Returns the measured velocity.
143
146
  #
144
147
  # Sensor hardware version 1 (see BrickletLaserRangeFinder#get_sensor_hardware_version) cannot
145
148
  # measure distance and velocity at the same time. Therefore, the velocity mode
@@ -153,39 +156,45 @@ module Tinkerforge
153
156
  # use the CALLBACK_VELOCITY callback and set the period with
154
157
  # BrickletLaserRangeFinder#set_velocity_callback_period.
155
158
  def get_velocity
156
- send_request FUNCTION_GET_VELOCITY, [], '', 2, 's'
159
+ check_validity
160
+
161
+ send_request FUNCTION_GET_VELOCITY, [], '', 10, 's'
157
162
  end
158
163
 
159
- # Sets the period in ms with which the CALLBACK_DISTANCE callback is triggered
164
+ # Sets the period with which the CALLBACK_DISTANCE callback is triggered
160
165
  # periodically. A value of 0 turns the callback off.
161
166
  #
162
167
  # The CALLBACK_DISTANCE callback is only triggered if the distance value has
163
168
  # changed since the last triggering.
164
- #
165
- # The default value is 0.
166
169
  def set_distance_callback_period(period)
167
- send_request FUNCTION_SET_DISTANCE_CALLBACK_PERIOD, [period], 'L', 0, ''
170
+ check_validity
171
+
172
+ send_request FUNCTION_SET_DISTANCE_CALLBACK_PERIOD, [period], 'L', 8, ''
168
173
  end
169
174
 
170
175
  # Returns the period as set by BrickletLaserRangeFinder#set_distance_callback_period.
171
176
  def get_distance_callback_period
172
- send_request FUNCTION_GET_DISTANCE_CALLBACK_PERIOD, [], '', 4, 'L'
177
+ check_validity
178
+
179
+ send_request FUNCTION_GET_DISTANCE_CALLBACK_PERIOD, [], '', 12, 'L'
173
180
  end
174
181
 
175
- # Sets the period in ms with which the CALLBACK_VELOCITY callback is triggered
182
+ # Sets the period with which the CALLBACK_VELOCITY callback is triggered
176
183
  # periodically. A value of 0 turns the callback off.
177
184
  #
178
185
  # The CALLBACK_VELOCITY callback is only triggered if the velocity value has
179
186
  # changed since the last triggering.
180
- #
181
- # The default value is 0.
182
187
  def set_velocity_callback_period(period)
183
- send_request FUNCTION_SET_VELOCITY_CALLBACK_PERIOD, [period], 'L', 0, ''
188
+ check_validity
189
+
190
+ send_request FUNCTION_SET_VELOCITY_CALLBACK_PERIOD, [period], 'L', 8, ''
184
191
  end
185
192
 
186
193
  # Returns the period as set by BrickletLaserRangeFinder#set_velocity_callback_period.
187
194
  def get_velocity_callback_period
188
- send_request FUNCTION_GET_VELOCITY_CALLBACK_PERIOD, [], '', 4, 'L'
195
+ check_validity
196
+
197
+ send_request FUNCTION_GET_VELOCITY_CALLBACK_PERIOD, [], '', 12, 'L'
189
198
  end
190
199
 
191
200
  # Sets the thresholds for the CALLBACK_DISTANCE_REACHED callback.
@@ -199,15 +208,17 @@ module Tinkerforge
199
208
  # "'i'", "Callback is triggered when the distance value is *inside* the min and max values"
200
209
  # "'<'", "Callback is triggered when the distance value is smaller than the min value (max is ignored)"
201
210
  # "'>'", "Callback is triggered when the distance value is greater than the min value (max is ignored)"
202
- #
203
- # The default value is ('x', 0, 0).
204
211
  def set_distance_callback_threshold(option, min, max)
205
- send_request FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, ''
212
+ check_validity
213
+
214
+ send_request FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
206
215
  end
207
216
 
208
217
  # Returns the threshold as set by BrickletLaserRangeFinder#set_distance_callback_threshold.
209
218
  def get_distance_callback_threshold
210
- send_request FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD, [], '', 5, 'k S S'
219
+ check_validity
220
+
221
+ send_request FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
211
222
  end
212
223
 
213
224
  # Sets the thresholds for the CALLBACK_VELOCITY_REACHED callback.
@@ -221,18 +232,20 @@ module Tinkerforge
221
232
  # "'i'", "Callback is triggered when the velocity is *inside* the min and max values"
222
233
  # "'<'", "Callback is triggered when the velocity is smaller than the min value (max is ignored)"
223
234
  # "'>'", "Callback is triggered when the velocity is greater than the min value (max is ignored)"
224
- #
225
- # The default value is ('x', 0, 0).
226
235
  def set_velocity_callback_threshold(option, min, max)
227
- send_request FUNCTION_SET_VELOCITY_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 0, ''
236
+ check_validity
237
+
238
+ send_request FUNCTION_SET_VELOCITY_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 8, ''
228
239
  end
229
240
 
230
241
  # Returns the threshold as set by BrickletLaserRangeFinder#set_velocity_callback_threshold.
231
242
  def get_velocity_callback_threshold
232
- send_request FUNCTION_GET_VELOCITY_CALLBACK_THRESHOLD, [], '', 5, 'k s s'
243
+ check_validity
244
+
245
+ send_request FUNCTION_GET_VELOCITY_CALLBACK_THRESHOLD, [], '', 13, 'k s s'
233
246
  end
234
247
 
235
- # Sets the period in ms with which the threshold callbacks
248
+ # Sets the period with which the threshold callbacks
236
249
  #
237
250
  # * CALLBACK_DISTANCE_REACHED,
238
251
  # * CALLBACK_VELOCITY_REACHED,
@@ -243,15 +256,17 @@ module Tinkerforge
243
256
  # * BrickletLaserRangeFinder#set_velocity_callback_threshold,
244
257
  #
245
258
  # keep being reached.
246
- #
247
- # The default value is 100.
248
259
  def set_debounce_period(debounce)
249
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
260
+ check_validity
261
+
262
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
250
263
  end
251
264
 
252
265
  # Returns the debounce period as set by BrickletLaserRangeFinder#set_debounce_period.
253
266
  def get_debounce_period
254
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
267
+ check_validity
268
+
269
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
255
270
  end
256
271
 
257
272
  # Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
@@ -259,17 +274,17 @@ module Tinkerforge
259
274
  #
260
275
  # Setting the length to 0 will turn the averaging completely off. With less
261
276
  # averaging, there is more noise on the data.
262
- #
263
- # The range for the averaging is 0-30.
264
- #
265
- # The default value is 10.
266
277
  def set_moving_average(distance_average_length, velocity_average_length)
267
- send_request FUNCTION_SET_MOVING_AVERAGE, [distance_average_length, velocity_average_length], 'C C', 0, ''
278
+ check_validity
279
+
280
+ send_request FUNCTION_SET_MOVING_AVERAGE, [distance_average_length, velocity_average_length], 'C C', 8, ''
268
281
  end
269
282
 
270
283
  # Returns the length moving average as set by BrickletLaserRangeFinder#set_moving_average.
271
284
  def get_moving_average
272
- send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 2, 'C C'
285
+ check_validity
286
+
287
+ send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 10, 'C C'
273
288
  end
274
289
 
275
290
  # .. note::
@@ -283,20 +298,22 @@ module Tinkerforge
283
298
  #
284
299
  # The following modes are available:
285
300
  #
286
- # * 0: Distance is measured with resolution 1.0 cm and range 0-400 cm
301
+ # * 0: Distance is measured with resolution 1.0 cm and range 0-4000 cm
287
302
  # * 1: Velocity is measured with resolution 0.1 m/s and range is 0-12.7 m/s
288
303
  # * 2: Velocity is measured with resolution 0.25 m/s and range is 0-31.75 m/s
289
304
  # * 3: Velocity is measured with resolution 0.5 m/s and range is 0-63.5 m/s
290
305
  # * 4: Velocity is measured with resolution 1.0 m/s and range is 0-127 m/s
291
- #
292
- # The default mode is 0 (distance is measured).
293
306
  def set_mode(mode)
294
- send_request FUNCTION_SET_MODE, [mode], 'C', 0, ''
307
+ check_validity
308
+
309
+ send_request FUNCTION_SET_MODE, [mode], 'C', 8, ''
295
310
  end
296
311
 
297
312
  # Returns the mode as set by BrickletLaserRangeFinder#set_mode.
298
313
  def get_mode
299
- send_request FUNCTION_GET_MODE, [], '', 1, 'C'
314
+ check_validity
315
+
316
+ send_request FUNCTION_GET_MODE, [], '', 9, 'C'
300
317
  end
301
318
 
302
319
  # Activates the laser of the LIDAR.
@@ -304,24 +321,32 @@ module Tinkerforge
304
321
  # We recommend that you wait 250ms after enabling the laser before
305
322
  # the first call of BrickletLaserRangeFinder#get_distance to ensure stable measurements.
306
323
  def enable_laser
307
- send_request FUNCTION_ENABLE_LASER, [], '', 0, ''
324
+ check_validity
325
+
326
+ send_request FUNCTION_ENABLE_LASER, [], '', 8, ''
308
327
  end
309
328
 
310
329
  # Deactivates the laser of the LIDAR.
311
330
  def disable_laser
312
- send_request FUNCTION_DISABLE_LASER, [], '', 0, ''
331
+ check_validity
332
+
333
+ send_request FUNCTION_DISABLE_LASER, [], '', 8, ''
313
334
  end
314
335
 
315
336
  # Returns *true* if the laser is enabled, *false* otherwise.
316
337
  def is_laser_enabled
317
- send_request FUNCTION_IS_LASER_ENABLED, [], '', 1, '?'
338
+ check_validity
339
+
340
+ send_request FUNCTION_IS_LASER_ENABLED, [], '', 9, '?'
318
341
  end
319
342
 
320
343
  # Returns the LIDAR-Lite hardware version.
321
344
  #
322
345
  # .. versionadded:: 2.0.3$nbsp;(Plugin)
323
346
  def get_sensor_hardware_version
324
- send_request FUNCTION_GET_SENSOR_HARDWARE_VERSION, [], '', 1, 'C'
347
+ check_validity
348
+
349
+ send_request FUNCTION_GET_SENSOR_HARDWARE_VERSION, [], '', 9, 'C'
325
350
  end
326
351
 
327
352
  # .. note::
@@ -346,7 +371,7 @@ module Tinkerforge
346
371
  # the distance to something with a very high reflection (e.g. mirror). Set this to 0 to
347
372
  # use the default algorithm. The other allowed values are 1-255.
348
373
  #
349
- # Set the **Measurement Frequency** in Hz to force a fixed measurement rate. If set to 0,
374
+ # Set the **Measurement Frequency** to force a fixed measurement rate. If set to 0,
350
375
  # the Laser Range Finder Bricklet will use the optimal frequency according to the other
351
376
  # configurations and the actual measured distance. Since the rate is not fixed in this case,
352
377
  # the velocity measurement is not stable. For a stable velocity measurement you should
@@ -354,31 +379,34 @@ module Tinkerforge
354
379
  # of the calculated velocity. The allowed values are 10Hz-500Hz (and 0 to turn the fixed
355
380
  # frequency off).
356
381
  #
357
- # The default values for Acquisition Count, Enable Quick Termination, Threshold Value and
358
- # Measurement Frequency are 128, false, 0 and 0.
359
- #
360
382
  # .. versionadded:: 2.0.3$nbsp;(Plugin)
361
383
  def set_configuration(acquisition_count, enable_quick_termination, threshold_value, measurement_frequency)
362
- send_request FUNCTION_SET_CONFIGURATION, [acquisition_count, enable_quick_termination, threshold_value, measurement_frequency], 'C ? C S', 0, ''
384
+ check_validity
385
+
386
+ send_request FUNCTION_SET_CONFIGURATION, [acquisition_count, enable_quick_termination, threshold_value, measurement_frequency], 'C ? C S', 8, ''
363
387
  end
364
388
 
365
389
  # Returns the configuration as set by BrickletLaserRangeFinder#set_configuration.
366
390
  #
367
391
  # .. versionadded:: 2.0.3$nbsp;(Plugin)
368
392
  def get_configuration
369
- send_request FUNCTION_GET_CONFIGURATION, [], '', 5, 'C ? C S'
393
+ check_validity
394
+
395
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 13, 'C ? C S'
370
396
  end
371
397
 
372
398
  # Returns the UID, the UID where the Bricklet is connected to,
373
399
  # the position, the hardware and firmware version as well as the
374
400
  # device identifier.
375
401
  #
376
- # The position can be 'a', 'b', 'c' or 'd'.
402
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
403
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
404
+ # position 'z'.
377
405
  #
378
406
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
379
407
  # |device_identifier_constant|
380
408
  def get_identity
381
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
409
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
382
410
  end
383
411
 
384
412
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.