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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '079f652eea712eed74c2d5cd78a755758a697e3f1f56d494f27d380cedceb20f'
4
- data.tar.gz: cca1e723fa33b5f5b7359c4b9a369f781a0607656dd8e2099f8df92556232066
3
+ metadata.gz: 1708baaffbfed4e5c76ecc11e739048f94de411c2702644e18067b18b78e40e3
4
+ data.tar.gz: 9eb324198747efc2053a78820afccbc7dcf24c45e40de9abbf5868de2f1d8158
5
5
  SHA512:
6
- metadata.gz: 668fbf0aac5f208792cad08bbc3428d7b6d6cc06f11abe636938a6a85c9e140dd722343a3d268e83ffee90b28ec5d55815651d935dfe9ecdd82f012f8c1f23e4
7
- data.tar.gz: 15f365b69eeda8a8b07d54a2422a08036b1bc4f8d6a40090dd4360c53afe3bee77170cc3d563f6b8d28c6d86fd9395da5c6e2790357dd6c36b17cf3de1749406
6
+ metadata.gz: d2025d9cab327b75f14e9ff0c7148b24c558ede545b9599ed190317625ab6f77070261158bfe332b7fc476d408e3878aaf21d84405f7c1d4eea1754d45faf6af
7
+ data.tar.gz: 548607d5c009e3364c5db4546a25a8e7eab0becb7804a7e2914a1f41bf857be46a98e1c1b7015adc137d3d613463bc6f97112d23ee9b97d4ac92c78662ec3cb1
@@ -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
  # Drives one brushed DC motor with up to 28V and 5A (peak)
14
16
  class BrickDC < Device
@@ -16,8 +18,7 @@ module Tinkerforge
16
18
  DEVICE_DISPLAY_NAME = 'DC Brick' # :nodoc:
17
19
 
18
20
  # This callback is triggered when the input voltage drops below the value set by
19
- # BrickDC#set_minimum_voltage. The parameter is the current voltage given
20
- # in mV.
21
+ # BrickDC#set_minimum_voltage. The parameter is the current voltage.
21
22
  CALLBACK_UNDER_VOLTAGE = 21
22
23
 
23
24
  # This callback is triggered if either the current consumption
@@ -88,6 +89,8 @@ module Tinkerforge
88
89
  FUNCTION_GET_PROTOCOL1_BRICKLET_NAME = 241 # :nodoc:
89
90
  FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
90
91
  FUNCTION_RESET = 243 # :nodoc:
92
+ FUNCTION_WRITE_BRICKLET_PLUGIN = 246 # :nodoc:
93
+ FUNCTION_READ_BRICKLET_PLUGIN = 247 # :nodoc:
91
94
  FUNCTION_GET_IDENTITY = 255 # :nodoc:
92
95
 
93
96
  DRIVE_MODE_DRIVE_BRAKE = 0 # :nodoc:
@@ -104,7 +107,7 @@ module Tinkerforge
104
107
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
105
108
  # the IP Connection <tt>ipcon</tt>.
106
109
  def initialize(uid, ipcon)
107
- super uid, ipcon
110
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
108
111
 
109
112
  @api_version = [2, 0, 3]
110
113
 
@@ -140,13 +143,16 @@ module Tinkerforge
140
143
  @response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
141
144
  @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
142
145
  @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
