tinkerforge 2.1.24 → 2.1.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +155 -74
  3. data/lib/tinkerforge/brick_hat.rb +70 -30
  4. data/lib/tinkerforge/brick_hat_zero.rb +56 -22
  5. data/lib/tinkerforge/brick_imu.rb +184 -77
  6. data/lib/tinkerforge/brick_imu_v2.rb +208 -105
  7. data/lib/tinkerforge/brick_master.rb +484 -182
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +185 -101
  10. data/lib/tinkerforge/brick_silent_stepper.rb +246 -166
  11. data/lib/tinkerforge/brick_stepper.rb +210 -98
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +58 -23
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +105 -54
  14. data/lib/tinkerforge/bricklet_air_quality.rb +117 -59
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +51 -21
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +40 -22
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -25
  18. data/lib/tinkerforge/bricklet_analog_in.rb +63 -25
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +57 -23
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +67 -25
  21. data/lib/tinkerforge/bricklet_analog_out.rb +23 -9
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +20 -8
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +54 -20
  24. data/lib/tinkerforge/bricklet_barometer.rb +66 -26
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +99 -37
  26. data/lib/tinkerforge/bricklet_can.rb +83 -18
  27. data/lib/tinkerforge/bricklet_can_v2.rb +172 -38
  28. data/lib/tinkerforge/bricklet_co2.rb +34 -14
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +97 -37
  30. data/lib/tinkerforge/bricklet_color.rb +69 -27
  31. data/lib/tinkerforge/bricklet_color_v2.rb +87 -33
  32. data/lib/tinkerforge/bricklet_compass.rb +78 -30
  33. data/lib/tinkerforge/bricklet_current12.rb +58 -24
  34. data/lib/tinkerforge/bricklet_current25.rb +58 -24
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +57 -23
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +83 -31
  37. data/lib/tinkerforge/bricklet_distance_us.rb +40 -16
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +67 -25
  39. data/lib/tinkerforge/bricklet_dmx.rb +88 -34
  40. data/lib/tinkerforge/bricklet_dual_button.rb +24 -10
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -24
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -11
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +40 -16
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +88 -32
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +73 -27
  46. data/lib/tinkerforge/bricklet_gps.rb +64 -26
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +117 -47
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -23
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +71 -27
  50. data/lib/tinkerforge/bricklet_humidity.rb +51 -21
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +83 -31
  52. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +38 -14
  53. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +81 -29
  54. data/lib/tinkerforge/bricklet_industrial_counter.rb +101 -39
  55. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +45 -17
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +77 -29
  57. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -14
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +73 -27
  59. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +40 -16
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +49 -19
  62. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +82 -30
  63. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +61 -23
  64. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -14
  65. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -25
  66. data/lib/tinkerforge/bricklet_io16.rb +55 -21
  67. data/lib/tinkerforge/bricklet_io16_v2.rb +90 -34
  68. data/lib/tinkerforge/bricklet_io4.rb +55 -23
  69. data/lib/tinkerforge/bricklet_io4_v2.rb +96 -36
  70. data/lib/tinkerforge/bricklet_isolator.rb +72 -28
  71. data/lib/tinkerforge/bricklet_joystick.rb +59 -25
  72. data/lib/tinkerforge/bricklet_joystick_v2.rb +68 -26
  73. data/lib/tinkerforge/bricklet_laser_range_finder.rb +82 -32
  74. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +96 -36
  75. data/lib/tinkerforge/bricklet_lcd_128x64.rb +192 -70
  76. data/lib/tinkerforge/bricklet_lcd_16x2.rb +45 -18
  77. data/lib/tinkerforge/bricklet_lcd_20x4.rb +58 -23
  78. data/lib/tinkerforge/bricklet_led_strip.rb +60 -22
  79. data/lib/tinkerforge/bricklet_led_strip_v2.rb +91 -46
  80. data/lib/tinkerforge/bricklet_line.rb +34 -14
  81. data/lib/tinkerforge/bricklet_linear_poti.rb +51 -21
  82. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -21
  83. data/lib/tinkerforge/bricklet_load_cell.rb +61 -23
  84. data/lib/tinkerforge/bricklet_load_cell_v2.rb +80 -30
  85. data/lib/tinkerforge/bricklet_moisture.rb +40 -16
  86. data/lib/tinkerforge/bricklet_motion_detector.rb +22 -10
  87. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -24
  88. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -27
  89. data/lib/tinkerforge/bricklet_multi_touch.rb +31 -13
  90. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -28
  91. data/lib/tinkerforge/bricklet_nfc.rb +123 -58
  92. data/lib/tinkerforge/bricklet_nfc_rfid.rb +33 -13
  93. data/lib/tinkerforge/bricklet_oled_128x64.rb +29 -11
  94. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +66 -24
  95. data/lib/tinkerforge/bricklet_oled_64x48.rb +29 -11
  96. data/lib/tinkerforge/bricklet_one_wire.rb +66 -24
  97. data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -27
  98. data/lib/tinkerforge/bricklet_particulate_matter.rb +75 -30
  99. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -9
  100. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -10
  101. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +80 -42
  102. data/lib/tinkerforge/bricklet_ptc.rb +74 -42
  103. data/lib/tinkerforge/bricklet_ptc_v2.rb +95 -48
  104. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -33
  105. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -44
  106. data/lib/tinkerforge/bricklet_remote_switch.rb +39 -29
  107. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +87 -49
  108. data/lib/tinkerforge/bricklet_rgb_led.rb +18 -8
  109. data/lib/tinkerforge/bricklet_rgb_led_button.rb +62 -30
  110. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +79 -33
  111. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +52 -20
  112. data/lib/tinkerforge/bricklet_rotary_encoder.rb +39 -19
  113. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -24
  114. data/lib/tinkerforge/bricklet_rotary_poti.rb +53 -28
  115. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -23
  116. data/lib/tinkerforge/bricklet_rs232.rb +90 -28
  117. data/lib/tinkerforge/bricklet_rs232_v2.rb +118 -44
  118. data/lib/tinkerforge/bricklet_rs485.rb +223 -95
  119. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +25 -14
  120. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -35
  121. data/lib/tinkerforge/bricklet_solid_state_relay.rb +25 -13
  122. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +59 -25
  123. data/lib/tinkerforge/bricklet_sound_intensity.rb +35 -18
  124. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +72 -31
  125. data/lib/tinkerforge/bricklet_temperature.rb +40 -16
  126. data/lib/tinkerforge/bricklet_temperature_ir.rb +57 -23
  127. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +71 -27
  128. data/lib/tinkerforge/bricklet_temperature_v2.rb +61 -25
  129. data/lib/tinkerforge/bricklet_thermal_imaging.rb +105 -44
  130. data/lib/tinkerforge/bricklet_thermocouple.rb +45 -24
  131. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -27
  132. data/lib/tinkerforge/bricklet_tilt.rb +24 -10
  133. data/lib/tinkerforge/bricklet_uv_light.rb +36 -18
  134. data/lib/tinkerforge/bricklet_uv_light_v2.rb +85 -37
  135. data/lib/tinkerforge/bricklet_voltage.rb +52 -28
  136. data/lib/tinkerforge/bricklet_voltage_current.rb +91 -73
  137. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +90 -68
  138. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +80 -30
  139. data/lib/tinkerforge/device_display_names.rb +163 -0
  140. data/lib/tinkerforge/ip_connection.rb +151 -32
  141. data/lib/tinkerforge/version.rb +1 -1
  142. metadata +3 -2
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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 150cm with infrared light
14
16
  class BrickletDistanceIRV2 < Device
