tinkerforge 2.1.22 → 2.1.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +157 -76
  3. data/lib/tinkerforge/brick_hat.rb +115 -32
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +192 -87
  6. data/lib/tinkerforge/brick_imu_v2.rb +220 -119
  7. data/lib/tinkerforge/brick_master.rb +498 -198
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +187 -103
  10. data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
  11. data/lib/tinkerforge/brick_stepper.rb +214 -102
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
  14. data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
  18. data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
  21. data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
  24. data/lib/tinkerforge/bricklet_barometer.rb +108 -58
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
  26. data/lib/tinkerforge/bricklet_can.rb +84 -24
  27. data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
  28. data/lib/tinkerforge/bricklet_co2.rb +36 -25
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
  30. data/lib/tinkerforge/bricklet_color.rb +77 -49
  31. data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
  32. data/lib/tinkerforge/bricklet_compass.rb +397 -0
  33. data/lib/tinkerforge/bricklet_current12.rb +61 -40
  34. data/lib/tinkerforge/bricklet_current25.rb +61 -40
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
  37. data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
  39. data/lib/tinkerforge/bricklet_dmx.rb +92 -48
  40. data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
  46. data/lib/tinkerforge/bricklet_gps.rb +72 -48
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
  50. data/lib/tinkerforge/bricklet_humidity.rb +54 -38
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
  52. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  53. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
  54. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
  55. data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
  62. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  63. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
  65. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
  66. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
  67. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
  68. data/lib/tinkerforge/bricklet_io16.rb +57 -32
  69. data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
  70. data/lib/tinkerforge/bricklet_io4.rb +56 -31
  71. data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
  72. data/lib/tinkerforge/bricklet_isolator.rb +111 -35
  73. data/lib/tinkerforge/bricklet_joystick.rb +63 -42
  74. data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
  75. data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
  76. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
  78. data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
  79. data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
  80. data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
  81. data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
  82. data/lib/tinkerforge/bricklet_line.rb +35 -22
  83. data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
  84. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
  85. data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
  86. data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
  87. data/lib/tinkerforge/bricklet_moisture.rb +43 -30
  88. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  89. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
  90. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
  91. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
  92. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
  93. data/lib/tinkerforge/bricklet_nfc.rb +130 -80
  94. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  95. data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
  96. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
  97. data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
  98. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  99. data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
  100. data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
  101. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
  102. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  103. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  104. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  105. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  106. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  107. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  108. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  109. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  110. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  111. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  112. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  113. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  114. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  115. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  116. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  117. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
  118. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  119. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  120. data/lib/tinkerforge/bricklet_rs485.rb +303 -207
  121. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  122. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  123. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  124. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  125. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  126. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  127. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  128. data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
  129. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
  130. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  131. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  132. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  133. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  134. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  135. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  136. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  137. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  138. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  139. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
  140. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
  141. data/lib/tinkerforge/device_display_names.rb +165 -0
  142. data/lib/tinkerforge/ip_connection.rb +155 -33
  143. data/lib/tinkerforge/version.rb +1 -1
  144. metadata +14 -4
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-05-21. #
3
+ # This file was automatically generated on 2020-11-02. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.27 #
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
  # Drives one bipolar stepper motor with up to 38V and 2.5A per phase
14
16
  class BrickStepper < Device
@@ -16,8 +18,7 @@ module Tinkerforge
16
18
  DEVICE_DISPLAY_NAME = 'Stepper Brick' # :nodoc:
17
19
 
18
20
  # This callback is triggered when the input voltage drops below the value set by
19
- # BrickStepper#set_minimum_voltage. The parameter is the current voltage given
20
- # in mV.
21
+ # BrickStepper#set_minimum_voltage. The parameter is the current voltage.
21
22
  CALLBACK_UNDER_VOLTAGE = 31
22
23
 
23
24
  # This callback is triggered when a position set by BrickStepper#set_steps or
@@ -89,6 +90,8 @@ module Tinkerforge
89
90
  FUNCTION_GET_PROTOCOL1_BRICKLET_NAME = 241 # :nodoc:
90
91
  FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
91
92
  FUNCTION_RESET = 243 # :nodoc:
93
+ FUNCTION_WRITE_BRICKLET_PLUGIN = 246 # :nodoc:
94
+ FUNCTION_READ_BRICKLET_PLUGIN = 247 # :nodoc:
92
95
  FUNCTION_GET_IDENTITY = 255 # :nodoc:
