tinkerforge 2.1.24 → 2.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
  # Full fledged AHRS with 9 degrees of freedom
14
16
  class BrickIMUV2 < Device
@@ -52,7 +54,7 @@ module Tinkerforge
52
54
 
53
55
  # This callback is triggered periodically with the period that is set by
54
56
  # BrickIMUV2#set_quaternion_period. The parameters are the orientation
55
- # (x, y, z, w) of the IMU Brick in quaternions. See BrickIMUV2#get_quaternion
57
+ # (w, x, y, z) of the IMU Brick in quaternions. See BrickIMUV2#get_quaternion
56
58
  # for details.
57
59
  CALLBACK_QUATERNION = 39
58
60
 
@@ -108,6 +110,8 @@ module Tinkerforge
108
110
  FUNCTION_GET_PROTOCOL1_BRICKLET_NAME = 241 # :nodoc:
109
111
  FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
110
112
  FUNCTION_RESET = 243 # :nodoc:
113
+ FUNCTION_WRITE_BRICKLET_PLUGIN = 246 # :nodoc:
114
+ FUNCTION_READ_BRICKLET_PLUGIN = 247 # :nodoc:
111
115
  FUNCTION_GET_IDENTITY = 255 # :nodoc:
112
116
 
113
117
  MAGNETOMETER_RATE_2HZ = 0 # :nodoc:
@@ -159,7 +163,7 @@ module Tinkerforge
159
163
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
160
164
  # the IP Connection <tt>ipcon</tt>.
161
165
  def initialize(uid, ipcon)
162
- super uid, ipcon
166
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
163
167
 
164
168
  @api_version = [2, 0, 3]
165
169
 
@@ -210,78 +214,88 @@ module Tinkerforge
210
214
  @response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
211
215
  @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
212
216
  @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