@@ -83,7 +85,7 @@ module Tinkerforge
83
85
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
84
86
  # the IP Connection <tt>ipcon</tt>.
85
87
  def initialize(uid, ipcon)
86
- super uid, ipcon
88
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
87
89
 
88
90
  @api_version = [2, 0, 1]
89
91
 
@@ -112,9 +114,10 @@ module Tinkerforge
112
114
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
113
115
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
114
116
 
115
- @callback_formats[CALLBACK_DISTANCE] = 'S'
116
- @callback_formats[CALLBACK_ANALOG_VALUE] = 'L'
117
+ @callback_formats[CALLBACK_DISTANCE] = [10, 'S']
118
+ @callback_formats[CALLBACK_ANALOG_VALUE] = [12, 'L']
117
119
 
120
+ @ipcon.add_device self
118
121
  end
119
122
 
120
123
  # Returns the distance measured by the sensor. Possible
@@ -126,7 +129,9 @@ module Tinkerforge
126
129
  # CALLBACK_DISTANCE callback. You can set the callback configuration
127
130
  # with BrickletDistanceIRV2#set_distance_callback_configuration.
128
131
  def get_distance
129
- send_request FUNCTION_GET_DISTANCE, [], '', 2, 'S'
132
+ check_validity
133
+
134
+ send_request FUNCTION_GET_DISTANCE, [], '', 10, 'S'
130
135
  end
