tinkerforge 2.1.24 → 2.1.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +156 -75
  3. data/lib/tinkerforge/brick_hat.rb +69 -31
  4. data/lib/tinkerforge/brick_hat_zero.rb +55 -23
  5. data/lib/tinkerforge/brick_imu.rb +185 -78
  6. data/lib/tinkerforge/brick_imu_v2.rb +209 -106
  7. data/lib/tinkerforge/brick_master.rb +491 -183
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +186 -102
  10. data/lib/tinkerforge/brick_silent_stepper.rb +247 -167
  11. data/lib/tinkerforge/brick_stepper.rb +211 -99
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +57 -23
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +104 -54
  14. data/lib/tinkerforge/bricklet_air_quality.rb +116 -59
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +50 -21
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +44 -24
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +65 -27
  18. data/lib/tinkerforge/bricklet_analog_in.rb +62 -25
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +56 -23
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +66 -25
  21. data/lib/tinkerforge/bricklet_analog_out.rb +22 -9
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +19 -8
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +53 -20
  24. data/lib/tinkerforge/bricklet_barometer.rb +100 -27
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +98 -37
  26. data/lib/tinkerforge/bricklet_can.rb +83 -19
  27. data/lib/tinkerforge/bricklet_can_v2.rb +171 -38
  28. data/lib/tinkerforge/bricklet_co2.rb +33 -14
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +97 -38
  30. data/lib/tinkerforge/bricklet_color.rb +68 -27
  31. data/lib/tinkerforge/bricklet_color_v2.rb +86 -33
  32. data/lib/tinkerforge/bricklet_compass.rb +77 -30
  33. data/lib/tinkerforge/bricklet_current12.rb +57 -24
  34. data/lib/tinkerforge/bricklet_current25.rb +57 -24
  35. data/lib/tinkerforge/bricklet_dc_v2.rb +521 -0
  36. data/lib/tinkerforge/bricklet_distance_ir.rb +56 -23
  37. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +82 -31
  38. data/lib/tinkerforge/bricklet_distance_us.rb +39 -16
  39. data/lib/tinkerforge/bricklet_distance_us_v2.rb +66 -25
  40. data/lib/tinkerforge/bricklet_dmx.rb +87 -34
  41. data/lib/tinkerforge/bricklet_dual_button.rb +23 -10
  42. data/lib/tinkerforge/bricklet_dual_button_v2.rb +63 -24
  43. data/lib/tinkerforge/bricklet_dual_relay.rb +26 -11
  44. data/lib/tinkerforge/bricklet_dust_detector.rb +39 -16
  45. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +87 -32
  46. data/lib/tinkerforge/bricklet_energy_monitor.rb +72 -27
  47. data/lib/tinkerforge/bricklet_gps.rb +63 -26
  48. data/lib/tinkerforge/bricklet_gps_v2.rb +116 -47
  49. data/lib/tinkerforge/bricklet_hall_effect.rb +42 -23
  50. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +70 -27
  51. data/lib/tinkerforge/bricklet_humidity.rb +50 -21
  52. data/lib/tinkerforge/bricklet_humidity_v2.rb +82 -31
  53. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  54. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +37 -14
  55. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +80 -29
  56. data/lib/tinkerforge/bricklet_industrial_counter.rb +100 -39
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +44 -17
  58. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +76 -29
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +35 -14
  60. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +72 -27
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +39 -16
  62. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -30
  63. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +48 -19
  65. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +137 -31
  66. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +60 -23
  67. data/lib/tinkerforge/bricklet_industrial_ptc.rb +475 -0
  68. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +35 -14
  69. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +66 -25
  70. data/lib/tinkerforge/bricklet_io16.rb +54 -21
  71. data/lib/tinkerforge/bricklet_io16_v2.rb +89 -34
  72. data/lib/tinkerforge/bricklet_io4.rb +54 -23
  73. data/lib/tinkerforge/bricklet_io4_v2.rb +95 -36
  74. data/lib/tinkerforge/bricklet_isolator.rb +72 -29
  75. data/lib/tinkerforge/bricklet_joystick.rb +58 -25
  76. data/lib/tinkerforge/bricklet_joystick_v2.rb +67 -26
  77. data/lib/tinkerforge/bricklet_laser_range_finder.rb +81 -32
  78. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +95 -36
  79. data/lib/tinkerforge/bricklet_lcd_128x64.rb +191 -70
  80. data/lib/tinkerforge/bricklet_lcd_16x2.rb +44 -18
  81. data/lib/tinkerforge/bricklet_lcd_20x4.rb +57 -23
  82. data/lib/tinkerforge/bricklet_led_strip.rb +59 -22
  83. data/lib/tinkerforge/bricklet_led_strip_v2.rb +90 -46
  84. data/lib/tinkerforge/bricklet_line.rb +33 -14
  85. data/lib/tinkerforge/bricklet_linear_poti.rb +50 -21
  86. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +54 -21
  87. data/lib/tinkerforge/bricklet_load_cell.rb +60 -23
  88. data/lib/tinkerforge/bricklet_load_cell_v2.rb +79 -30
  89. data/lib/tinkerforge/bricklet_moisture.rb +39 -16
  90. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  91. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +61 -27
  92. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +70 -27
  93. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -13
  94. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +75 -28
  95. data/lib/tinkerforge/bricklet_nfc.rb +126 -62
  96. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  97. data/lib/tinkerforge/bricklet_oled_128x64.rb +28 -11
  98. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +65 -24
  99. data/lib/tinkerforge/bricklet_oled_64x48.rb +28 -11
  100. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  101. data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -28
  102. data/lib/tinkerforge/bricklet_particulate_matter.rb +74 -30
  103. data/lib/tinkerforge/bricklet_performance_dc.rb +682 -0
  104. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +18 -9
  105. data/lib/tinkerforge/bricklet_piezo_speaker.rb +21 -10
  106. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +79 -42
  107. data/lib/tinkerforge/bricklet_ptc.rb +73 -42
  108. data/lib/tinkerforge/bricklet_ptc_v2.rb +94 -48
  109. data/lib/tinkerforge/bricklet_real_time_clock.rb +44 -33
  110. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +77 -44
  111. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  112. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  113. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  114. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  115. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  116. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  117. data/lib/tinkerforge/bricklet_rotary_encoder.rb +38 -19
  118. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +59 -24
  119. data/lib/tinkerforge/bricklet_rotary_poti.rb +52 -28
  120. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +56 -23
  121. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  122. data/lib/tinkerforge/bricklet_rs232_v2.rb +117 -44
  123. data/lib/tinkerforge/bricklet_rs485.rb +222 -95
  124. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  125. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +74 -35
  126. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  127. data/lib/tinkerforge/bricklet_silent_stepper_v2.rb +1024 -0
  128. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  129. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  130. data/lib/tinkerforge/bricklet_sound_intensity.rb +34 -18
  131. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +71 -31
  132. data/lib/tinkerforge/bricklet_temperature.rb +39 -16
  133. data/lib/tinkerforge/bricklet_temperature_ir.rb +56 -23
  134. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +70 -27
  135. data/lib/tinkerforge/bricklet_temperature_v2.rb +60 -25
  136. data/lib/tinkerforge/bricklet_thermal_imaging.rb +104 -44
  137. data/lib/tinkerforge/bricklet_thermocouple.rb +44 -24
  138. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +64 -27
  139. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  140. data/lib/tinkerforge/bricklet_uv_light.rb +35 -18
  141. data/lib/tinkerforge/bricklet_uv_light_v2.rb +84 -37
  142. data/lib/tinkerforge/bricklet_voltage.rb +51 -28
  143. data/lib/tinkerforge/bricklet_voltage_current.rb +90 -73
  144. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +89 -68
  145. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +79 -30
  146. data/lib/tinkerforge/device_display_names.rb +170 -0
  147. data/lib/tinkerforge/ip_connection.rb +153 -33
  148. data/lib/tinkerforge/version.rb +1 -1
  149. metadata +11 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: '079f652eea712eed74c2d5cd78a755758a697e3f1f56d494f27d380cedceb20f'