146
+ @response_expected[FUNCTION_WRITE_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_FALSE
147
+ @response_expected[FUNCTION_READ_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_ALWAYS_TRUE
143
148
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
144
149
 
145
- @callback_formats[CALLBACK_UNDER_VOLTAGE] = 'S'
146
- @callback_formats[CALLBACK_EMERGENCY_SHUTDOWN] = ''
147
- @callback_formats[CALLBACK_VELOCITY_REACHED] = 's'
148
- @callback_formats[CALLBACK_CURRENT_VELOCITY] = 's'
150
+ @callback_formats[CALLBACK_UNDER_VOLTAGE] = [10, 'S']
151
+ @callback_formats[CALLBACK_EMERGENCY_SHUTDOWN] = [8, '']
152
+ @callback_formats[CALLBACK_VELOCITY_REACHED] = [10, 's']
153
+ @callback_formats[CALLBACK_CURRENT_VELOCITY] = [10, 's']
149
154
 
155
+ @ipcon.add_device self
150
156
  end
151
157
 
152
158
  # Sets the velocity of the motor. Whereas -32767 is full speed backward,
@@ -158,22 +164,26 @@ module Tinkerforge
158
164
  # controlled, e.g. a velocity of 3277 sets a PWM with a 10% duty cycle.
159
165
  # You can not only control the duty cycle of the PWM but also the frequency,
160
166
  # see BrickDC#set_pwm_frequency.
161
- #
162
- # The default velocity is 0.
163
167
  def set_velocity(velocity)
164
- send_request FUNCTION_SET_VELOCITY, [velocity], 's', 0, ''
168
+ check_validity
169
+
170
+ send_request FUNCTION_SET_VELOCITY, [velocity], 's', 8, ''
165
171
  end
166
172
 
167
173
  # Returns the velocity as set by BrickDC#set_velocity.
168
174
  def get_velocity
169
- send_request FUNCTION_GET_VELOCITY, [], '', 2, 's'
175
+ check_validity
176
+
177
+ send_request FUNCTION_GET_VELOCITY, [], '', 10, 's'
170
178
  end
171
179
 
172
180
  # Returns the *current* velocity of the motor. This value is different
173
181
  # from BrickDC#get_velocity whenever the motor is currently accelerating
174
182
  # to a goal set by BrickDC#set_velocity.
175
183
  def get_current_velocity
176
- send_request FUNCTION_GET_CURRENT_VELOCITY, [], '', 2, 's'
184
+ check_validity
185
+
186
+ send_request FUNCTION_GET_CURRENT_VELOCITY, [], '', 10, 's'
177
187
  end
178
188
 
179
189
  # Sets the acceleration of the motor. It is given in *velocity/s*. An
@@ -186,34 +196,38 @@ module Tinkerforge
186
196
  #
187
197
  # If acceleration is set to 0, there is no speed ramping, i.e. a new velocity
188
198
  # is immediately given to the motor.
189
- #
190
- # The default acceleration is 10000.
191
199
  def set_acceleration(acceleration)
192
- send_request FUNCTION_SET_ACCELERATION, [acceleration], 'S', 0, ''
200
+ check_validity
201
+
202
+ send_request FUNCTION_SET_ACCELERATION, [acceleration], 'S', 8, ''
193
203
  end
194
204
 
195
205
  # Returns the acceleration as set by BrickDC#set_acceleration.
196
206
  def get_acceleration
197
- send_request FUNCTION_GET_ACCELERATION, [], '', 2, 'S'
207
+ check_validity
208
+
209
+ send_request FUNCTION_GET_ACCELERATION, [], '', 10, 'S'
198
210
  end
199
211
 
200
- # Sets the frequency (in Hz) of the PWM with which the motor is driven.
201
- # The possible range of the frequency is 1-20000Hz. Often a high frequency
212
+ # Sets the frequency of the PWM with which the motor is driven.
213
+ # Often a high frequency
202
214
  # is less noisy and the motor runs smoother. However, with a low frequency
203
215
  # there are less switches and therefore fewer switching losses. Also with
204
216
  # most motors lower frequencies enable higher torque.
205
217
  #
206
218
  # If you have no idea what all this means, just ignore this function and use
207
219
  # the default frequency, it will very likely work fine.
208
- #
209
- # The default frequency is 15 kHz.
210
220
  def set_pwm_frequency(frequency)
211
- send_request FUNCTION_SET_PWM_FREQUENCY, [frequency], 'S', 0, ''
221
+ check_validity
222
+
223
+ send_request FUNCTION_SET_PWM_FREQUENCY, [frequency], 'S', 8, ''
212
224
  end
213
225
 
214
- # Returns the PWM frequency (in Hz) as set by BrickDC#set_pwm_frequency.
226
+ # Returns the PWM frequency as set by BrickDC#set_pwm_frequency.
215
227
  def get_pwm_frequency
216
- send_request FUNCTION_GET_PWM_FREQUENCY, [], '', 2, 'S'
228
+ check_validity
229
+
230
+ send_request FUNCTION_GET_PWM_FREQUENCY, [], '', 10, 'S'
217
231
  end
218
232
 
219
233
  # Executes an active full brake.
@@ -225,17 +239,21 @@ module Tinkerforge
225
239
  #
226
240
  # Call BrickDC#set_velocity with 0 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
- # Returns the stack input voltage in mV. The stack input voltage is the
247
+ # Returns the stack input voltage. The stack input voltage is the
232
248
  # voltage that is supplied via the stack, i.e. it is given by a
233
249
  # Step-Down or Step-Up Power Supply.
234
250
  def get_stack_input_voltage
235
- send_request FUNCTION_GET_STACK_INPUT_VOLTAGE, [], '', 2, 'S'
251
+ check_validity
252
+
253
+ send_request FUNCTION_GET_STACK_INPUT_VOLTAGE, [], '', 10, 'S'
236
254
  end
237
255
 
238
- # Returns the external input voltage in mV. The external input voltage is
256
+ # Returns the external input voltage. The external input voltage is
239
257
  # given via the black power input connector on the DC Brick.
240
258
  #
241
259
  # If there is an external input voltage and a stack input voltage, the motor
@@ -248,45 +266,65 @@ module Tinkerforge
248
266
  # the external connection, it will immediately be driven by the high
249
267
  # stack voltage.
250
268
  def get_external_input_voltage
251
- send_request FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE, [], '', 2, 'S'
269
+ check_validity
270
+
271
+ send_request FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE, [], '', 10, 'S'
252
272
  end
253
273
 
254
- # Returns the current consumption of the motor in mA.
274
+ # Returns the current consumption of the motor.
255
275
  def get_current_consumption
256
- send_request FUNCTION_GET_CURRENT_CONSUMPTION, [], '', 2, 'S'
276
+ check_validity
277
+
278
+ send_request FUNCTION_GET_CURRENT_CONSUMPTION, [], '', 10, 'S'
257
279
  end
258
280
 
259
281
  # Enables the driver chip. The driver parameters can be configured (velocity,
260
282
  # acceleration, etc) before it is enabled.
261
283
  def enable
262
- send_request FUNCTION_ENABLE, [], '', 0, ''
284
+ check_validity
285
+
286
+ send_request FUNCTION_ENABLE, [], '', 8, ''
263
287
  end
264
288
 
265
289
  # Disables the driver chip. The configurations are kept (velocity,
266
290
  # acceleration, etc) but the motor is not driven until it is enabled again.
291
+ #
292
+ # .. warning::
293
+ # Disabling the driver chip while the motor is still turning can damage the
294
+ # driver chip. The motor should be stopped calling BrickDC#set_velocity with 0
295
+ # before disabling the motor power. The BrickDC#set_velocity function will **not**
296
+ # wait until the motor is actually stopped. You have to explicitly wait for the
297
+ # appropriate time after calling the BrickDC#set_velocity function before calling
298
+ # the BrickDC#disable function.
267
299
  def disable
268
- send_request FUNCTION_DISABLE, [], '', 0, ''
300
+ check_validity
301
+
302
+ send_request FUNCTION_DISABLE, [], '', 8, ''
269
303
  end
270
304
 
271
305
  # Returns *true* if the driver chip is enabled, *false* otherwise.
272
306
  def is_enabled
273
- send_request FUNCTION_IS_ENABLED, [], '', 1, '?'
307
+ check_validity
308
+
309
+ send_request FUNCTION_IS_ENABLED, [], '', 9, '?'
274
310
  end
275
311
 
276
- # Sets the minimum voltage in mV, below which the CALLBACK_UNDER_VOLTAGE callback
312
+ # Sets the minimum voltage, below which the CALLBACK_UNDER_VOLTAGE callback
277
313
  # is triggered. The minimum possible value that works with the DC Brick is 6V.
278
314
  # You can use this function to detect the discharge of a battery that is used
279
315
  # to drive the motor. If you have a fixed power supply, you likely do not need
280
316
  # this functionality.
281
- #
282
- # The default value is 6V.
283
317
  def set_minimum_voltage(voltage)
284
- send_request FUNCTION_SET_MINIMUM_VOLTAGE, [voltage], 'S', 0, ''
318
+ check_validity
319
+
320
+ send_request FUNCTION_SET_MINIMUM_VOLTAGE, [voltage], 'S', 8, ''
285
321
  end
286
322
 
287
323
  # Returns the minimum voltage as set by BrickDC#set_minimum_voltage
288
324
  def get_minimum_voltage
289
- send_request FUNCTION_GET_MINIMUM_VOLTAGE, [], '', 2, 'S'
325
+ check_validity
326
+
327
+ send_request FUNCTION_GET_MINIMUM_VOLTAGE, [], '', 10, 'S'
290
328
  end
291
329
 
292
330
  # Sets the drive mode. Possible modes are:
@@ -304,36 +342,40 @@ module Tinkerforge
304
342
  # In Drive/Coast mode, the motor is always either driving or freewheeling.
305
343
  # Advantages are: Less current consumption and less demands on the motor and
306
344
  # driver chip.
307
- #
308
- # The default value is 0 = Drive/Brake.
309
345
  def set_drive_mode(mode)
310
- send_request FUNCTION_SET_DRIVE_MODE, [mode], 'C', 0, ''
346
+ check_validity
347
+
348
+ send_request FUNCTION_SET_DRIVE_MODE, [mode], 'C', 8, ''
311
349
  end
312
350
 
313
351
  # Returns the drive mode, as set by BrickDC#set_drive_mode.
314
352
  def get_drive_mode
315
- send_request FUNCTION_GET_DRIVE_MODE, [], '', 1, 'C'
353
+ check_validity
354
+
355
+ send_request FUNCTION_GET_DRIVE_MODE, [], '', 9, 'C'
316
356
  end
317
357
 
318
- # Sets a period in ms with which the CALLBACK_CURRENT_VELOCITY callback is triggered.
358
+ # Sets a period with which the CALLBACK_CURRENT_VELOCITY callback is triggered.
319
359
  # A period of 0 turns the callback off.
320
- #
321
- # The default value is 0.
322
360
  def set_current_velocity_period(period)
323
- send_request FUNCTION_SET_CURRENT_VELOCITY_PERIOD, [period], 'S', 0, ''
361
+ check_validity
362
+
363
+ send_request FUNCTION_SET_CURRENT_VELOCITY_PERIOD, [period], 'S', 8, ''
324
364
  end
325
365
 
326
366
  # Returns the period as set by BrickDC#set_current_velocity_period.
327
367
  def get_current_velocity_period
328
- send_request FUNCTION_GET_CURRENT_VELOCITY_PERIOD, [], '', 2, 'S'
368
+ check_validity
369
+
370
+ send_request FUNCTION_GET_CURRENT_VELOCITY_PERIOD, [], '', 10, 'S'
329
371
  end
330
372
 
331
373
  # The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is
332
374
  # enabled, the Brick will try to adapt the baudrate for the communication
333
375
  # between Bricks and Bricklets according to the amount of data that is transferred.
334
376
  #
335
- # The baudrate will be increased exponentially if lots of data is send/received and
336
- # decreased linearly if little data is send/received.
377
+ # The baudrate will be increased exponentially if lots of data is sent/received and
378
+ # decreased linearly if little data is sent/received.
337
379
  #
338
380
  # This lowers the baudrate in applications where little data is transferred (e.g.
339
381
  # a weather station) and increases the robustness. If there is lots of data to transfer
@@ -347,20 +389,20 @@ module Tinkerforge
347
389
  # BrickDC#set_spitfp_baudrate. If the dynamic baudrate is disabled, the baudrate
348
390
  # as set by BrickDC#set_spitfp_baudrate will be used statically.
349
391
  #
350
- # The minimum dynamic baudrate has a value range of 400000 to 2000000 baud.
351
- #
352
- # By default dynamic baudrate is enabled and the minimum dynamic baudrate is 400000.
353
- #
354
392
  # .. versionadded:: 2.3.5$nbsp;(Firmware)
355
393
  def set_spitfp_baudrate_config(enable_dynamic_baudrate, minimum_dynamic_baudrate)
356
- send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 0, ''
394
+ check_validity
395
+
396
+ send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 8, ''
357
397
  end
358
398
 
359
399
  # Returns the baudrate config, see BrickDC#set_spitfp_baudrate_config.
360
400
  #
361
401
  # .. versionadded:: 2.3.5$nbsp;(Firmware)
362
402
  def get_spitfp_baudrate_config
363
- send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 5, '? L'
403
+ check_validity
404
+
405
+ send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 13, '? L'
364
406
  end
365
407
 
366
408
  # Returns the timeout count for the different communication methods.
@@ -372,11 +414,12 @@ module Tinkerforge
372
414
  #
373
415
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
374
416
  def get_send_timeout_count(communication_method)
375
- send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 4, 'L'
417
+ check_validity
418
+
419
+ send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 12, 'L'
376
420
  end
377
421
 
378
- # Sets the baudrate for a specific Bricklet port ('a' - 'd'). The
379
- # baudrate can be in the range 400000 to 2000000.
422
+ # Sets the baudrate for a specific Bricklet port.
380
423
  #
381
424
  # If you want to increase the throughput of Bricklets you can increase
382
425
  # the baudrate. If you get a high error count because of high
@@ -390,18 +433,20 @@ module Tinkerforge
390
433
  # or similar is necessary in you applications we recommend to not change
391
434
  # the baudrate.
392
435
  #
393
- # The default baudrate for all ports is 1400000.
394
- #
395
436
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
396
437
  def set_spitfp_baudrate(bricklet_port, baudrate)
397
- send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 0, ''
438
+ check_validity
439
+
440
+ send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 8, ''
398
441
  end
399
442
 
400
443
  # Returns the baudrate for a given Bricklet port, see BrickDC#set_spitfp_baudrate.
401
444
  #
402
445
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
403
446
  def get_spitfp_baudrate(bricklet_port)
404
- send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 4, 'L'
447
+ check_validity
448
+
449
+ send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 12, 'L'
405
450
  end
406
451
 
407
452
  # Returns the error count for the communication between Brick and Bricklet.
@@ -418,7 +463,9 @@ module Tinkerforge
418
463
  #
419
464
  # .. versionadded:: 2.3.3$nbsp;(Firmware)
420
465
  def get_spitfp_error_count(bricklet_port)
421
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 16, 'L L L L'
466
+ check_validity
467
+
468
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 24, 'L L L L'
422
469
  end
423
470
 
424
471
  # Enables the status LED.
@@ -430,7 +477,9 @@ module Tinkerforge
430
477
  #
431
478
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
432
479
  def enable_status_led
433
- send_request FUNCTION_ENABLE_STATUS_LED, [], '', 0, ''
480
+ check_validity
481
+
482
+ send_request FUNCTION_ENABLE_STATUS_LED, [], '', 8, ''
434
483
  end
435
484
 
436
485
  # Disables the status LED.
@@ -442,14 +491,18 @@ module Tinkerforge
442
491
  #
443
492
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
444
493
  def disable_status_led
445
- send_request FUNCTION_DISABLE_STATUS_LED, [], '', 0, ''
494
+ check_validity
495
+
496
+ send_request FUNCTION_DISABLE_STATUS_LED, [], '', 8, ''
446
497
  end
447
498
 
448
499
  # Returns *true* if the status LED is enabled, *false* otherwise.
449
500
  #
450
501
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
451
502
  def is_status_led_enabled
452
- send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 1, '?'
503
+ check_validity
504
+
505
+ send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 9, '?'
453
506
  end
454
507
 
455
508
  # Returns the firmware and protocol version and the name of the Bricklet for a
@@ -458,17 +511,21 @@ module Tinkerforge
458
511
  # This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet
459
512
  # plugins.
460
513
  def get_protocol1_bricklet_name(port)
461
- send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 44, 'C C3 Z40'
514
+ check_validity
515
+
516
+ send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 52, 'C C3 Z40'
462
517
  end
463
518
 
464
- # Returns the temperature in °C/10 as measured inside the microcontroller. The
519
+ # Returns the temperature as measured inside the microcontroller. The
465
520
  # value returned is not the ambient temperature!
466
521
  #
467
522
  # The temperature is only proportional to the real temperature and it has an
468
523
  # accuracy of ±15%. Practically it is only useful as an indicator for
469
524
  # temperature changes.
470
525
  def get_chip_temperature
471
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
526
+ check_validity
527
+
528
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
472
529
  end
473
530
 
474
531
  # Calling this function will reset the Brick. Calling this function
@@ -478,19 +535,43 @@ module Tinkerforge
478
535
  # calling functions on the existing ones will result in
479
536
  # undefined behavior!
480
537
  def reset
481
- send_request FUNCTION_RESET, [], '', 0, ''
538
+ check_validity
539
+
540
+ send_request FUNCTION_RESET, [], '', 8, ''
541
+ end
542
+
543
+ # Writes 32 bytes of firmware to the bricklet attached at the given port.
544
+ # The bytes are written to the position offset * 32.
545
+ #
546
+ # This function is used by Brick Viewer during flashing. It should not be
547
+ # necessary to call it in a normal user program.
548
+ def write_bricklet_plugin(port, offset, chunk)
549
+ check_validity
550
+
551
+ send_request FUNCTION_WRITE_BRICKLET_PLUGIN, [port, offset, chunk], 'k C C32', 8, ''
552
+ end
553
+
554
+ # Reads 32 bytes of firmware from the bricklet attached at the given port.
555
+ # The bytes are read starting at the position offset * 32.
556
+ #
557
+ # This function is used by Brick Viewer during flashing. It should not be
558
+ # necessary to call it in a normal user program.
559
+ def read_bricklet_plugin(port, offset)
560
+ check_validity
561
+
562
+ send_request FUNCTION_READ_BRICKLET_PLUGIN, [port, offset], 'k C', 40, 'C32'
482
563
  end
483
564
 
484
565
  # Returns the UID, the UID where the Brick is connected to,
485
566
  # the position, the hardware and firmware version as well as the
486
567
  # device identifier.
487
568
  #
488
- # The position can be '0'-'8' (stack position).
569
+ # The position is the position in the stack from '0' (bottom) to '8' (top).
489
570
  #
490
571
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
491
572
  # |device_identifier_constant|
492
573
  def get_identity
493
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
574
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
494
575
  end
495
576
 
496
577
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.