131
136
 
132
137
  # The period is the period with which the CALLBACK_DISTANCE callback is triggered
@@ -155,12 +160,16 @@ module Tinkerforge
155
160
  #
156
161
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
157
162
  def set_distance_callback_configuration(period, value_has_to_change, option, min, max)
158
- send_request FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 0, ''
163
+ check_validity
164
+
165
+ send_request FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 8, ''
159
166
  end
160
167
 
161
168
  # Returns the callback configuration as set by BrickletDistanceIRV2#set_distance_callback_configuration.
162
169
  def get_distance_callback_configuration
163
- send_request FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k S S'
170
+ check_validity
171
+
172
+ send_request FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k S S'
164
173
  end
165
174
 
166
175
  # Returns the analog value as read by a analog-to-digital converter.
@@ -177,7 +186,9 @@ module Tinkerforge
177
186
  # CALLBACK_ANALOG_VALUE callback. You can set the callback configuration
178
187
  # with BrickletDistanceIRV2#set_analog_value_callback_configuration.
179
188
  def get_analog_value
180
- send_request FUNCTION_GET_ANALOG_VALUE, [], '', 4, 'L'
189
+ check_validity
190
+
191
+ send_request FUNCTION_GET_ANALOG_VALUE, [], '', 12, 'L'
181
192
  end
182
193
 
183
194
  # The period is the period with which the CALLBACK_ANALOG_VALUE callback is triggered
@@ -206,12 +217,16 @@ module Tinkerforge
206
217
  #
207
218
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
208
219
  def set_analog_value_callback_configuration(period, value_has_to_change, option, min, max)
209
- send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k L L', 0, ''
220
+ check_validity
221
+
222
+ send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k L L', 8, ''
210
223
  end
211
224
 
212
225
  # Returns the callback configuration as set by BrickletDistanceIRV2#set_analog_value_callback_configuration.
213
226
  def get_analog_value_callback_configuration
214
- send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_CONFIGURATION, [], '', 14, 'L ? k L L'
227
+ check_validity
228
+
229
+ send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k L L'
215
230
  end
216
231
 
217
232
  # Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
@@ -224,23 +239,31 @@ module Tinkerforge
224
239
  # resulting averaging window has a length of approximately 10s. If you want to do
225
240
  # long term measurements the longest moving average will give the cleanest results.
226
241
  def set_moving_average_configuration(moving_average_length)
227
- send_request FUNCTION_SET_MOVING_AVERAGE_CONFIGURATION, [moving_average_length], 'S', 0, ''
242
+ check_validity
243
+
244
+ send_request FUNCTION_SET_MOVING_AVERAGE_CONFIGURATION, [moving_average_length], 'S', 8, ''
228
245
  end
229
246
 
230
247
  # Returns the moving average configuration as set by BrickletDistanceIRV2#set_moving_average_configuration.
231
248
  def get_moving_average_configuration