217
+ @response_expected[FUNCTION_WRITE_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_FALSE
218
+ @response_expected[FUNCTION_READ_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_ALWAYS_TRUE
213
219
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
214
220
 
215
- @callback_formats[CALLBACK_ACCELERATION] = 's s s'
216
- @callback_formats[CALLBACK_MAGNETIC_FIELD] = 's s s'
217
- @callback_formats[CALLBACK_ANGULAR_VELOCITY] = 's s s'
218
- @callback_formats[CALLBACK_TEMPERATURE] = 'c'
219
- @callback_formats[CALLBACK_LINEAR_ACCELERATION] = 's s s'
220
- @callback_formats[CALLBACK_GRAVITY_VECTOR] = 's s s'
221
- @callback_formats[CALLBACK_ORIENTATION] = 's s s'
222
- @callback_formats[CALLBACK_QUATERNION] = 's s s s'
223
- @callback_formats[CALLBACK_ALL_DATA] = 's3 s3 s3 s3 s4 s3 s3 c C'
221
+ @callback_formats[CALLBACK_ACCELERATION] = [14, 's s s']
222
+ @callback_formats[CALLBACK_MAGNETIC_FIELD] = [14, 's s s']
223
+ @callback_formats[CALLBACK_ANGULAR_VELOCITY] = [14, 's s s']
224
+ @callback_formats[CALLBACK_TEMPERATURE] = [9, 'c']
225
+ @callback_formats[CALLBACK_LINEAR_ACCELERATION] = [14, 's s s']
226
+ @callback_formats[CALLBACK_GRAVITY_VECTOR] = [14, 's s s']
227
+ @callback_formats[CALLBACK_ORIENTATION] = [14, 's s s']
228
+ @callback_formats[CALLBACK_QUATERNION] = [16, 's s s s']
229
+ @callback_formats[CALLBACK_ALL_DATA] = [54, 's3 s3 s3 s3 s4 s3 s3 c C']
224
230
 
231
+ @ipcon.add_device self
225
232
  end
226
233
 
227
234
  # Returns the calibrated acceleration from the accelerometer for the
228
- # x, y and z axis in 1/100 m/s².
235
+ # x, y and z axis. The acceleration is in the range configured with
236
+ # BrickIMUV2#set_sensor_configuration.
229
237
  #
230
238
  # If you want to get the acceleration periodically, it is recommended
231
239
  # to use the CALLBACK_ACCELERATION callback and set the period with
232
240
  # BrickIMUV2#set_acceleration_period.
233
241
  def get_acceleration
234
- send_request FUNCTION_GET_ACCELERATION, [], '', 6, 's s s'
242
+ check_validity
243
+
244
+ send_request FUNCTION_GET_ACCELERATION, [], '', 14, 's s s'
235
245
  end
236
246
 
237
247
  # Returns the calibrated magnetic field from the magnetometer for the
238
- # x, y and z axis in 1/16 µT (Microtesla).
248
+ # x, y and z axis.
239
249
  #
240
250
  # If you want to get the magnetic field periodically, it is recommended
241
251
  # to use the CALLBACK_MAGNETIC_FIELD callback and set the period with
242
252
  # BrickIMUV2#set_magnetic_field_period.
243
253
  def get_magnetic_field
244
- send_request FUNCTION_GET_MAGNETIC_FIELD, [], '', 6, 's s s'
254
+ check_validity
255
+
256
+ send_request FUNCTION_GET_MAGNETIC_FIELD, [], '', 14, 's s s'
245
257
  end
246
258
 
247
259
  # Returns the calibrated angular velocity from the gyroscope for the
248
- # x, y and z axis in 1/16 °/s.
260
+ # x, y and z axis. The angular velocity is in the range configured with
261
+ # BrickIMUV2#set_sensor_configuration.
249
262
  #
250
263
  # If you want to get the angular velocity periodically, it is recommended
251
264
  # to use the CALLBACK_ANGULAR_VELOCITY acallback nd set the period with
252
265
  # BrickIMUV2#set_angular_velocity_period.
253
266
  def get_angular_velocity
254
- send_request FUNCTION_GET_ANGULAR_VELOCITY, [], '', 6, 's s s'
267
+ check_validity
268
+
269
+ send_request FUNCTION_GET_ANGULAR_VELOCITY, [], '', 14, 's s s'
255
270
  end
256
271
 
257
- # Returns the temperature of the IMU Brick. The temperature is given in
258
- # °C. The temperature is measured in the core of the BNO055 IC, it is not the
272
+ # Returns the temperature of the IMU Brick.
273
+ # The temperature is measured in the core of the BNO055 IC, it is not the
259
274
  # ambient temperature
260
275
  def get_temperature
261
- send_request FUNCTION_GET_TEMPERATURE, [], '', 1, 'c'
276
+ check_validity
277
+
278
+ send_request FUNCTION_GET_TEMPERATURE, [], '', 9, 'c'
262
279
  end
263
280
 
264
281
  # Returns the current orientation (heading, roll, pitch) of the IMU Brick as
265
- # independent Euler angles in 1/16 degree. Note that Euler angles always
282
+ # independent Euler angles. Note that Euler angles always
266
283
  # experience a `gimbal lock <https://en.wikipedia.org/wiki/Gimbal_lock>`__.
267
284
  # We recommend that you use quaternions instead, if you need the absolute
268
285
  # orientation.
269
286
  #
270
- # The rotation angle has the following ranges:
271
- #
272
- # * heading: 0° to 360°
273
- # * roll: -90° to +90°
274
- # * pitch: -180° to +180°
275
- #
276
287
  # If you want to get the orientation periodically, it is recommended
277
288
  # to use the CALLBACK_ORIENTATION callback and set the period with
278
289
  # BrickIMUV2#set_orientation_period.
279
290
  def get_orientation
280
- send_request FUNCTION_GET_ORIENTATION, [], '', 6, 's s s'
291
+ check_validity
292
+
293
+ send_request FUNCTION_GET_ORIENTATION, [], '', 14, 's s s'
281
294
  end
282
295
 
283
296
  # Returns the linear acceleration of the IMU Brick for the
284
- # x, y and z axis in 1/100 m/s².
297
+ # x, y and z axis. The acceleration is in the range configured with
298
+ # BrickIMUV2#set_sensor_configuration.
285
299
  #
286
300
  # The linear acceleration is the acceleration in each of the three
287
301
  # axis of the IMU Brick with the influences of gravity removed.
@@ -293,11 +307,13 @@ module Tinkerforge
293
307
  # to use the CALLBACK_LINEAR_ACCELERATION callback and set the period with
294
308
  # BrickIMUV2#set_linear_acceleration_period.
295
309
  def get_linear_acceleration
296
- send_request FUNCTION_GET_LINEAR_ACCELERATION, [], '', 6, 's s s'
310
+ check_validity
311
+
312
+ send_request FUNCTION_GET_LINEAR_ACCELERATION, [], '', 14, 's s s'
297
313
  end
298
314
 
299
315
  # Returns the current gravity vector of the IMU Brick for the
300
- # x, y and z axis in 1/100 m/s².
316
+ # x, y and z axis.
301
317
  #
302
318
  # The gravity vector is the acceleration that occurs due to gravity.
303
319
  # Influences of additional linear acceleration are removed.
@@ -309,7 +325,9 @@ module Tinkerforge
309
325
  # to use the CALLBACK_GRAVITY_VECTOR callback and set the period with
310
326
  # BrickIMUV2#set_gravity_vector_period.
311
327
  def get_gravity_vector
312
- send_request FUNCTION_GET_GRAVITY_VECTOR, [], '', 6, 's s s'
328
+ check_validity
329
+
330
+ send_request FUNCTION_GET_GRAVITY_VECTOR, [], '', 14, 's s s'
313
331
  end
314
332
 
315
333
  # Returns the current orientation (w, x, y, z) of the IMU Brick as
@@ -322,19 +340,21 @@ module Tinkerforge
322
340
  # to use the CALLBACK_QUATERNION callback and set the period with
323
341
  # BrickIMUV2#set_quaternion_period.
324
342
  def get_quaternion
325
- send_request FUNCTION_GET_QUATERNION, [], '', 8, 's s s s'
343
+ check_validity
344
+
345
+ send_request FUNCTION_GET_QUATERNION, [], '', 16, 's s s s'
326
346
  end
327
347
 
328
348
  # Return all of the available data of the IMU Brick.
329
349
  #
330
- # * acceleration in 1/100 m/s² (see BrickIMUV2#get_acceleration)
331
- # * magnetic field in 1/16 µT (see BrickIMUV2#get_magnetic_field)
332
- # * angular velocity in 1/16 °/s (see BrickIMUV2#get_angular_velocity)
333
- # * Euler angles in 1/16 ° (see BrickIMUV2#get_orientation)
334
- # * quaternion 1/16383 (see BrickIMUV2#get_quaternion)
335
- # * linear acceleration 1/100 m/s² (see BrickIMUV2#get_linear_acceleration)
336
- # * gravity vector 1/100 m/s² (see BrickIMUV2#get_gravity_vector)
337
- # * temperature in 1 °C (see BrickIMUV2#get_temperature)
350
+ # * acceleration (see BrickIMUV2#get_acceleration)
351
+ # * magnetic field (see BrickIMUV2#get_magnetic_field)
352
+ # * angular velocity (see BrickIMUV2#get_angular_velocity)
353
+ # * Euler angles (see BrickIMUV2#get_orientation)
354
+ # * quaternion (see BrickIMUV2#get_quaternion)
355
+ # * linear acceleration (see BrickIMUV2#get_linear_acceleration)
356
+ # * gravity vector (see BrickIMUV2#get_gravity_vector)
357
+ # * temperature (see BrickIMUV2#get_temperature)
338
358
  # * calibration status (see below)
339
359
  #
340
360
  # The calibration status consists of four pairs of two bits. Each pair
@@ -356,23 +376,31 @@ module Tinkerforge
356
376
  # to use the CALLBACK_ALL_DATA callback and set the period with
357
377
  # BrickIMUV2#set_all_data_period.
358
378
  def get_all_data
359
- send_request FUNCTION_GET_ALL_DATA, [], '', 46, 's3 s3 s3 s3 s4 s3 s3 c C'
379
+ check_validity
380
+
381
+ send_request FUNCTION_GET_ALL_DATA, [], '', 54, 's3 s3 s3 s3 s4 s3 s3 c C'
360
382
  end
361
383
 
362
384
  # Turns the orientation and direction LEDs of the IMU Brick on.
363
385
  def leds_on
364
- send_request FUNCTION_LEDS_ON, [], '', 0, ''
386
+ check_validity
387
+
388
+ send_request FUNCTION_LEDS_ON, [], '', 8, ''
365
389
  end
366
390
 
367
391
  # Turns the orientation and direction LEDs of the IMU Brick off.
368
392
  def leds_off
369
- send_request FUNCTION_LEDS_OFF, [], '', 0, ''
393
+ check_validity
394
+
395
+ send_request FUNCTION_LEDS_OFF, [], '', 8, ''
370
396
  end
371
397
 
372
398
  # Returns *true* if the orientation and direction LEDs of the IMU Brick
373
399
  # are on, *false* otherwise.
374
400
  def are_leds_on
375
- send_request FUNCTION_ARE_LEDS_ON, [], '', 1, '?'
401
+ check_validity
402
+
403
+ send_request FUNCTION_ARE_LEDS_ON, [], '', 9, '?'
376
404
  end
377
405
 
378
406
  # A call of this function saves the current calibration to be used
@@ -386,130 +414,164 @@ module Tinkerforge
386
414
  # This function is used by the calibration window of the Brick Viewer, you
387
415
  # should not need to call it in your program.
388
416
  def save_calibration
389
- send_request FUNCTION_SAVE_CALIBRATION, [], '', 1, '?'
417
+ check_validity
418
+
419
+ send_request FUNCTION_SAVE_CALIBRATION, [], '', 9, '?'
390
420
  end
391
421
 
392
422
  # Sets the period with which the CALLBACK_ACCELERATION callback is triggered
393
423
  # periodically. A value of 0 turns the callback off.
394
424
  def set_acceleration_period(period)
395
- send_request FUNCTION_SET_ACCELERATION_PERIOD, [period], 'L', 0, ''
425
+ check_validity
426
+
427
+ send_request FUNCTION_SET_ACCELERATION_PERIOD, [period], 'L', 8, ''
396
428
  end
397
429
 
398
430
  # Returns the period as set by BrickIMUV2#set_acceleration_period.
399
431
  def get_acceleration_period
400
- send_request FUNCTION_GET_ACCELERATION_PERIOD, [], '', 4, 'L'
432
+ check_validity
433
+
434
+ send_request FUNCTION_GET_ACCELERATION_PERIOD, [], '', 12, 'L'
401
435
  end
402
436
 
403
437
  # Sets the period with which the CALLBACK_MAGNETIC_FIELD callback is triggered
404
438
  # periodically. A value of 0 turns the callback off.
405
439
  def set_magnetic_field_period(period)
406
- send_request FUNCTION_SET_MAGNETIC_FIELD_PERIOD, [period], 'L', 0, ''
440
+ check_validity
441
+
442
+ send_request FUNCTION_SET_MAGNETIC_FIELD_PERIOD, [period], 'L', 8, ''
407
443
  end
408
444
 
409
445
  # Returns the period as set by BrickIMUV2#set_magnetic_field_period.
410
446
  def get_magnetic_field_period
411
- send_request FUNCTION_GET_MAGNETIC_FIELD_PERIOD, [], '', 4, 'L'
447
+ check_validity
448
+
449
+ send_request FUNCTION_GET_MAGNETIC_FIELD_PERIOD, [], '', 12, 'L'
412
450
  end
413
451
 
414
452
  # Sets the period with which the CALLBACK_ANGULAR_VELOCITY callback is
415
453
  # triggered periodically. A value of 0 turns the callback off.
416
454
  def set_angular_velocity_period(period)
417
- send_request FUNCTION_SET_ANGULAR_VELOCITY_PERIOD, [period], 'L', 0, ''
455
+ check_validity
456
+
457
+ send_request FUNCTION_SET_ANGULAR_VELOCITY_PERIOD, [period], 'L', 8, ''
418
458
  end
419
459
 
420
460
  # Returns the period as set by BrickIMUV2#set_angular_velocity_period.
421
461
  def get_angular_velocity_period
422
- send_request FUNCTION_GET_ANGULAR_VELOCITY_PERIOD, [], '', 4, 'L'
462
+ check_validity
463
+
464
+ send_request FUNCTION_GET_ANGULAR_VELOCITY_PERIOD, [], '', 12, 'L'
423
465
  end
424
466
 
425
467
  # Sets the period with which the CALLBACK_TEMPERATURE callback is triggered
426
468
  # periodically. A value of 0 turns the callback off.
427
469
  def set_temperature_period(period)
428
- send_request FUNCTION_SET_TEMPERATURE_PERIOD, [period], 'L', 0, ''
470
+ check_validity
471
+
472
+ send_request FUNCTION_SET_TEMPERATURE_PERIOD, [period], 'L', 8, ''
429
473
  end
430
474
 
431
475
  # Returns the period as set by BrickIMUV2#set_temperature_period.
432
476
  def get_temperature_period
433
- send_request FUNCTION_GET_TEMPERATURE_PERIOD, [], '', 4, 'L'
477
+ check_validity
478
+
479
+ send_request FUNCTION_GET_TEMPERATURE_PERIOD, [], '', 12, 'L'
434
480
  end
435
481
 
436
482
  # Sets the period with which the CALLBACK_ORIENTATION callback is triggered
437
483
  # periodically. A value of 0 turns the callback off.
438
484
  def set_orientation_period(period)
439
- send_request FUNCTION_SET_ORIENTATION_PERIOD, [period], 'L', 0, ''
485
+ check_validity
486
+
487
+ send_request FUNCTION_SET_ORIENTATION_PERIOD, [period], 'L', 8, ''
440
488
  end
441
489
 
442
490
  # Returns the period as set by BrickIMUV2#set_orientation_period.
443
491
  def get_orientation_period
444
- send_request FUNCTION_GET_ORIENTATION_PERIOD, [], '', 4, 'L'
492
+ check_validity
493
+
494
+ send_request FUNCTION_GET_ORIENTATION_PERIOD, [], '', 12, 'L'
445
495
  end
446
496
 
447
497
  # Sets the period with which the CALLBACK_LINEAR_ACCELERATION callback is
448
498
  # triggered periodically. A value of 0 turns the callback off.
449
499
  def set_linear_acceleration_period(period)
450
- send_request FUNCTION_SET_LINEAR_ACCELERATION_PERIOD, [period], 'L', 0, ''
500
+ check_validity
501
+
502
+ send_request FUNCTION_SET_LINEAR_ACCELERATION_PERIOD, [period], 'L', 8, ''
451
503
  end
452
504
 
453
505
  # Returns the period as set by BrickIMUV2#set_linear_acceleration_period.
454
506
  def get_linear_acceleration_period
455
- send_request FUNCTION_GET_LINEAR_ACCELERATION_PERIOD, [], '', 4, 'L'
507
+ check_validity
508
+
509
+ send_request FUNCTION_GET_LINEAR_ACCELERATION_PERIOD, [], '', 12, 'L'
456
510
  end
457
511
 
458
512
  # Sets the period with which the CALLBACK_GRAVITY_VECTOR callback is triggered
459
513
  # periodically. A value of 0 turns the callback off.
460
514
  def set_gravity_vector_period(period)
461
- send_request FUNCTION_SET_GRAVITY_VECTOR_PERIOD, [period], 'L', 0, ''
515
+ check_validity
516
+
517
+ send_request FUNCTION_SET_GRAVITY_VECTOR_PERIOD, [period], 'L', 8, ''
462
518
  end
463
519
 
464
520
  # Returns the period as set by BrickIMUV2#set_gravity_vector_period.
465
521
  def get_gravity_vector_period
466
- send_request FUNCTION_GET_GRAVITY_VECTOR_PERIOD, [], '', 4, 'L'
522
+ check_validity
523
+
524
+ send_request FUNCTION_GET_GRAVITY_VECTOR_PERIOD, [], '', 12, 'L'
467
525
  end
468
526
 
469
527
  # Sets the period with which the CALLBACK_QUATERNION callback is triggered
470
528
  # periodically. A value of 0 turns the callback off.
471
529
  def set_quaternion_period(period)
472
- send_request FUNCTION_SET_QUATERNION_PERIOD, [period], 'L', 0, ''
530
+ check_validity
531
+
532
+ send_request FUNCTION_SET_QUATERNION_PERIOD, [period], 'L', 8, ''
473
533
  end
474
534
 
475
535
  # Returns the period as set by BrickIMUV2#set_quaternion_period.
476
536
  def get_quaternion_period
477
- send_request FUNCTION_GET_QUATERNION_PERIOD, [], '', 4, 'L'
537
+ check_validity
538
+
539
+ send_request FUNCTION_GET_QUATERNION_PERIOD, [], '', 12, 'L'
478
540
  end
479
541
 
480
542
  # Sets the period with which the CALLBACK_ALL_DATA callback is triggered
481
543
  # periodically. A value of 0 turns the callback off.
482
544
  def set_all_data_period(period)
483
- send_request FUNCTION_SET_ALL_DATA_PERIOD, [period], 'L', 0, ''
545
+ check_validity
546
+
547
+ send_request FUNCTION_SET_ALL_DATA_PERIOD, [period], 'L', 8, ''
484
548
  end
485
549
 
486
550
  # Returns the period as set by BrickIMUV2#set_all_data_period.
487
551
  def get_all_data_period
488
- send_request FUNCTION_GET_ALL_DATA_PERIOD, [], '', 4, 'L'
552
+ check_validity
553
+
554
+ send_request FUNCTION_GET_ALL_DATA_PERIOD, [], '', 12, 'L'
489
555
  end
490
556
 
491
557
  # Sets the available sensor configuration for the Magnetometer, Gyroscope and
492
558
  # Accelerometer. The Accelerometer Range is user selectable in all fusion modes,
493
559
  # all other configurations are auto-controlled in fusion mode.
494
560
  #
495
- # The default values are:
496
- #
497
- # * Magnetometer Rate 20Hz
498
- # * Gyroscope Range 2000°/s
499
- # * Gyroscope Bandwidth 32Hz
500
- # * Accelerometer Range +/-4G
501
- # * Accelerometer Bandwidth 62.5Hz
502
- #
503
561
  # .. versionadded:: 2.0.5$nbsp;(Firmware)
504
562
  def set_sensor_configuration(magnetometer_rate, gyroscope_range, gyroscope_bandwidth, accelerometer_range, accelerometer_bandwidth)
505
- send_request FUNCTION_SET_SENSOR_CONFIGURATION, [magnetometer_rate, gyroscope_range, gyroscope_bandwidth, accelerometer_range, accelerometer_bandwidth], 'C C C C C', 0, ''
563
+ check_validity
564
+
565
+ send_request FUNCTION_SET_SENSOR_CONFIGURATION, [magnetometer_rate, gyroscope_range, gyroscope_bandwidth, accelerometer_range, accelerometer_bandwidth], 'C C C C C', 8, ''
506
566
  end
507
567
 
508
568
  # Returns the sensor configuration as set by BrickIMUV2#set_sensor_configuration.
509
569
  #
510
570
  # .. versionadded:: 2.0.5$nbsp;(Firmware)
511
571
  def get_sensor_configuration
512
- send_request FUNCTION_GET_SENSOR_CONFIGURATION, [], '', 5, 'C C C C C'
572
+ check_validity
573
+
574
+ send_request FUNCTION_GET_SENSOR_CONFIGURATION, [], '', 13, 'C C C C C'
513
575
  end
514
576
 
515
577
  # If the fusion mode is turned off, the functions BrickIMUV2#get_acceleration,
@@ -527,26 +589,28 @@ module Tinkerforge
527
589
  # the first time will likely take longer, but small magnetic influences might
528
590
  # not affect the automatic calibration as much.
529
591
  #
530
- # By default sensor fusion is on.
531
- #
532
592
  # .. versionadded:: 2.0.5$nbsp;(Firmware)
533
593
  def set_sensor_fusion_mode(mode)
534
- send_request FUNCTION_SET_SENSOR_FUSION_MODE, [mode], 'C', 0, ''
594
+ check_validity
595
+
596
+ send_request FUNCTION_SET_SENSOR_FUSION_MODE, [mode], 'C', 8, ''
535
597
  end
536
598
 
537
599
  # Returns the sensor fusion mode as set by BrickIMUV2#set_sensor_fusion_mode.
538
600
  #
539
601
  # .. versionadded:: 2.0.5$nbsp;(Firmware)
540
602
  def get_sensor_fusion_mode
541
- send_request FUNCTION_GET_SENSOR_FUSION_MODE, [], '', 1, 'C'
603
+ check_validity
604
+
605
+ send_request FUNCTION_GET_SENSOR_FUSION_MODE, [], '', 9, 'C'
542
606
  end
543
607
 
544
608
  # The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is
545
609
  # enabled, the Brick will try to adapt the baudrate for the communication
546
610
  # between Bricks and Bricklets according to the amount of data that is transferred.
547
611
  #
548
- # The baudrate will be increased exponentially if lots of data is send/received and
549
- # decreased linearly if little data is send/received.
612
+ # The baudrate will be increased exponentially if lots of data is sent/received and
613
+ # decreased linearly if little data is sent/received.
550
614
  #
551
615
  # This lowers the baudrate in applications where little data is transferred (e.g.
552
616
  # a weather station) and increases the robustness. If there is lots of data to transfer
@@ -560,20 +624,20 @@ module Tinkerforge
560
624
  # BrickIMUV2#set_spitfp_baudrate. If the dynamic baudrate is disabled, the baudrate
561
625
  # as set by BrickIMUV2#set_spitfp_baudrate will be used statically.
562
626
  #
563
- # The minimum dynamic baudrate has a value range of 400000 to 2000000 baud.
564
- #
565
- # By default dynamic baudrate is enabled and the minimum dynamic baudrate is 400000.
566
- #
567
627
  # .. versionadded:: 2.0.10$nbsp;(Firmware)
568
628
  def set_spitfp_baudrate_config(enable_dynamic_baudrate, minimum_dynamic_baudrate)
569
- send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 0, ''
629
+ check_validity
630
+
631
+ send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 8, ''
570
632
  end
571
633
 
572
634
  # Returns the baudrate config, see BrickIMUV2#set_spitfp_baudrate_config.
573
635
  #
574
636
  # .. versionadded:: 2.0.10$nbsp;(Firmware)
575
637
  def get_spitfp_baudrate_config
576
- send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 5, '? L'
638
+ check_validity
639
+
640
+ send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 13, '? L'
577
641
  end
578
642
 
579
643
  # Returns the timeout count for the different communication methods.
@@ -585,11 +649,12 @@ module Tinkerforge
585
649
  #
586
650
  # .. versionadded:: 2.0.7$nbsp;(Firmware)
587
651
  def get_send_timeout_count(communication_method)
588
- send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 4, 'L'
652
+ check_validity
653
+
654
+ send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 12, 'L'
589
655
  end
590
656
 
591
- # Sets the baudrate for a specific Bricklet port ('a' - 'd'). The
592
- # baudrate can be in the range 400000 to 2000000.
657
+ # Sets the baudrate for a specific Bricklet port.
593
658
  #
594
659
  # If you want to increase the throughput of Bricklets you can increase
595
660
  # the baudrate. If you get a high error count because of high
@@ -603,18 +668,20 @@ module Tinkerforge
603
668
  # or similar is necessary in you applications we recommend to not change
604
669
  # the baudrate.
605
670
  #
606
- # The default baudrate for all ports is 1400000.
607
- #
608
671
  # .. versionadded:: 2.0.5$nbsp;(Firmware)
609
672
  def set_spitfp_baudrate(bricklet_port, baudrate)
610
- send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 0, ''
673
+ check_validity
674
+
675
+ send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 8, ''
611
676
  end
612
677
 
613
678
  # Returns the baudrate for a given Bricklet port, see BrickIMUV2#set_spitfp_baudrate.
614
679
  #
615
680
  # .. versionadded:: 2.0.5$nbsp;(Firmware)
616
681
  def get_spitfp_baudrate(bricklet_port)
617
- send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 4, 'L'
682
+ check_validity
683
+
684
+ send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 12, 'L'
618
685
  end
619
686
 
620
687
  # Returns the error count for the communication between Brick and Bricklet.
@@ -631,7 +698,9 @@ module Tinkerforge
631
698
  #
632
699
  # .. versionadded:: 2.0.5$nbsp;(Firmware)
633
700
  def get_spitfp_error_count(bricklet_port)
634
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 16, 'L L L L'
701
+ check_validity
702
+
703
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 24, 'L L L L'
635
704
  end
636
705
 
637
706
  # Enables the status LED.
@@ -641,7 +710,9 @@ module Tinkerforge
641
710
  #
642
711
  # The default state is enabled.
643
712
  def enable_status_led
644
- send_request FUNCTION_ENABLE_STATUS_LED, [], '', 0, ''
713
+ check_validity
714
+
715
+ send_request FUNCTION_ENABLE_STATUS_LED, [], '', 8, ''
645
716
  end
646
717
 
647
718
  # Disables the status LED.
@@ -651,12 +722,16 @@ module Tinkerforge
651
722
  #
652
723
  # The default state is enabled.
653
724
  def disable_status_led
654
- send_request FUNCTION_DISABLE_STATUS_LED, [], '', 0, ''
725
+ check_validity
726
+
727
+ send_request FUNCTION_DISABLE_STATUS_LED, [], '', 8, ''
655
728
  end
656
729
 
657
730
  # Returns *true* if the status LED is enabled, *false* otherwise.
658
731
  def is_status_led_enabled
659
- send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 1, '?'
732
+ check_validity
733
+
734
+ send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 9, '?'
660
735
  end
661
736
 
662
737
  # Returns the firmware and protocol version and the name of the Bricklet for a
@@ -665,17 +740,21 @@ module Tinkerforge
665
740
  # This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet
666
741
  # plugins.
667
742
  def get_protocol1_bricklet_name(port)
668
- send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 44, 'C C3 Z40'
743
+ check_validity
744
+
745
+ send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 52, 'C C3 Z40'
669
746
  end
670
747
 
671
- # Returns the temperature in °C/10 as measured inside the microcontroller. The
748
+ # Returns the temperature as measured inside the microcontroller. The
672
749
  # value returned is not the ambient temperature!
673
750
  #
674
751
  # The temperature is only proportional to the real temperature and it has an
675
752
  # accuracy of ±15%. Practically it is only useful as an indicator for
676
753
  # temperature changes.
677
754
  def get_chip_temperature
678
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
755
+ check_validity
756
+
757
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
679
758
  end
680
759
 
681
760
  # Calling this function will reset the Brick. Calling this function
@@ -685,19 +764,43 @@ module Tinkerforge
685
764
  # calling functions on the existing ones will result in
686
765
  # undefined behavior!
687
766
  def reset
688
- send_request FUNCTION_RESET, [], '', 0, ''
767
+ check_validity
768
+
769
+ send_request FUNCTION_RESET, [], '', 8, ''
770
+ end
771
+
772
+ # Writes 32 bytes of firmware to the bricklet attached at the given port.
773
+ # The bytes are written to the position offset * 32.
774
+ #
775
+ # This function is used by Brick Viewer during flashing. It should not be
776
+ # necessary to call it in a normal user program.
777
+ def write_bricklet_plugin(port, offset, chunk)
778
+ check_validity
779
+
780
+ send_request FUNCTION_WRITE_BRICKLET_PLUGIN, [port, offset, chunk], 'k C C32', 8, ''
781
+ end
782
+
783
+ # Reads 32 bytes of firmware from the bricklet attached at the given port.
784
+ # The bytes are read starting at the position offset * 32.
785
+ #
786
+ # This function is used by Brick Viewer during flashing. It should not be
787
+ # necessary to call it in a normal user program.
788
+ def read_bricklet_plugin(port, offset)
789
+ check_validity
790
+
791
+ send_request FUNCTION_READ_BRICKLET_PLUGIN, [port, offset], 'k C', 40, 'C32'
689
792
  end
690
793
 
691
794
  # Returns the UID, the UID where the Brick is connected to,
692
795
  # the position, the hardware and firmware version as well as the
693
796
  # device identifier.
694
797
  #
695
- # The position can be '0'-'8' (stack position).
798
+ # The position is the position in the stack from '0' (bottom) to '8' (top).
696
799
  #
697
800
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
698
801
  # |device_identifier_constant|
699
802
  def get_identity
700
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
803
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
701
804
  end
702
805
 
703
806
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.