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
  # Full fledged AHRS with 9 degrees of freedom
14
16
  class BrickIMU < Device
@@ -93,6 +95,8 @@ module Tinkerforge
93
95
  FUNCTION_GET_PROTOCOL1_BRICKLET_NAME = 241 # :nodoc:
94
96
  FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
95
97
  FUNCTION_RESET = 243 # :nodoc:
98
+ FUNCTION_WRITE_BRICKLET_PLUGIN = 246 # :nodoc:
99
+ FUNCTION_READ_BRICKLET_PLUGIN = 247 # :nodoc:
96
100
  FUNCTION_GET_IDENTITY = 255 # :nodoc:
97
101
 
98
102
  CALIBRATION_TYPE_ACCELEROMETER_GAIN = 0 # :nodoc:
@@ -113,7 +117,7 @@ module Tinkerforge
113
117
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
114
118
  # the IP Connection <tt>ipcon</tt>.
115
119
  def initialize(uid, ipcon)
116
- super uid, ipcon
120
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
117
121
 
118
122
  @api_version = [2, 0, 4]
119
123
 
@@ -162,35 +166,42 @@ module Tinkerforge
162
166
  @response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
163
167
  @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
164
168
  @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
169
+ @response_expected[FUNCTION_WRITE_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_FALSE
170
+ @response_expected[FUNCTION_READ_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_ALWAYS_TRUE
165
171
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
166
172
 
167
- @callback_formats[CALLBACK_ACCELERATION] = 's s s'
168
- @callback_formats[CALLBACK_MAGNETIC_FIELD] = 's s s'
169
- @callback_formats[CALLBACK_ANGULAR_VELOCITY] = 's s s'
170
- @callback_formats[CALLBACK_ALL_DATA] = 's s s s s s s s s s'
171
- @callback_formats[CALLBACK_ORIENTATION] = 's s s'
172
- @callback_formats[CALLBACK_QUATERNION] = 'e e e e'
173
+ @callback_formats[CALLBACK_ACCELERATION] = [14, 's s s']
174
+ @callback_formats[CALLBACK_MAGNETIC_FIELD] = [14, 's s s']
175
+ @callback_formats[CALLBACK_ANGULAR_VELOCITY] = [14, 's s s']
176
+ @callback_formats[CALLBACK_ALL_DATA] = [28, 's s s s s s s s s s']
177
+ @callback_formats[CALLBACK_ORIENTATION] = [14, 's s s']
178
+ @callback_formats[CALLBACK_QUATERNION] = [24, 'e e e e']
173
179
 
180
+ @ipcon.add_device self
174
181
  end
175
182
 
176
183
  # Returns the calibrated acceleration from the accelerometer for the
177
- # x, y and z axis in g/1000 (1g = 9.80665m/s²).
184
+ # x, y and z axis.
178
185
  #
179
186
  # If you want to get the acceleration periodically, it is recommended
180
187
  # to use the CALLBACK_ACCELERATION callback and set the period with
181
188
  # BrickIMU#set_acceleration_period.
182
189
  def get_acceleration
183
- send_request FUNCTION_GET_ACCELERATION, [], '', 6, 's s s'
190
+ check_validity
191
+
192
+ send_request FUNCTION_GET_ACCELERATION, [], '', 14, 's s s'
184
193
  end
185
194
 
186
195
  # Returns the calibrated magnetic field from the magnetometer for the
187
- # x, y and z axis in mG (Milligauss or Nanotesla).
196
+ # x, y and z axis.
188
197
  #
189
198
  # If you want to get the magnetic field periodically, it is recommended
190
199
  # to use the CALLBACK_MAGNETIC_FIELD callback and set the period with
191
200
  # BrickIMU#set_magnetic_field_period.
192
201
  def get_magnetic_field
193
- send_request FUNCTION_GET_MAGNETIC_FIELD, [], '', 6, 's s s'
202
+ check_validity
203
+
204
+ send_request FUNCTION_GET_MAGNETIC_FIELD, [], '', 14, 's s s'
194
205
  end
195
206
 
196
207
  # Returns the calibrated angular velocity from the gyroscope for the
@@ -201,23 +212,25 @@ module Tinkerforge
201
212
  # to use the CALLBACK_ANGULAR_VELOCITY callback and set the period with
202
213
  # BrickIMU#set_angular_velocity_period.
203
214
  def get_angular_velocity
204
- send_request FUNCTION_GET_ANGULAR_VELOCITY, [], '', 6, 's s s'
215
+ check_validity
216
+
217
+ send_request FUNCTION_GET_ANGULAR_VELOCITY, [], '', 14, 's s s'
205
218
  end
206
219
 
207
220
  # Returns the data from BrickIMU#get_acceleration, BrickIMU#get_magnetic_field
208
221
  # and BrickIMU#get_angular_velocity as well as the temperature of the IMU Brick.
209
222
  #
210
- # The temperature is given in °C/100.
211
- #
212
223
  # If you want to get the data periodically, it is recommended
213
224
  # to use the CALLBACK_ALL_DATA callback and set the period with
214
225
  # BrickIMU#set_all_data_period.
215
226
  def get_all_data
216
- send_request FUNCTION_GET_ALL_DATA, [], '', 20, 's s s s s s s s s s'
227
+ check_validity
228
+
229
+ send_request FUNCTION_GET_ALL_DATA, [], '', 28, 's s s s s s s s s s'
217
230
  end
218
231
 
219
232
  # Returns the current orientation (roll, pitch, yaw) of the IMU Brick as Euler
220
- # angles in one-hundredth degree. Note that Euler angles always experience a
233
+ # angles. Note that Euler angles always experience a
221
234
  # `gimbal lock <https://en.wikipedia.org/wiki/Gimbal_lock>`__.
222
235
  #
223
236
  # We recommend that you use quaternions instead.
@@ -229,7 +242,9 @@ module Tinkerforge
229
242
  # to use the CALLBACK_ORIENTATION callback and set the period with
230
243
  # BrickIMU#set_orientation_period.
231
244
  def get_orientation
232
- send_request FUNCTION_GET_ORIENTATION, [], '', 6, 's s s'
245
+ check_validity
246
+
247
+ send_request FUNCTION_GET_ORIENTATION, [], '', 14, 's s s'
233
248
  end
234
249
 
235
250
  # Returns the current orientation (x, y, z, w) of the IMU as
@@ -264,52 +279,69 @@ module Tinkerforge
264
279
  # to use the CALLBACK_QUATERNION callback and set the period with
265
280
  # BrickIMU#set_quaternion_period.
266
281
  def get_quaternion
267
- send_request FUNCTION_GET_QUATERNION, [], '', 16, 'e e e e'
282
+ check_validity
283
+
284
+ send_request FUNCTION_GET_QUATERNION, [], '', 24, 'e e e e'
268
285
  end
269
286
 
270
- # Returns the temperature of the IMU Brick. The temperature is given in
271
- # °C/100.
287
+ # Returns the temperature of the IMU Brick.
272
288
  def get_imu_temperature
273
- send_request FUNCTION_GET_IMU_TEMPERATURE, [], '', 2, 's'
289
+ check_validity
290
+
291
+ send_request FUNCTION_GET_IMU_TEMPERATURE, [], '', 10, 's'
274
292
  end
275
293
 
276
294
  # Turns the orientation and direction LEDs of the IMU Brick on.
277
295
  def leds_on
278
- send_request FUNCTION_LEDS_ON, [], '', 0, ''
296
+ check_validity
297
+
298
+ send_request FUNCTION_LEDS_ON, [], '', 8, ''
279
299
  end
280
300
 
281
301
  # Turns the orientation and direction LEDs of the IMU Brick off.
282
302
  def leds_off
283
- send_request FUNCTION_LEDS_OFF, [], '', 0, ''
303
+ check_validity
304
+
305
+ send_request FUNCTION_LEDS_OFF, [], '', 8, ''
284
306
  end
285
307
 
286
308
  # Returns *true* if the orientation and direction LEDs of the IMU Brick
287
309
  # are on, *false* otherwise.
288
310
  def are_leds_on
289
- send_request FUNCTION_ARE_LEDS_ON, [], '', 1, '?'
311
+ check_validity
312
+
313
+ send_request FUNCTION_ARE_LEDS_ON, [], '', 9, '?'
290
314
  end
291
315
 
292
316
  # Not implemented yet.
293
317
  def set_acceleration_range(range)
294
- send_request FUNCTION_SET_ACCELERATION_RANGE, [range], 'C', 0, ''
318
+ check_validity
319
+
320
+ send_request FUNCTION_SET_ACCELERATION_RANGE, [range], 'C', 8, ''
295
321
  end
296
322
 
297
323
  # Not implemented yet.
298
324
  def get_acceleration_range
299
- send_request FUNCTION_GET_ACCELERATION_RANGE, [], '', 1, 'C'
325
+ check_validity
326
+
327
+ send_request FUNCTION_GET_ACCELERATION_RANGE, [], '', 9, 'C'
300
328
  end
301
329
 
302
330
  # Not implemented yet.
303
331
  def set_magnetometer_range(range)
304
- send_request FUNCTION_SET_MAGNETOMETER_RANGE, [range], 'C', 0, ''
332
+ check_validity
333
+
334
+ send_request FUNCTION_SET_MAGNETOMETER_RANGE, [range], 'C', 8, ''
305
335
  end
306
336
 
307
337
  # Not implemented yet.
308
338
  def get_magnetometer_range
309
- send_request FUNCTION_GET_MAGNETOMETER_RANGE, [], '', 1, 'C'
339
+ check_validity
340
+
341
+ send_request FUNCTION_GET_MAGNETOMETER_RANGE, [], '', 9, 'C'
310
342
  end
311
343
 
312
- # Sets the convergence speed of the IMU Brick in °/s. The convergence speed
344
+ # Sets the convergence speed of the IMU Brick. The convergence speed
313
345
  # determines how the different sensor measurements are fused.
314
346
  #
315
347
  # If the orientation of the IMU Brick is off by 10° and the convergence speed is
@@ -334,15 +366,17 @@ module Tinkerforge
334
366
  #
335
367
  # You might want to play around with the convergence speed in the Brick Viewer to
336
368
  # get a feeling for a good value for your application.
337
- #
338
- # The default value is 30.
339
369
  def set_convergence_speed(speed)
340
- send_request FUNCTION_SET_CONVERGENCE_SPEED, [speed], 'S', 0, ''
370
+ check_validity
371
+
372
+ send_request FUNCTION_SET_CONVERGENCE_SPEED, [speed], 'S', 8, ''
341
373
  end
342
374
 
343
375
  # Returns the convergence speed as set by BrickIMU#set_convergence_speed.
344
376
  def get_convergence_speed
345
- send_request FUNCTION_GET_CONVERGENCE_SPEED, [], '', 2, 'S'
377
+ check_validity
378
+
379
+ send_request FUNCTION_GET_CONVERGENCE_SPEED, [], '', 10, 'S'
346
380
  end
347
381
 
348
382
  # There are several different types that can be calibrated:
@@ -378,78 +412,106 @@ module Tinkerforge
378
412
  # We highly recommend that you use the Brick Viewer to calibrate your
379
413
  # IMU Brick.
380
414
  def set_calibration(typ, data)
381
- send_request FUNCTION_SET_CALIBRATION, [typ, data], 'C s10', 0, ''
415
+ check_validity
416
+
417
+ send_request FUNCTION_SET_CALIBRATION, [typ, data], 'C s10', 8, ''
382
418
  end
383
419
 
384
420
  # Returns the calibration for a given type as set by BrickIMU#set_calibration.
385
421
  def get_calibration(typ)
386
- send_request FUNCTION_GET_CALIBRATION, [typ], 'C', 20, 's10'
422
+ check_validity
423
+
424
+ send_request FUNCTION_GET_CALIBRATION, [typ], 'C', 28, 's10'
387
425
  end
388
426
 
389
427
  # Sets the period with which the CALLBACK_ACCELERATION callback is triggered
390
428
  # periodically. A value of 0 turns the callback off.
391
429
  def set_acceleration_period(period)
392
- send_request FUNCTION_SET_ACCELERATION_PERIOD, [period], 'L', 0, ''
430
+ check_validity
431
+
432
+ send_request FUNCTION_SET_ACCELERATION_PERIOD, [period], 'L', 8, ''
393
433
  end
394
434
 
395
435
  # Returns the period as set by BrickIMU#set_acceleration_period.
396
436
  def get_acceleration_period
397
- send_request FUNCTION_GET_ACCELERATION_PERIOD, [], '', 4, 'L'
437
+ check_validity
438
+
439
+ send_request FUNCTION_GET_ACCELERATION_PERIOD, [], '', 12, 'L'
398
440
  end
399
441
 
400
442
  # Sets the period with which the CALLBACK_MAGNETIC_FIELD callback is
401
443
  # triggered periodically. A value of 0 turns the callback off.
402
444
  def set_magnetic_field_period(period)
403
- send_request FUNCTION_SET_MAGNETIC_FIELD_PERIOD, [period], 'L', 0, ''
445
+ check_validity
446
+
447
+ send_request FUNCTION_SET_MAGNETIC_FIELD_PERIOD, [period], 'L', 8, ''
404
448
  end
405
449
 
406
450
  # Returns the period as set by BrickIMU#set_magnetic_field_period.
407
451
  def get_magnetic_field_period
408
- send_request FUNCTION_GET_MAGNETIC_FIELD_PERIOD, [], '', 4, 'L'
452
+ check_validity
453
+
454
+ send_request FUNCTION_GET_MAGNETIC_FIELD_PERIOD, [], '', 12, 'L'
409
455
  end
410
456
 
411
457
  # Sets the period with which the CALLBACK_ANGULAR_VELOCITY callback is
412
458
  # triggered periodically. A value of 0 turns the callback off.
413
459
  def set_angular_velocity_period(period)
414
- send_request FUNCTION_SET_ANGULAR_VELOCITY_PERIOD, [period], 'L', 0, ''
460
+ check_validity
461
+
462
+ send_request FUNCTION_SET_ANGULAR_VELOCITY_PERIOD, [period], 'L', 8, ''
415
463
  end
416
464
 
417
465
  # Returns the period as set by BrickIMU#set_angular_velocity_period.
418
466
  def get_angular_velocity_period
419
- send_request FUNCTION_GET_ANGULAR_VELOCITY_PERIOD, [], '', 4, 'L'
467
+ check_validity
468
+
469
+ send_request FUNCTION_GET_ANGULAR_VELOCITY_PERIOD, [], '', 12, 'L'
420
470
  end
421
471
 
422
472
  # Sets the period with which the CALLBACK_ALL_DATA callback is triggered
423
473
  # periodically. A value of 0 turns the callback off.
424
474
  def set_all_data_period(period)
425
- send_request FUNCTION_SET_ALL_DATA_PERIOD, [period], 'L', 0, ''
475
+ check_validity
476
+
477
+ send_request FUNCTION_SET_ALL_DATA_PERIOD, [period], 'L', 8, ''
426
478
  end
427
479
 
428
480
  # Returns the period as set by BrickIMU#set_all_data_period.
429
481
  def get_all_data_period
430
- send_request FUNCTION_GET_ALL_DATA_PERIOD, [], '', 4, 'L'
482
+ check_validity
483
+
484
+ send_request FUNCTION_GET_ALL_DATA_PERIOD, [], '', 12, 'L'
431
485
  end
432
486
 
433
487
  # Sets the period with which the CALLBACK_ORIENTATION callback is triggered
434
488
  # periodically. A value of 0 turns the callback off.
435
489
  def set_orientation_period(period)
436
- send_request FUNCTION_SET_ORIENTATION_PERIOD, [period], 'L', 0, ''
490
+ check_validity
491
+
492
+ send_request FUNCTION_SET_ORIENTATION_PERIOD, [period], 'L', 8, ''
437
493
  end
438
494
 
439
495
  # Returns the period as set by BrickIMU#set_orientation_period.
440
496
  def get_orientation_period
441
- send_request FUNCTION_GET_ORIENTATION_PERIOD, [], '', 4, 'L'
497
+ check_validity
498
+
499
+ send_request FUNCTION_GET_ORIENTATION_PERIOD, [], '', 12, 'L'
442
500
  end
443
501
 
444
502
  # Sets the period with which the CALLBACK_QUATERNION callback is triggered
445
503
  # periodically. A value of 0 turns the callback off.
446
504
  def set_quaternion_period(period)
447
- send_request FUNCTION_SET_QUATERNION_PERIOD, [period], 'L', 0, ''
505
+ check_validity
506
+
507
+ send_request FUNCTION_SET_QUATERNION_PERIOD, [period], 'L', 8, ''
448
508
  end
449
509
 
450
510
  # Returns the period as set by BrickIMU#set_quaternion_period.
451
511
  def get_quaternion_period
452
- send_request FUNCTION_GET_QUATERNION_PERIOD, [], '', 4, 'L'
512
+ check_validity
513
+
514
+ send_request FUNCTION_GET_QUATERNION_PERIOD, [], '', 12, 'L'
453
515
  end
454
516
 
455
517
  # Turns the orientation calculation of the IMU Brick on.
@@ -458,7 +520,9 @@ module Tinkerforge
458
520
  #
459
521
  # .. versionadded:: 2.0.2$nbsp;(Firmware)
460
522
  def orientation_calculation_on
461
- send_request FUNCTION_ORIENTATION_CALCULATION_ON, [], '', 0, ''
523
+ check_validity
524
+
525
+ send_request FUNCTION_ORIENTATION_CALCULATION_ON, [], '', 8, ''
462
526
  end
463
527
 
464
528
  # Turns the orientation calculation of the IMU Brick off.
@@ -475,7 +539,9 @@ module Tinkerforge
475
539
  #
476
540
  # .. versionadded:: 2.0.2$nbsp;(Firmware)
477
541
  def orientation_calculation_off
478
- send_request FUNCTION_ORIENTATION_CALCULATION_OFF, [], '', 0, ''
542
+ check_validity
543
+
544
+ send_request FUNCTION_ORIENTATION_CALCULATION_OFF, [], '', 8, ''
479
545
  end
480
546
 
481
547
  # Returns *true* if the orientation calculation of the IMU Brick
@@ -483,15 +549,17 @@ module Tinkerforge
483
549
  #
484
550
  # .. versionadded:: 2.0.2$nbsp;(Firmware)
485
551
  def is_orientation_calculation_on
486
- send_request FUNCTION_IS_ORIENTATION_CALCULATION_ON, [], '', 1, '?'
552
+ check_validity
553
+
554
+ send_request FUNCTION_IS_ORIENTATION_CALCULATION_ON, [], '', 9, '?'
487
555
  end
488
556
 
489
557
  # The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is
490
558
  # enabled, the Brick will try to adapt the baudrate for the communication
491
559
  # between Bricks and Bricklets according to the amount of data that is transferred.
492
560
  #
493
- # The baudrate will be increased exponentially if lots of data is send/received and
494
- # decreased linearly if little data is send/received.
561
+ # The baudrate will be increased exponentially if lots of data is sent/received and
562
+ # decreased linearly if little data is sent/received.
495
563
  #
496
564
  # This lowers the baudrate in applications where little data is transferred (e.g.
497
565
  # a weather station) and increases the robustness. If there is lots of data to transfer
@@ -505,20 +573,20 @@ module Tinkerforge
505
573
  # BrickIMU#set_spitfp_baudrate. If the dynamic baudrate is disabled, the baudrate
506
574
  # as set by BrickIMU#set_spitfp_baudrate will be used statically.
507
575
  #
508
- # The minimum dynamic baudrate has a value range of 400000 to 2000000 baud.
509
- #
510
- # By default dynamic baudrate is enabled and the minimum dynamic baudrate is 400000.
511
- #
512
576
  # .. versionadded:: 2.3.5$nbsp;(Firmware)
513
577
  def set_spitfp_baudrate_config(enable_dynamic_baudrate, minimum_dynamic_baudrate)
514
- send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 0, ''
578
+ check_validity
579
+
580
+ send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 8, ''
515
581
  end
516
582
 
517
583
  # Returns the baudrate config, see BrickIMU#set_spitfp_baudrate_config.
518
584
  #
519
585
  # .. versionadded:: 2.3.5$nbsp;(Firmware)
520
586
  def get_spitfp_baudrate_config
521
- send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 5, '? L'
587
+ check_validity
588
+
589
+ send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 13, '? L'
522
590
  end
523
591
 
524
592
  # Returns the timeout count for the different communication methods.
@@ -530,11 +598,12 @@ module Tinkerforge
530
598
  #
531
599
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
532
600
  def get_send_timeout_count(communication_method)
533
- send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 4, 'L'
601
+ check_validity
602
+
603
+ send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 12, 'L'
534
604
  end
535
605
 
536
- # Sets the baudrate for a specific Bricklet port ('a' - 'd'). The
537
- # baudrate can be in the range 400000 to 2000000.
606
+ # Sets the baudrate for a specific Bricklet port.
538
607
  #
539
608
  # If you want to increase the throughput of Bricklets you can increase
540
609
  # the baudrate. If you get a high error count because of high
@@ -548,18 +617,20 @@ module Tinkerforge
548
617
  # or similar is necessary in you applications we recommend to not change
549
618
  # the baudrate.
550
619
  #
551
- # The default baudrate for all ports is 1400000.
552
- #
553
620
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
554
621
  def set_spitfp_baudrate(bricklet_port, baudrate)
555
- send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 0, ''
622
+ check_validity
623
+
624
+ send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 8, ''
556
625
  end
557
626
 
558
627
  # Returns the baudrate for a given Bricklet port, see BrickIMU#set_spitfp_baudrate.
559
628
  #
560
629
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
561
630
  def get_spitfp_baudrate(bricklet_port)
562
- send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 4, 'L'
631
+ check_validity
632
+
633
+ send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 12, 'L'
563
634
  end
564
635
 
565
636
  # Returns the error count for the communication between Brick and Bricklet.
@@ -576,7 +647,9 @@ module Tinkerforge
576
647
  #
577
648
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
578
649
  def get_spitfp_error_count(bricklet_port)
579
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 16, 'L L L L'
650
+ check_validity
651
+
652
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 24, 'L L L L'
580
653
  end
581
654
 
582
655
  # Enables the status LED.
@@ -588,7 +661,9 @@ module Tinkerforge
588
661
  #
589
662
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
590
663
  def enable_status_led
591
- send_request FUNCTION_ENABLE_STATUS_LED, [], '', 0, ''
664
+ check_validity
665
+
666
+ send_request FUNCTION_ENABLE_STATUS_LED, [], '', 8, ''
592
667
  end
593
668
 
594
669
  # Disables the status LED.
@@ -600,14 +675,18 @@ module Tinkerforge
600
675
  #
601
676
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
602
677
  def disable_status_led
603
- send_request FUNCTION_DISABLE_STATUS_LED, [], '', 0, ''
678
+ check_validity
679
+
680
+ send_request FUNCTION_DISABLE_STATUS_LED, [], '', 8, ''
604
681
  end
605
682
 
606
683
  # Returns *true* if the status LED is enabled, *false* otherwise.
607
684
  #
608
685
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
609
686
  def is_status_led_enabled
610
- send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 1, '?'
687
+ check_validity
688
+
689
+ send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 9, '?'
611
690
  end
612
691
 
613
692
  # Returns the firmware and protocol version and the name of the Bricklet for a
@@ -616,17 +695,21 @@ module Tinkerforge
616
695
  # This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet
617
696
  # plugins.
618
697
  def get_protocol1_bricklet_name(port)
619
- send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 44, 'C C3 Z40'
698
+ check_validity
699
+
700
+ send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 52, 'C C3 Z40'
620
701
  end
621
702
 
622
- # Returns the temperature in °C/10 as measured inside the microcontroller. The
703
+ # Returns the temperature as measured inside the microcontroller. The
623
704
  # value returned is not the ambient temperature!
624
705
  #
625
706
  # The temperature is only proportional to the real temperature and it has an
626
707
  # accuracy of ±15%. Practically it is only useful as an indicator for
627
708
  # temperature changes.
628
709
  def get_chip_temperature
629
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
710
+ check_validity
711
+
712
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
630
713
  end
631
714
 
632
715
  # Calling this function will reset the Brick. Calling this function
@@ -636,19 +719,43 @@ module Tinkerforge
636
719
  # calling functions on the existing ones will result in
637
720
  # undefined behavior!
638
721
  def reset
639
- send_request FUNCTION_RESET, [], '', 0, ''
722
+ check_validity
723
+
724
+ send_request FUNCTION_RESET, [], '', 8, ''
725
+ end
726
+
727
+ # Writes 32 bytes of firmware to the bricklet attached at the given port.
728
+ # The bytes are written to the position offset * 32.
729
+ #
730
+ # This function is used by Brick Viewer during flashing. It should not be
731
+ # necessary to call it in a normal user program.
732
+ def write_bricklet_plugin(port, offset, chunk)
733
+ check_validity
734
+
735
+ send_request FUNCTION_WRITE_BRICKLET_PLUGIN, [port, offset, chunk], 'k C C32', 8, ''
736
+ end
737
+
738
+ # Reads 32 bytes of firmware from the bricklet attached at the given port.
739
+ # The bytes are read starting at the position offset * 32.
740
+ #
741
+ # This function is used by Brick Viewer during flashing. It should not be
742
+ # necessary to call it in a normal user program.
743
+ def read_bricklet_plugin(port, offset)
744
+ check_validity
745
+
746
+ send_request FUNCTION_READ_BRICKLET_PLUGIN, [port, offset], 'k C', 40, 'C32'
640
747
  end
641
748
 
642
749
  # Returns the UID, the UID where the Brick is connected to,
643
750
  # the position, the hardware and firmware version as well as the
644
751
  # device identifier.
645
752
  #
646
- # The position can be '0'-'8' (stack position).
753
+ # The position is the position in the stack from '0' (bottom) to '8' (top).
647
754
  #
648
755
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
649
756
  # |device_identifier_constant|
650
757
  def get_identity
651
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
758
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
652
759
  end
653
760
 
654
761
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.