232
- send_request FUNCTION_GET_MOVING_AVERAGE_CONFIGURATION, [], '', 2, 'S'
249
+ check_validity
250
+
251
+ send_request FUNCTION_GET_MOVING_AVERAGE_CONFIGURATION, [], '', 10, 'S'
233
252
  end
234
253
 
235
254
  # Configures the distance LED to be either turned off, turned on, blink in
236
255
  # heartbeat mode or show the distance (brighter = object is nearer).
237
256
  def set_distance_led_config(config)
238
- send_request FUNCTION_SET_DISTANCE_LED_CONFIG, [config], 'C', 0, ''
257
+ check_validity
258
+
259
+ send_request FUNCTION_SET_DISTANCE_LED_CONFIG, [config], 'C', 8, ''
239
260
  end
240
261
 
241
262
  # Returns the LED configuration as set by BrickletDistanceIRV2#set_distance_led_config
242
263
  def get_distance_led_config
243
- send_request FUNCTION_GET_DISTANCE_LED_CONFIG, [], '', 1, 'C'
264
+ check_validity
265
+
266
+ send_request FUNCTION_GET_DISTANCE_LED_CONFIG, [], '', 9, 'C'
244
267
  end
245
268
 
246
269
  # Sets the sensor type.
@@ -252,12 +275,16 @@ module Tinkerforge
252
275
  # If you want to change the sensor you can set the type in Brick Viewer,
253
276
  # you will likely never need to call this function from your program.
254
277
  def set_sensor_type(sensor)
255
- send_request FUNCTION_SET_SENSOR_TYPE, [sensor], 'C', 0, ''
278
+ check_validity
279
+
280
+ send_request FUNCTION_SET_SENSOR_TYPE, [sensor], 'C', 8, ''
256
281
  end
257
282
 
258
283
  # Returns the sensor type as set by BrickletDistanceIRV2#set_sensor_type.
259
284
  def get_sensor_type
260
- send_request FUNCTION_GET_SENSOR_TYPE, [], '', 1, 'C'
285
+ check_validity
286
+
287
+ send_request FUNCTION_GET_SENSOR_TYPE, [], '', 9, 'C'
261
288
  end
262
289
 
263
290
  # Returns the error count for the communication between Brick and Bricklet.
@@ -272,7 +299,9 @@ module Tinkerforge
272
299
  # The errors counts are for errors that occur on the Bricklet side. All
273
300
  # Bricks have a similar function that returns the errors on the Brick side.
274
301
  def get_spitfp_error_count
275
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
302
+ check_validity
303
+
304
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
276
305
  end
277
306
 
278
307
  # Sets the bootloader mode and returns the status after the requested
@@ -285,12 +314,16 @@ module Tinkerforge
285
314
  # This function is used by Brick Viewer during flashing. It should not be
286
315
  # necessary to call it in a normal user program.
287
316
  def set_bootloader_mode(mode)
288
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
317
+ check_validity
318
+
319
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
289
320
  end
290
321
 
291
322
  # Returns the current bootloader mode, see BrickletDistanceIRV2#set_bootloader_mode.
292
323
  def get_bootloader_mode
293
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
324
+ check_validity
325
+
326
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
294
327
  end
295
328
 
296
329
  # Sets the firmware pointer for BrickletDistanceIRV2#write_firmware. The pointer has
@@ -300,7 +333,9 @@ module Tinkerforge
300
333
  # This function is used by Brick Viewer during flashing. It should not be
301
334
  # necessary to call it in a normal user program.
302
335
  def set_write_firmware_pointer(pointer)
303
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
336
+ check_validity
337
+
338
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
304
339
  end
305
340
 
306
341
  # Writes 64 Bytes of firmware at the position as written by
@@ -312,7 +347,9 @@ module Tinkerforge
312
347
  # This function is used by Brick Viewer during flashing. It should not be
313
348
  # necessary to call it in a normal user program.
314
349
  def write_firmware(data)
315
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
350
+ check_validity
351
+
352
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
316
353
  end