93
96
 
94
97
  STEP_MODE_FULL_STEP = 1 # :nodoc:
@@ -113,7 +116,7 @@ module Tinkerforge
113
116
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
114
117
  # the IP Connection <tt>ipcon</tt>.
115
118
  def initialize(uid, ipcon)
116
- super uid, ipcon
119
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
117
120
 
118
121
  @api_version = [2, 0, 4]
119
122
 
@@ -166,36 +169,45 @@ module Tinkerforge
166
169
  @response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
167
170
  @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
168
171
  @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
172
+ @response_expected[FUNCTION_WRITE_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_FALSE
173
+ @response_expected[FUNCTION_READ_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_ALWAYS_TRUE
169
174
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
170
175
 
171
- @callback_formats[CALLBACK_UNDER_VOLTAGE] = 'S'
172
- @callback_formats[CALLBACK_POSITION_REACHED] = 'l'
173
- @callback_formats[CALLBACK_ALL_DATA] = 'S l l S S S'
174
- @callback_formats[CALLBACK_NEW_STATE] = 'C C'
176
+ @callback_formats[CALLBACK_UNDER_VOLTAGE] = [10, 'S']
177
+ @callback_formats[CALLBACK_POSITION_REACHED] = [12, 'l']
178
+ @callback_formats[CALLBACK_ALL_DATA] = [24, 'S l l S S S']
179
+ @callback_formats[CALLBACK_NEW_STATE] = [10, 'C C']
175
180
 
181
+ @ipcon.add_device self
176
182
  end
177
183
 
178
- # Sets the maximum velocity of the stepper motor in steps per second.
184
+ # Sets the maximum velocity of the stepper motor.
179
185
  # This function does *not* start the motor, it merely sets the maximum
180
186
  # velocity the stepper motor is accelerated to. To get the motor running use
181
187
  # either BrickStepper#set_target_position, BrickStepper#set_steps, BrickStepper#drive_forward or
182
188
  # BrickStepper#drive_backward.
183
189
  def set_max_velocity(velocity)
184
- send_request FUNCTION_SET_MAX_VELOCITY, [velocity], 'S', 0, ''
190
+ check_validity
191
+
192
+ send_request FUNCTION_SET_MAX_VELOCITY, [velocity], 'S', 8, ''
185
193
  end
186
194
 
187
195
  # Returns the velocity as set by BrickStepper#set_max_velocity.
188
196
  def get_max_velocity
189
- send_request FUNCTION_GET_MAX_VELOCITY, [], '', 2, 'S'
197
+ check_validity
198
+
199
+ send_request FUNCTION_GET_MAX_VELOCITY, [], '', 10, 'S'
190
200
  end
191
201
 
192
- # Returns the *current* velocity of the stepper motor in steps per second.
202
+ # Returns the *current* velocity of the stepper motor.
193
203
  def get_current_velocity
194
- send_request FUNCTION_GET_CURRENT_VELOCITY, [], '', 2, 'S'
204
+ check_validity
205
+
206
+ send_request FUNCTION_GET_CURRENT_VELOCITY, [], '', 10, 'S'
195
207
  end
196
208
 
197
- # Sets the acceleration and deacceleration of the stepper motor. The values
198
- # are given in *steps/s²*. An acceleration of 1000 means, that
209
+ # Sets the acceleration and deacceleration of the stepper motor.
210
+ # An acceleration of 1000 means, that
199
211
  # every second the velocity is increased by 1000 *steps/s*.
200
212
  #
201
213
  # For example: If the current velocity is 0 and you want to accelerate to a
@@ -204,16 +216,18 @@ module Tinkerforge
204
216
  #
205
217
  # An acceleration/deacceleration of 0 means instantaneous
206
218
  # acceleration/deacceleration (not recommended)
207
- #
208
- # The default value is 1000 for both
209
219
  def set_speed_ramping(acceleration, deacceleration)
210
- send_request FUNCTION_SET_SPEED_RAMPING, [acceleration, deacceleration], 'S S', 0, ''
220
+ check_validity
221
+
222
+ send_request FUNCTION_SET_SPEED_RAMPING, [acceleration, deacceleration], 'S S', 8, ''
211
223
  end
212
224
 
213
225
  # Returns the acceleration and deacceleration as set by
214
226
  # BrickStepper#set_speed_ramping.
215
227
  def get_speed_ramping
216
- send_request FUNCTION_GET_SPEED_RAMPING, [], '', 4, 'S S'
228
+ check_validity
229
+
230
+ send_request FUNCTION_GET_SPEED_RAMPING, [], '', 12, 'S S'
217
231
  end
218
232
 
219
233
  # Executes an active full brake.
@@ -225,14 +239,18 @@ module Tinkerforge
225
239
  #
226
240
  # Call BrickStepper#stop if you just want to stop the motor.
227
241
  def full_brake
228
- send_request FUNCTION_FULL_BRAKE, [], '', 0, ''
242
+ check_validity
243
+
244
+ send_request FUNCTION_FULL_BRAKE, [], '', 8, ''
229
245
  end
230
246
 
231
247
  # Sets the current steps of the internal step counter. This can be used to
232
248
  # set the current position to 0 when some kind of starting position
233
249
  # is reached (e.g. when a CNC machine reaches a corner).
234
250
  def set_current_position(position)
235
- send_request FUNCTION_SET_CURRENT_POSITION, [position], 'l', 0, ''
251
+ check_validity
252
+
253
+ send_request FUNCTION_SET_CURRENT_POSITION, [position], 'l', 8, ''
236
254
  end
237
255
 
238
256
  # Returns the current position of the stepper motor in steps. On startup
@@ -241,7 +259,9 @@ module Tinkerforge
241
259
  # BrickStepper#drive_backward). It also is possible to reset the steps to 0 or
242
260
  # set them to any other desired value with BrickStepper#set_current_position.
243
261
  def get_current_position
244
- send_request FUNCTION_GET_CURRENT_POSITION, [], '', 4, 'l'
262
+ check_validity
263
+
264
+ send_request FUNCTION_GET_CURRENT_POSITION, [], '', 12, 'l'
245
265
  end
246
266
 
247
267
  # Sets the target position of the stepper motor in steps. For example,
@@ -254,12 +274,16 @@ module Tinkerforge
254
274
  # a call of BrickStepper#set_steps with the parameter
255
275
  # (*x* - BrickStepper#get_current_position).
256
276
  def set_target_position(position)
257
- send_request FUNCTION_SET_TARGET_POSITION, [position], 'l', 0, ''
277
+ check_validity
278
+
279
+ send_request FUNCTION_SET_TARGET_POSITION, [position], 'l', 8, ''
258
280
  end
259
281
 
260
282
  # Returns the last target position as set by BrickStepper#set_target_position.
261
283
  def get_target_position
262
- send_request FUNCTION_GET_TARGET_POSITION, [], '', 4, 'l'
284
+ check_validity
285
+
286
+ send_request FUNCTION_GET_TARGET_POSITION, [], '', 12, 'l'
263
287
  end
264
288
 
265
289
  # Sets the number of steps the stepper motor should run. Positive values
@@ -267,12 +291,16 @@ module Tinkerforge
267
291
  # The velocity, acceleration and deacceleration as set by
268
292
  # BrickStepper#set_max_velocity and BrickStepper#set_speed_ramping will be used.
269
293
  def set_steps(steps)
270
- send_request FUNCTION_SET_STEPS, [steps], 'l', 0, ''
294
+ check_validity
295
+
296
+ send_request FUNCTION_SET_STEPS, [steps], 'l', 8, ''
271
297
  end
272
298
 
273
299
  # Returns the last steps as set by BrickStepper#set_steps.
274
300
  def get_steps
275
- send_request FUNCTION_GET_STEPS, [], '', 4, 'l'
301
+ check_validity
302
+
303
+ send_request FUNCTION_GET_STEPS, [], '', 12, 'l'
276
304
  end
277
305
 
278
306
  # Returns the remaining steps of the last call of BrickStepper#set_steps.
@@ -280,7 +308,9 @@ module Tinkerforge
280
308
  # BrickStepper#get_remaining_steps is called after the motor has run for 500 steps,
281
309
  # it will return 1500.
282
310
  def get_remaining_steps
283
- send_request FUNCTION_GET_REMAINING_STEPS, [], '', 4, 'l'
311
+ check_validity
312
+
313
+ send_request FUNCTION_GET_REMAINING_STEPS, [], '', 12, 'l'
284
314
  end
285
315
 
286
316
  # Sets the step mode of the stepper motor. Possible values are:
@@ -292,45 +322,55 @@ module Tinkerforge
292
322
  #
293
323
  # A higher value will increase the resolution and
294
324
  # decrease the torque of the stepper motor.
295
- #
296
- # The default value is 8 (Eighth Step).
297
325
  def set_step_mode(mode)
298
- send_request FUNCTION_SET_STEP_MODE, [mode], 'C', 0, ''
326
+ check_validity
327
+
328
+ send_request FUNCTION_SET_STEP_MODE, [mode], 'C', 8, ''
299
329
  end
300
330
 
301
331
  # Returns the step mode as set by BrickStepper#set_step_mode.
302
332
  def get_step_mode
303
- send_request FUNCTION_GET_STEP_MODE, [], '', 1, 'C'
333
+ check_validity
334
+
335
+ send_request FUNCTION_GET_STEP_MODE, [], '', 9, 'C'
304
336
  end
305
337
 
306
338
  # Drives the stepper motor forward until BrickStepper#drive_backward or
307
339
  # BrickStepper#stop is called. The velocity, acceleration and deacceleration as
308
340
  # set by BrickStepper#set_max_velocity and BrickStepper#set_speed_ramping will be used.
309
341
  def drive_forward
310
- send_request FUNCTION_DRIVE_FORWARD, [], '', 0, ''
342
+ check_validity
343
+
344
+ send_request FUNCTION_DRIVE_FORWARD, [], '', 8, ''
311
345
  end
312
346
 
313
347
  # Drives the stepper motor backward until BrickStepper#drive_forward or
314
348
  # BrickStepper#stop is triggered. The velocity, acceleration and deacceleration as
315
349
  # set by BrickStepper#set_max_velocity and BrickStepper#set_speed_ramping will be used.
316
350
  def drive_backward
317
- send_request FUNCTION_DRIVE_BACKWARD, [], '', 0, ''
351
+ check_validity
352
+
353
+ send_request FUNCTION_DRIVE_BACKWARD, [], '', 8, ''
318
354
  end
319
355
 
320
356
  # Stops the stepper motor with the deacceleration as set by
321
357
  # BrickStepper#set_speed_ramping.
322
358
  def stop
323
- send_request FUNCTION_STOP, [], '', 0, ''
359
+ check_validity
360
+
361
+ send_request FUNCTION_STOP, [], '', 8, ''
324
362
  end
325
363
 
326
- # Returns the stack input voltage in mV. The stack input voltage is the
364
+ # Returns the stack input voltage. The stack input voltage is the
327
365
  # voltage that is supplied via the stack, i.e. it is given by a
328
366
  # Step-Down or Step-Up Power Supply.
329
367
  def get_stack_input_voltage
330
- send_request FUNCTION_GET_STACK_INPUT_VOLTAGE, [], '', 2, 'S'
368
+ check_validity
369
+
370
+ send_request FUNCTION_GET_STACK_INPUT_VOLTAGE, [], '', 10, 'S'
331
371
  end
332
372
 
333
- # Returns the external input voltage in mV. The external input voltage is
373
+ # Returns the external input voltage. The external input voltage is
334
374
  # given via the black power input connector on the Stepper Brick.
335
375
  #
336
376
  # If there is an external input voltage and a stack input voltage, the motor
@@ -343,49 +383,69 @@ module Tinkerforge
343
383
  # the external connection, it will immediately be driven by the high
344
384
  # stack voltage
345
385
  def get_external_input_voltage
346
- send_request FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE, [], '', 2, 'S'
386
+ check_validity
387
+
388
+ send_request FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE, [], '', 10, 'S'
347
389
  end
348
390
 
349
- # Returns the current consumption of the motor in mA.
391
+ # Returns the current consumption of the motor.
350
392
  def get_current_consumption
351
- send_request FUNCTION_GET_CURRENT_CONSUMPTION, [], '', 2, 'S'
393
+ check_validity
394
+
395
+ send_request FUNCTION_GET_CURRENT_CONSUMPTION, [], '', 10, 'S'
352
396
  end
353
397
 
354
- # Sets the current in mA with which the motor will be driven.
355
- # The minimum value is 100mA, the maximum value 2291mA and the
356
- # default value is 800mA.
398
+ # Sets the current with which the motor will be driven.
357
399
  #
358
400
  # .. warning::
359
401
  # Do not set this value above the specifications of your stepper motor.
360
402
  # Otherwise it may damage your motor.
361
403
  def set_motor_current(current)
362
- send_request FUNCTION_SET_MOTOR_CURRENT, [current], 'S', 0, ''
404
+ check_validity
405
+
406
+ send_request FUNCTION_SET_MOTOR_CURRENT, [current], 'S', 8, ''
363
407
  end
364
408
 
365
409
  # Returns the current as set by BrickStepper#set_motor_current.
366
410
  def get_motor_current
367
- send_request FUNCTION_GET_MOTOR_CURRENT, [], '', 2, 'S'
411
+ check_validity
412
+
413
+ send_request FUNCTION_GET_MOTOR_CURRENT, [], '', 10, 'S'
368
414
  end
369
415
 
370
416
  # Enables the driver chip. The driver parameters can be configured (maximum velocity,
371
417
  # acceleration, etc) before it is enabled.
372
418
  def enable
373
- send_request FUNCTION_ENABLE, [], '', 0, ''
419
+ check_validity
420
+
421
+ send_request FUNCTION_ENABLE, [], '', 8, ''
374
422
  end
375
423
 
376
424
  # Disables the driver chip. The configurations are kept (maximum velocity,
377
425
  # acceleration, etc) but the motor is not driven until it is enabled again.
426
+ #
427
+ # .. warning::
428
+ # Disabling the driver chip while the motor is still turning can damage the
429
+ # driver chip. The motor should be stopped calling BrickStepper#stop function
430
+ # before disabling the motor power. The BrickStepper#stop function will **not**
431
+ # wait until the motor is actually stopped. You have to explicitly wait for the
432
+ # appropriate time after calling the BrickStepper#stop function before calling
433
+ # the BrickStepper#disable function.
378
434
  def disable
379
- send_request FUNCTION_DISABLE, [], '', 0, ''
435
+ check_validity
436
+
437
+ send_request FUNCTION_DISABLE, [], '', 8, ''
380
438
  end
381
439
 
382
440
  # Returns *true* if the driver chip is enabled, *false* otherwise.
383
441
  def is_enabled
384
- send_request FUNCTION_IS_ENABLED, [], '', 1, '?'
442
+ check_validity
443
+
444
+ send_request FUNCTION_IS_ENABLED, [], '', 9, '?'
385
445
  end
386
446
 
387
- # Sets the decay mode of the stepper motor. The possible value range is
388
- # between 0 and 65535. A value of 0 sets the fast decay mode, a value of
447
+ # Sets the decay mode of the stepper motor.
448
+ # A value of 0 sets the fast decay mode, a value of
389
449
  # 65535 sets the slow decay mode and a value in between sets the mixed
390
450
  # decay mode.
391
451
  #
@@ -393,7 +453,7 @@ module Tinkerforge
393
453
  # is enabled (see BrickStepper#set_sync_rect).
394
454
  #
395
455
  # For a good explanation of the different decay modes see
396
- # `this <http://ebldc.com/?p=86/>`__ blog post by Avayan.
456
+ # `this <https://ebldc.com/?p=86/>`__ blog post by Avayan.
397
457
  #
398
458
  # A good decay mode is unfortunately different for every motor. The best
399
459
  # way to work out a good decay mode for your stepper motor, if you can't
@@ -404,36 +464,40 @@ module Tinkerforge
404
464
  # Generally, fast decay mode (small value) will be noisier but also
405
465
  # allow higher motor speeds.
406
466
  #
407
- # The default value is 10000.
408
- #
409
467
  # .. note::
410
468
  # There is unfortunately no formula to calculate a perfect decay
411
469
  # mode for a given stepper motor. If you have problems with loud noises
412
470
  # or the maximum motor speed is too slow, you should try to tinker with
413
471
  # the decay value
414
472
  def set_decay(decay)
415
- send_request FUNCTION_SET_DECAY, [decay], 'S', 0, ''
473
+ check_validity
474
+
475
+ send_request FUNCTION_SET_DECAY, [decay], 'S', 8, ''
416
476
  end
417
477
 
418
478
  # Returns the decay mode as set by BrickStepper#set_decay.
419
479
  def get_decay
420
- send_request FUNCTION_GET_DECAY, [], '', 2, 'S'
480
+ check_validity
481
+
482
+ send_request FUNCTION_GET_DECAY, [], '', 10, 'S'
421
483
  end
422
484
 
423
- # Sets the minimum voltage in mV, below which the CALLBACK_UNDER_VOLTAGE callback
485
+ # Sets the minimum voltage, below which the CALLBACK_UNDER_VOLTAGE callback
424
486
  # is triggered. The minimum possible value that works with the Stepper Brick is 8V.
425
487
  # You can use this function to detect the discharge of a battery that is used
426
488
  # to drive the stepper motor. If you have a fixed power supply, you likely do
427
489
  # not need this functionality.
428
- #
429
- # The default value is 8V.
430
490
  def set_minimum_voltage(voltage)
431
- send_request FUNCTION_SET_MINIMUM_VOLTAGE, [voltage], 'S', 0, ''
491
+ check_validity
492
+
493
+ send_request FUNCTION_SET_MINIMUM_VOLTAGE, [voltage], 'S', 8, ''
432
494
  end
433
495
 
434
496
  # Returns the minimum voltage as set by BrickStepper#set_minimum_voltage.
435
497
  def get_minimum_voltage
436
- send_request FUNCTION_GET_MINIMUM_VOLTAGE, [], '', 2, 'S'
498
+ check_validity
499
+
500
+ send_request FUNCTION_GET_MINIMUM_VOLTAGE, [], '', 10, 'S'
437
501
  end
438
502
 
439
503
  # Turns synchronous rectification on or off (*true* or *false*).
@@ -450,32 +514,35 @@ module Tinkerforge
450
514
  # stepper motor with a large inductivity we strongly
451
515
  # suggest that you disable synchronous rectification. Otherwise the
452
516
  # Brick may not be able to cope with the load and overheat.
453
- #
454
- # The default value is *false*.
455
517
  def set_sync_rect(sync_rect)
456
- send_request FUNCTION_SET_SYNC_RECT, [sync_rect], '?', 0, ''
518
+ check_validity
519
+
520
+ send_request FUNCTION_SET_SYNC_RECT, [sync_rect], '?', 8, ''
457
521
  end
458
522
 
459
523
  # Returns *true* if synchronous rectification is enabled, *false* otherwise.
460
524
  def is_sync_rect
461
- send_request FUNCTION_IS_SYNC_RECT, [], '', 1, '?'
525
+ check_validity
526
+
527
+ send_request FUNCTION_IS_SYNC_RECT, [], '', 9, '?'
462
528
  end
463
529
 
464
- # Sets the time base of the velocity and the acceleration of the stepper brick
465
- # (in seconds).
530
+ # Sets the time base of the velocity and the acceleration of the stepper brick.
466
531
  #
467
532
  # For example, if you want to make one step every 1.5 seconds, you can set
468
533
  # the time base to 15 and the velocity to 10. Now the velocity is
469
534
  # 10steps/15s = 1steps/1.5s.
470
- #
471
- # The default value is 1.
472
535
  def set_time_base(time_base)
473
- send_request FUNCTION_SET_TIME_BASE, [time_base], 'L', 0, ''
536
+ check_validity
537
+
538
+ send_request FUNCTION_SET_TIME_BASE, [time_base], 'L', 8, ''
474
539
  end
475
540
 
476
541
  # Returns the time base as set by BrickStepper#set_time_base.
477
542
  def get_time_base
478
- send_request FUNCTION_GET_TIME_BASE, [], '', 4, 'L'
543
+ check_validity
544
+
545
+ send_request FUNCTION_GET_TIME_BASE, [], '', 12, 'L'
479
546
  end
480
547
 
481
548
  # Returns the following parameters: The current velocity,
@@ -484,26 +551,32 @@ module Tinkerforge
484
551
  #
485
552
  # There is also a callback for this function, see CALLBACK_ALL_DATA callback.
486
553
  def get_all_data
487
- send_request FUNCTION_GET_ALL_DATA, [], '', 16, 'S l l S S S'
554
+ check_validity
555
+
556
+ send_request FUNCTION_GET_ALL_DATA, [], '', 24, 'S l l S S S'
488
557
  end
489
558
 
490
- # Sets the period in ms with which the CALLBACK_ALL_DATA callback is triggered
559
+ # Sets the period with which the CALLBACK_ALL_DATA callback is triggered
491
560
  # periodically. A value of 0 turns the callback off.
492
561
  def set_all_data_period(period)
493
- send_request FUNCTION_SET_ALL_DATA_PERIOD, [period], 'L', 0, ''
562
+ check_validity
563
+
564
+ send_request FUNCTION_SET_ALL_DATA_PERIOD, [period], 'L', 8, ''
494
565
  end
495
566
 
496
567
  # Returns the period as set by BrickStepper#set_all_data_period.
497
568
  def get_all_data_period
498
- send_request FUNCTION_GET_ALL_DATA_PERIOD, [], '', 4, 'L'
569
+ check_validity
570
+
571
+ send_request FUNCTION_GET_ALL_DATA_PERIOD, [], '', 12, 'L'
499
572
  end
500
573
 
501
574
  # The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is
502
575
  # enabled, the Brick will try to adapt the baudrate for the communication
503
576
  # between Bricks and Bricklets according to the amount of data that is transferred.
504
577
  #
505
- # The baudrate will be increased exponentially if lots of data is send/received and
506
- # decreased linearly if little data is send/received.
578
+ # The baudrate will be increased exponentially if lots of data is sent/received and
579
+ # decreased linearly if little data is sent/received.
507
580
  #
508
581
  # This lowers the baudrate in applications where little data is transferred (e.g.
509
582
  # a weather station) and increases the robustness. If there is lots of data to transfer
@@ -517,20 +590,20 @@ module Tinkerforge
517
590
  # BrickStepper#set_spitfp_baudrate. If the dynamic baudrate is disabled, the baudrate
518
591
  # as set by BrickStepper#set_spitfp_baudrate will be used statically.
519
592
  #
520
- # The minimum dynamic baudrate has a value range of 400000 to 2000000 baud.
521
- #
522
- # By default dynamic baudrate is enabled and the minimum dynamic baudrate is 400000.
523
- #
524
593
  # .. versionadded:: 2.3.6$nbsp;(Firmware)
525
594
  def set_spitfp_baudrate_config(enable_dynamic_baudrate, minimum_dynamic_baudrate)
526
- send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 0, ''
595
+ check_validity
596
+
597
+ send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 8, ''
527
598
  end
528
599
 
529
600
  # Returns the baudrate config, see BrickStepper#set_spitfp_baudrate_config.
530
601
  #
531
602
  # .. versionadded:: 2.3.6$nbsp;(Firmware)
532
603
  def get_spitfp_baudrate_config
533
- send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 5, '? L'
604
+ check_validity
605
+
606
+ send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 13, '? L'
534
607
  end
535
608
 
536
609
  # Returns the timeout count for the different communication methods.
@@ -542,11 +615,12 @@ module Tinkerforge
542
615
  #
543
616
  # .. versionadded:: 2.3.4$nbsp;(Firmware)
544
617
  def get_send_timeout_count(communication_method)
545
- send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 4, 'L'
618
+ check_validity
619
+
620
+ send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 12, 'L'
546
621
  end
547
622
 
548
- # Sets the baudrate for a specific Bricklet port ('a' - 'd'). The
549
- # baudrate can be in the range 400000 to 2000000.
623
+ # Sets the baudrate for a specific Bricklet port.
550
624
  #
551
625
  # If you want to increase the throughput of Bricklets you can increase
552
626
  # the baudrate. If you get a high error count because of high
@@ -557,21 +631,23 @@ module Tinkerforge
557
631
  # function corresponds to the maximum baudrate (see BrickStepper#set_spitfp_baudrate_config).
558
632
  #
559
633
  # Regulatory testing is done with the default baudrate. If CE compatibility
560
- # or similar is necessary in you applications we recommend to not change
634
+ # or similar is necessary in your applications we recommend to not change
561
635
  # the baudrate.
562
636
  #
563
- # The default baudrate for all ports is 1400000.
564
- #
565
637
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
566
638
  def set_spitfp_baudrate(bricklet_port, baudrate)
567
- send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 0, ''
639
+ check_validity
640
+
641
+ send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 8, ''
568
642
  end
569
643
 
570
644
  # Returns the baudrate for a given Bricklet port, see BrickStepper#set_spitfp_baudrate.
571
645
  #
572
646
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
573
647
  def get_spitfp_baudrate(bricklet_port)
574
- send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 4, 'L'
648
+ check_validity
649
+
650
+ send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 12, 'L'
575
651
  end
576
652
 
577
653
  # Returns the error count for the communication between Brick and Bricklet.
@@ -588,7 +664,9 @@ module Tinkerforge
588
664
  #
589
665
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
590
666
  def get_spitfp_error_count(bricklet_port)
591
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 16, 'L L L L'
667
+ check_validity
668
+
669
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 24, 'L L L L'
592
670
  end
593
671
 
594
672
  # Enables the status LED.
@@ -600,7 +678,9 @@ module Tinkerforge
600
678
  #
601
679
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
602
680
  def enable_status_led
603
- send_request FUNCTION_ENABLE_STATUS_LED, [], '', 0, ''
681
+ check_validity
682
+
683
+ send_request FUNCTION_ENABLE_STATUS_LED, [], '', 8, ''
604
684
  end
605
685
 
606
686
  # Disables the status LED.
@@ -612,14 +692,18 @@ module Tinkerforge
612
692
  #
613
693
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
614
694
  def disable_status_led
615
- send_request FUNCTION_DISABLE_STATUS_LED, [], '', 0, ''
695
+ check_validity
696
+
697
+ send_request FUNCTION_DISABLE_STATUS_LED, [], '', 8, ''
616
698
  end
617
699
 
618
700
  # Returns *true* if the status LED is enabled, *false* otherwise.
619
701
  #
620
702
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
621
703
  def is_status_led_enabled
622
- send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 1, '?'
704
+ check_validity
705
+
706
+ send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 9, '?'
623
707
  end
624
708
 
625
709
  # Returns the firmware and protocol version and the name of the Bricklet for a
@@ -628,17 +712,21 @@ module Tinkerforge
628
712
  # This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet
629
713
  # plugins.
630
714
  def get_protocol1_bricklet_name(port)
631
- send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 44, 'C C3 Z40'
715
+ check_validity
716
+
717
+ send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 52, 'C C3 Z40'
632
718
  end
633
719
 
634
- # Returns the temperature in °C/10 as measured inside the microcontroller. The
720
+ # Returns the temperature as measured inside the microcontroller. The
635
721
  # value returned is not the ambient temperature!
636
722
  #
637
723
  # The temperature is only proportional to the real temperature and it has an
638
- # accuracy of +-15%. Practically it is only useful as an indicator for
724
+ # accuracy of ±15%. Practically it is only useful as an indicator for
639
725
  # temperature changes.
640
726
  def get_chip_temperature
641
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
727
+ check_validity
728
+
729
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
642
730
  end
643
731
 
644
732
  # Calling this function will reset the Brick. Calling this function
@@ -648,19 +736,43 @@ module Tinkerforge
648
736
  # calling functions on the existing ones will result in
649
737
  # undefined behavior!
650
738
  def reset
651
- send_request FUNCTION_RESET, [], '', 0, ''
739
+ check_validity
740
+
741
+ send_request FUNCTION_RESET, [], '', 8, ''
742
+ end
743
+
744
+ # Writes 32 bytes of firmware to the bricklet attached at the given port.
745
+ # The bytes are written to the position offset * 32.
746
+ #
747
+ # This function is used by Brick Viewer during flashing. It should not be
748
+ # necessary to call it in a normal user program.
749
+ def write_bricklet_plugin(port, offset, chunk)
750
+ check_validity
751
+
752
+ send_request FUNCTION_WRITE_BRICKLET_PLUGIN, [port, offset, chunk], 'k C C32', 8, ''
753
+ end
754
+
755
+ # Reads 32 bytes of firmware from the bricklet attached at the given port.
756
+ # The bytes are read starting at the position offset * 32.
757
+ #
758
+ # This function is used by Brick Viewer during flashing. It should not be
759
+ # necessary to call it in a normal user program.
760
+ def read_bricklet_plugin(port, offset)
761
+ check_validity
762
+
763
+ send_request FUNCTION_READ_BRICKLET_PLUGIN, [port, offset], 'k C', 40, 'C32'
652
764
  end
653
765
 
654
766
  # Returns the UID, the UID where the Brick is connected to,
655
767
  # the position, the hardware and firmware version as well as the
656
768
  # device identifier.
657
769
  #
658
- # The position can be '0'-'8' (stack position).
770
+ # The position is the position in the stack from '0' (bottom) to '8' (top).
659
771
  #
660
772
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
661
773
  # |device_identifier_constant|
662
774
  def get_identity
663
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
775
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
664
776
  end
665
777
 
666
778
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.