4
- data.tar.gz: cca1e723fa33b5f5b7359c4b9a369f781a0607656dd8e2099f8df92556232066
2
+ SHA1:
3
+ metadata.gz: 230f7a5c93853c69863d8547f48eebcf6a07a776
4
+ data.tar.gz: 2db97f5f906248e1216b0ddd10eb27e9ef9fcebc
5
5
  SHA512:
6
- metadata.gz: 668fbf0aac5f208792cad08bbc3428d7b6d6cc06f11abe636938a6a85c9e140dd722343a3d268e83ffee90b28ec5d55815651d935dfe9ecdd82f012f8c1f23e4
7
- data.tar.gz: 15f365b69eeda8a8b07d54a2422a08036b1bc4f8d6a40090dd4360c53afe3bee77170cc3d563f6b8d28c6d86fd9395da5c6e2790357dd6c36b17cf3de1749406
6
+ metadata.gz: 3b441d9e549ea256d67ddf9424aa9f6edcfc14ca9a20c113a93fe5c4d69123d1a3f78226cd95cb41a62b7831c5f1d05ec4dd1540287e361d0cadceb78d479658
7
+ data.tar.gz: 8a395c5ce48fb09f26f437ec3ccbcc683d335d1d584c42f34f70c5f8845a92320a26184b7061d0aa201681d24b52aae9bc8c6fb5478a17f3ea1372d2943c4320
@@ -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 2021-05-06. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.29 #
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
@@ -387,21 +430,23 @@ module Tinkerforge
387
430
  # function corresponds to the maximum baudrate (see BrickDC#set_spitfp_baudrate_config).
388
431
  #
389
432
  # Regulatory testing is done with the default baudrate. If CE compatibility
390
- # or similar is necessary in you applications we recommend to not change
433
+ # or similar is necessary in your 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>.