317
354
 
318
355
  # Sets the status LED configuration. By default the LED shows
@@ -323,22 +360,28 @@ module Tinkerforge
323
360
  #
324
361
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
325
362
  def set_status_led_config(config)
326
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
363
+ check_validity
364
+
365
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
327
366
  end
328
367
 
329
368
  # Returns the configuration as set by BrickletDistanceIRV2#set_status_led_config
330
369
  def get_status_led_config
331
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
370
+ check_validity
371
+
372
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
332
373
  end
333
374
 
334
- # Returns the temperature in °C as measured inside the microcontroller. The
375
+ # Returns the temperature as measured inside the microcontroller. The
335
376
  # value returned is not the ambient temperature!
336
377
  #
337
378
  # The temperature is only proportional to the real temperature and it has bad
338
379
  # accuracy. Practically it is only useful as an indicator for
339
380
  # temperature changes.
340
381
  def get_chip_temperature
341
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
382
+ check_validity
383
+
384
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
342
385
  end
343
386
 
344
387
  # Calling this function will reset the Bricklet. All configurations
@@ -348,7 +391,9 @@ module Tinkerforge
348
391
  # calling functions on the existing ones will result in
349
392
  # undefined behavior!
350
393
  def reset
351
- send_request FUNCTION_RESET, [], '', 0, ''
394
+ check_validity
395
+
396
+ send_request FUNCTION_RESET, [], '', 8, ''
352
397
  end
353
398
 
354
399
  # Writes a new UID into flash. If you want to set a new UID
@@ -357,25 +402,32 @@ module Tinkerforge
357
402
  #
358
403
  # We recommend that you use Brick Viewer to change the UID.
359
404
  def write_uid(uid)
360
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
405
+ check_validity
406
+
407
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
361
408
  end
362
409
 
363
410
  # Returns the current UID as an integer. Encode as
364
411
  # Base58 to get the usual string version.
365
412
  def read_uid
366
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
413
+ check_validity
414
+
415
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
367
416
  end
368
417
 
369
418
  # Returns the UID, the UID where the Bricklet is connected to,
370
419
  # the position, the hardware and firmware version as well as the
371
420
  # device identifier.
372
421
  #
373
- # The position can be 'a', 'b', 'c' or 'd'.
422
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
423
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
424
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
425
+ # position 'z'.
374
426
  #
375
427
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
376
428
  # |device_identifier_constant|
377
429
  def get_identity
378
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
430
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
379
431
  end
380
432
 
381
433
  # 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-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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 between 2cm and 400cm with ultrasound
14
16
  class BrickletDistanceUS < Device
@@ -51,7 +53,7 @@ module Tinkerforge
51
53
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
52
54
  # the IP Connection <tt>ipcon</tt>.
53
55
  def initialize(uid, ipcon)
54
- super uid, ipcon
56
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
55
57
 
56
58
  @api_version = [2, 0, 1]
57
59
 
@@ -66,9 +68,10 @@ module Tinkerforge
66
68
  @response_expected[FUNCTION_GET_MOVING_AVERAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
67
69
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
68
70
 
69
- @callback_formats[CALLBACK_DISTANCE] = 'S'
70
- @callback_formats[CALLBACK_DISTANCE_REACHED] = 'S'
71
+ @callback_formats[CALLBACK_DISTANCE] = [10, 'S']
72
+ @callback_formats[CALLBACK_DISTANCE_REACHED] = [10, 'S']
71
73
 
74
+ @ipcon.add_device self
72
75
  end
73
76
 
74
77
  # Returns the current distance value measured by the sensor.
@@ -82,7 +85,9 @@ module Tinkerforge
82
85
  # use the CALLBACK_DISTANCE callback and set the period with
83
86
  # BrickletDistanceUS#set_distance_callback_period.
84
87
  def get_distance_value
85
- send_request FUNCTION_GET_DISTANCE_VALUE, [], '', 2, 'S'
88
+ check_validity
89
+
90
+ send_request FUNCTION_GET_DISTANCE_VALUE, [], '', 10, 'S'
86
91
  end
87
92
 
88
93
  # Sets the period with which the CALLBACK_DISTANCE callback is triggered
@@ -91,12 +96,16 @@ module Tinkerforge
91
96
  # Der CALLBACK_DISTANCE callback is only triggered if the distance value has changed
92
97
  # since the last triggering.
93
98
  def set_distance_callback_period(period)
94
- send_request FUNCTION_SET_DISTANCE_CALLBACK_PERIOD, [period], 'L', 0, ''
99
+ check_validity
100
+
101
+ send_request FUNCTION_SET_DISTANCE_CALLBACK_PERIOD, [period], 'L', 8, ''
95
102
  end
96
103
 
97
104
  # Returns the period as set by BrickletDistanceUS#set_distance_callback_period.
98
105
  def get_distance_callback_period
99
- send_request FUNCTION_GET_DISTANCE_CALLBACK_PERIOD, [], '', 4, 'L'
106
+ check_validity
107
+
108
+ send_request FUNCTION_GET_DISTANCE_CALLBACK_PERIOD, [], '', 12, 'L'
100
109
  end
101
110
 
102
111
  # Sets the thresholds for the CALLBACK_DISTANCE_REACHED callback.
@@ -111,12 +120,16 @@ module Tinkerforge
111
120
  # "'<'", "Callback is triggered when the distance value is smaller than the min value (max is ignored)"
112
121
  # "'>'", "Callback is triggered when the distance value is greater than the min value (max is ignored)"
113
122
  def set_distance_callback_threshold(option, min, max)
114
- send_request FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 0, ''
123
+ check_validity
124
+
125
+ send_request FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
115
126
  end
116
127
 
117
128
  # Returns the threshold as set by BrickletDistanceUS#set_distance_callback_threshold.
118
129
  def get_distance_callback_threshold
119
- send_request FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD, [], '', 5, 'k S S'
130
+ check_validity
131
+
132
+ send_request FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
120
133
  end
121
134
 
122
135
  # Sets the period with which the threshold callbacks
@@ -129,12 +142,16 @@ module Tinkerforge
129
142
  #
130
143
  # keep being reached.
131
144
  def set_debounce_period(debounce)
132
- send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 0, ''
145
+ check_validity
146
+
147
+ send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
133
148
  end
134
149
 
135
150
  # Returns the debounce period as set by BrickletDistanceUS#set_debounce_period.
136
151
  def get_debounce_period
137
- send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 4, 'L'
152
+ check_validity
153
+
154
+ send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
138
155
  end
139
156
 
140
157
  # Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
@@ -143,24 +160,31 @@ module Tinkerforge
143
160
  # Setting the length to 0 will turn the averaging completely off. With less
144
161
  # averaging, there is more noise on the data.
145
162
  def set_moving_average(average)
146
- send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'C', 0, ''
163
+ check_validity
164
+
165
+ send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'C', 8, ''
147
166
  end
148
167
 
149
168
  # Returns the length moving average as set by BrickletDistanceUS#set_moving_average.
150
169
  def get_moving_average
151
- send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 1, 'C'
170
+ check_validity
171
+
172
+ send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 9, 'C'
152
173
  end
153
174
 
154
175
  # Returns the UID, the UID where the Bricklet is connected to,
155
176
  # the position, the hardware and firmware version as well as the
156
177
  # device identifier.
157
178
  #
158
- # The position can be 'a', 'b', 'c' or 'd'.
179
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
180
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
181
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
182
+ # position 'z'.
159
183
  #
160
184
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
161
185
  # |device_identifier_constant|
162
186
  def get_identity
163
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
187
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
164
188
  end
165
189
 
166
190
  # 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-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
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 between 30cm and 500cm with ultrasound
14
16
  class BrickletDistanceUSV2 < Device
@@ -71,7 +73,7 @@ module Tinkerforge
71
73
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
72
74
  # the IP Connection <tt>ipcon</tt>.
73
75
  def initialize(uid, ipcon)
74
- super uid, ipcon
76
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
75
77
 
76
78
  @api_version = [2, 0, 0]
77
79
 
@@ -95,8 +97,9 @@ module Tinkerforge
95
97
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
96
98
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
97
99
 
98
- @callback_formats[CALLBACK_DISTANCE] = 'S'
100
+ @callback_formats[CALLBACK_DISTANCE] = [10, 'S']
99
101
 
102
+ @ipcon.add_device self
100
103
  end
101
104
 
102
105
  # Returns the distance.
@@ -106,7 +109,9 @@ module Tinkerforge
106
109
  # CALLBACK_DISTANCE callback. You can set the callback configuration
107
110
  # with BrickletDistanceUSV2#set_distance_callback_configuration.
108
111
  def get_distance
109
- send_request FUNCTION_GET_DISTANCE, [], '', 2, 'S'
112
+ check_validity
113
+
114
+ send_request FUNCTION_GET_DISTANCE, [], '', 10, 'S'
110
115
  end
111
116
 
112
117
  # The period is the period with which the CALLBACK_DISTANCE callback is triggered
@@ -135,12 +140,16 @@ module Tinkerforge
135
140
  #
136
141
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
137
142
  def set_distance_callback_configuration(period, value_has_to_change, option, min, max)
138
- send_request FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 0, ''
143
+ check_validity
144
+
145
+ send_request FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 8, ''
139
146
  end
140
147
 
141
148
  # Returns the callback configuration as set by BrickletDistanceUSV2#set_distance_callback_configuration.
142
149
  def get_distance_callback_configuration
143
- send_request FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k S S'
150
+ check_validity
151
+
152
+ send_request FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k S S'
144
153
  end
145
154
 
146
155
  # Sets the update rate to 2 Hz or 10 Hz.
@@ -148,23 +157,31 @@ module Tinkerforge
148
157
  # With 2 Hz update rate the noise is about ±1mm, while with 10 Hz update rate the noise
149
158
  # increases to about ±5mm.
150
159
  def set_update_rate(update_rate)
151
- send_request FUNCTION_SET_UPDATE_RATE, [update_rate], 'C', 0, ''
160
+ check_validity
161
+
162
+ send_request FUNCTION_SET_UPDATE_RATE, [update_rate], 'C', 8, ''
152
163
  end
153
164
 
154
165
  # Returns the update rate as set by BrickletDistanceUSV2#set_update_rate.
155
166
  def get_update_rate
156
- send_request FUNCTION_GET_UPDATE_RATE, [], '', 1, 'C'
167
+ check_validity
168
+
169
+ send_request FUNCTION_GET_UPDATE_RATE, [], '', 9, 'C'
157
170
  end
158
171
 
159
172
  # Configures the distance LED to be either turned off, turned on, blink in
160
173
  # heartbeat mode or show the distance (brighter = object is nearer).
161
174
  def set_distance_led_config(config)
162
- send_request FUNCTION_SET_DISTANCE_LED_CONFIG, [config], 'C', 0, ''
175
+ check_validity
176
+
177
+ send_request FUNCTION_SET_DISTANCE_LED_CONFIG, [config], 'C', 8, ''
163
178
  end
164
179
 
165
180
  # Returns the LED configuration as set by BrickletDistanceUSV2#set_distance_led_config
166
181
  def get_distance_led_config
167
- send_request FUNCTION_GET_DISTANCE_LED_CONFIG, [], '', 1, 'C'
182
+ check_validity
183
+
184
+ send_request FUNCTION_GET_DISTANCE_LED_CONFIG, [], '', 9, 'C'
168
185
  end
169
186
 
170
187
  # Returns the error count for the communication between Brick and Bricklet.
@@ -179,7 +196,9 @@ module Tinkerforge
179
196
  # The errors counts are for errors that occur on the Bricklet side. All
180
197
  # Bricks have a similar function that returns the errors on the Brick side.
181
198
  def get_spitfp_error_count
182
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
199
+ check_validity
200
+
201
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
183
202
  end
184
203
 
185
204
  # Sets the bootloader mode and returns the status after the requested
@@ -192,12 +211,16 @@ module Tinkerforge
192
211
  # This function is used by Brick Viewer during flashing. It should not be
193
212
  # necessary to call it in a normal user program.
194
213
  def set_bootloader_mode(mode)
195
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
214
+ check_validity
215
+
216
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
196
217
  end
197
218
 
198
219
  # Returns the current bootloader mode, see BrickletDistanceUSV2#set_bootloader_mode.
199
220
  def get_bootloader_mode
200
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
221
+ check_validity
222
+
223
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
201
224
  end
202
225
 
203
226
  # Sets the firmware pointer for BrickletDistanceUSV2#write_firmware. The pointer has
@@ -207,7 +230,9 @@ module Tinkerforge
207
230
  # This function is used by Brick Viewer during flashing. It should not be
208
231
  # necessary to call it in a normal user program.
209
232
  def set_write_firmware_pointer(pointer)
210
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
233
+ check_validity
234
+
235
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
211
236
  end
212
237
 
213
238
  # Writes 64 Bytes of firmware at the position as written by
@@ -219,7 +244,9 @@ module Tinkerforge
219
244
  # This function is used by Brick Viewer during flashing. It should not be
220
245
  # necessary to call it in a normal user program.
221
246
  def write_firmware(data)
222
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
247
+ check_validity
248
+
249
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
223
250
  end
224
251
 
225
252
  # Sets the status LED configuration. By default the LED shows
@@ -230,22 +257,28 @@ module Tinkerforge
230
257
  #
231
258
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
232
259
  def set_status_led_config(config)
233
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
260
+ check_validity
261
+
262
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
234
263
  end
235
264
 
236
265
  # Returns the configuration as set by BrickletDistanceUSV2#set_status_led_config
237
266
  def get_status_led_config
238
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
267
+ check_validity
268
+
269
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
239
270
  end
240
271
 
241
- # Returns the temperature in °C as measured inside the microcontroller. The
272
+ # Returns the temperature as measured inside the microcontroller. The
242
273
  # value returned is not the ambient temperature!
243
274
  #
244
275
  # The temperature is only proportional to the real temperature and it has bad
245
276
  # accuracy. Practically it is only useful as an indicator for
246
277
  # temperature changes.
247
278
  def get_chip_temperature
248
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
279
+ check_validity
280
+
281
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
249
282
  end
250
283
 
251
284
  # Calling this function will reset the Bricklet. All configurations
@@ -255,7 +288,9 @@ module Tinkerforge
255
288
  # calling functions on the existing ones will result in
256
289
  # undefined behavior!
257
290
  def reset
258
- send_request FUNCTION_RESET, [], '', 0, ''
291
+ check_validity
292
+
293
+ send_request FUNCTION_RESET, [], '', 8, ''
259
294
  end
260
295
 
261
296
  # Writes a new UID into flash. If you want to set a new UID
@@ -264,25 +299,32 @@ module Tinkerforge
264
299
  #
265
300
  # We recommend that you use Brick Viewer to change the UID.
266
301
  def write_uid(uid)
267
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
302
+ check_validity
303
+
304
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
268
305
  end
269
306
 
270
307
  # Returns the current UID as an integer. Encode as
271
308
  # Base58 to get the usual string version.
272
309
  def read_uid
273
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
310
+ check_validity
311
+
312
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
274
313
  end
275
314
 
276
315
  # Returns the UID, the UID where the Bricklet is connected to,
277
316
  # the position, the hardware and firmware version as well as the
278
317
  # device identifier.
279
318
  #
280
- # The position can be 'a', 'b', 'c' or 'd'.
319
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
320
+ # The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
321
+ # connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
322
+ # position 'z'.
281
323
  #
282
324
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
283
325
  # |device_identifier_constant|
284
326
  def get_identity
285
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
327
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
286
328
  end
287
329
 
288
330
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.