tinkerforge 2.1.24 → 2.1.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +155 -74
  3. data/lib/tinkerforge/brick_hat.rb +70 -30
  4. data/lib/tinkerforge/brick_hat_zero.rb +56 -22
  5. data/lib/tinkerforge/brick_imu.rb +184 -77
  6. data/lib/tinkerforge/brick_imu_v2.rb +208 -105
  7. data/lib/tinkerforge/brick_master.rb +484 -182
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +185 -101
  10. data/lib/tinkerforge/brick_silent_stepper.rb +246 -166
  11. data/lib/tinkerforge/brick_stepper.rb +210 -98
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +58 -23
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +105 -54
  14. data/lib/tinkerforge/bricklet_air_quality.rb +117 -59
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +51 -21
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +40 -22
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -25
  18. data/lib/tinkerforge/bricklet_analog_in.rb +63 -25
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +57 -23
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +67 -25
  21. data/lib/tinkerforge/bricklet_analog_out.rb +23 -9
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +20 -8
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +54 -20
  24. data/lib/tinkerforge/bricklet_barometer.rb +66 -26
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +99 -37
  26. data/lib/tinkerforge/bricklet_can.rb +83 -18
  27. data/lib/tinkerforge/bricklet_can_v2.rb +172 -38
  28. data/lib/tinkerforge/bricklet_co2.rb +34 -14
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +97 -37
  30. data/lib/tinkerforge/bricklet_color.rb +69 -27
  31. data/lib/tinkerforge/bricklet_color_v2.rb +87 -33
  32. data/lib/tinkerforge/bricklet_compass.rb +78 -30
  33. data/lib/tinkerforge/bricklet_current12.rb +58 -24
  34. data/lib/tinkerforge/bricklet_current25.rb +58 -24
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +57 -23
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +83 -31
  37. data/lib/tinkerforge/bricklet_distance_us.rb +40 -16
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +67 -25
  39. data/lib/tinkerforge/bricklet_dmx.rb +88 -34
  40. data/lib/tinkerforge/bricklet_dual_button.rb +24 -10
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -24
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -11
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +40 -16
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +88 -32
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +73 -27
  46. data/lib/tinkerforge/bricklet_gps.rb +64 -26
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +117 -47
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -23
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +71 -27
  50. data/lib/tinkerforge/bricklet_humidity.rb +51 -21
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +83 -31
  52. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +38 -14
  53. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +81 -29
  54. data/lib/tinkerforge/bricklet_industrial_counter.rb +101 -39
  55. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +45 -17
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +77 -29
  57. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -14
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +73 -27
  59. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +40 -16
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +49 -19
  62. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +82 -30
  63. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +61 -23
  64. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -14
  65. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -25
  66. data/lib/tinkerforge/bricklet_io16.rb +55 -21
  67. data/lib/tinkerforge/bricklet_io16_v2.rb +90 -34
  68. data/lib/tinkerforge/bricklet_io4.rb +55 -23
  69. data/lib/tinkerforge/bricklet_io4_v2.rb +96 -36
  70. data/lib/tinkerforge/bricklet_isolator.rb +72 -28
  71. data/lib/tinkerforge/bricklet_joystick.rb +59 -25
  72. data/lib/tinkerforge/bricklet_joystick_v2.rb +68 -26
  73. data/lib/tinkerforge/bricklet_laser_range_finder.rb +82 -32
  74. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +96 -36
  75. data/lib/tinkerforge/bricklet_lcd_128x64.rb +192 -70
  76. data/lib/tinkerforge/bricklet_lcd_16x2.rb +45 -18
  77. data/lib/tinkerforge/bricklet_lcd_20x4.rb +58 -23
  78. data/lib/tinkerforge/bricklet_led_strip.rb +60 -22
  79. data/lib/tinkerforge/bricklet_led_strip_v2.rb +91 -46
  80. data/lib/tinkerforge/bricklet_line.rb +34 -14
  81. data/lib/tinkerforge/bricklet_linear_poti.rb +51 -21
  82. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -21
  83. data/lib/tinkerforge/bricklet_load_cell.rb +61 -23
  84. data/lib/tinkerforge/bricklet_load_cell_v2.rb +80 -30
  85. data/lib/tinkerforge/bricklet_moisture.rb +40 -16
  86. data/lib/tinkerforge/bricklet_motion_detector.rb +22 -10
  87. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -24
  88. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -27
  89. data/lib/tinkerforge/bricklet_multi_touch.rb +31 -13
  90. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -28
  91. data/lib/tinkerforge/bricklet_nfc.rb +123 -58
  92. data/lib/tinkerforge/bricklet_nfc_rfid.rb +33 -13
  93. data/lib/tinkerforge/bricklet_oled_128x64.rb +29 -11
  94. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +66 -24
  95. data/lib/tinkerforge/bricklet_oled_64x48.rb +29 -11
  96. data/lib/tinkerforge/bricklet_one_wire.rb +66 -24
  97. data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -27
  98. data/lib/tinkerforge/bricklet_particulate_matter.rb +75 -30
  99. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -9
  100. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -10
  101. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +80 -42
  102. data/lib/tinkerforge/bricklet_ptc.rb +74 -42
  103. data/lib/tinkerforge/bricklet_ptc_v2.rb +95 -48
  104. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -33
  105. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -44
  106. data/lib/tinkerforge/bricklet_remote_switch.rb +39 -29
  107. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +87 -49
  108. data/lib/tinkerforge/bricklet_rgb_led.rb +18 -8
  109. data/lib/tinkerforge/bricklet_rgb_led_button.rb +62 -30
  110. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +79 -33
  111. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +52 -20
  112. data/lib/tinkerforge/bricklet_rotary_encoder.rb +39 -19
  113. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -24
  114. data/lib/tinkerforge/bricklet_rotary_poti.rb +53 -28
  115. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -23
  116. data/lib/tinkerforge/bricklet_rs232.rb +90 -28
  117. data/lib/tinkerforge/bricklet_rs232_v2.rb +118 -44
  118. data/lib/tinkerforge/bricklet_rs485.rb +223 -95
  119. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +25 -14
  120. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -35
  121. data/lib/tinkerforge/bricklet_solid_state_relay.rb +25 -13
  122. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +59 -25
  123. data/lib/tinkerforge/bricklet_sound_intensity.rb +35 -18
  124. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +72 -31
  125. data/lib/tinkerforge/bricklet_temperature.rb +40 -16
  126. data/lib/tinkerforge/bricklet_temperature_ir.rb +57 -23
  127. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +71 -27
  128. data/lib/tinkerforge/bricklet_temperature_v2.rb +61 -25
  129. data/lib/tinkerforge/bricklet_thermal_imaging.rb +105 -44
  130. data/lib/tinkerforge/bricklet_thermocouple.rb +45 -24
  131. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -27
  132. data/lib/tinkerforge/bricklet_tilt.rb +24 -10
  133. data/lib/tinkerforge/bricklet_uv_light.rb +36 -18
  134. data/lib/tinkerforge/bricklet_uv_light_v2.rb +85 -37
  135. data/lib/tinkerforge/bricklet_voltage.rb +52 -28
  136. data/lib/tinkerforge/bricklet_voltage_current.rb +91 -73
  137. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +90 -68
  138. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +80 -30
  139. data/lib/tinkerforge/device_display_names.rb +163 -0
  140. data/lib/tinkerforge/ip_connection.rb +151 -32
  141. data/lib/tinkerforge/version.rb +1 -1
  142. metadata +3 -2
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-11-25. #
3
+ # This file was automatically generated on 2020-04-07. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.25 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
9
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # Drives up to 7 RC Servos with up to 3A
14
16
  class BrickServo < Device
@@ -16,8 +18,7 @@ module Tinkerforge
16
18
  DEVICE_DISPLAY_NAME = 'Servo Brick' # :nodoc:
17
19
 
18
20
  # This callback is triggered when the input voltage drops below the value set by
19
- # BrickServo#set_minimum_voltage. The parameter is the current voltage given
20
- # in mV.
21
+ # BrickServo#set_minimum_voltage. The parameter is the current voltage.
21
22
  CALLBACK_UNDER_VOLTAGE = 26
22
23
 
23
24
  # This callback is triggered when a position set by BrickServo#set_position
@@ -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
  COMMUNICATION_METHOD_NONE = 0 # :nodoc:
@@ -103,7 +106,7 @@ module Tinkerforge
103
106
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
104
107
  # the IP Connection <tt>ipcon</tt>.
105
108
  def initialize(uid, ipcon)
106
- super uid, ipcon
109
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
107
110
 
108
111
  @api_version = [2, 0, 4]
109
112
 
@@ -150,32 +153,41 @@ module Tinkerforge
150
153
  @response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
151
154
  @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
152
155
  @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
156
+ @response_expected[FUNCTION_WRITE_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_FALSE
157
+ @response_expected[FUNCTION_READ_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_ALWAYS_TRUE
153
158
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
154
159
 
155
- @callback_formats[CALLBACK_UNDER_VOLTAGE] = 'S'
156
- @callback_formats[CALLBACK_POSITION_REACHED] = 'C s'
157
- @callback_formats[CALLBACK_VELOCITY_REACHED] = 'C s'
160
+ @callback_formats[CALLBACK_UNDER_VOLTAGE] = [10, 'S']
161
+ @callback_formats[CALLBACK_POSITION_REACHED] = [11, 'C s']
162
+ @callback_formats[CALLBACK_VELOCITY_REACHED] = [11, 'C s']
158
163
 
164
+ @ipcon.add_device self
159
165
  end
160
166
 
161
167
  # Enables a servo (0 to 6). If a servo is enabled, the configured position,
162
168
  # velocity, acceleration, etc. are applied immediately.
163
169
  def enable(servo_num)
164
- send_request FUNCTION_ENABLE, [servo_num], 'C', 0, ''
170
+ check_validity
171
+
172
+ send_request FUNCTION_ENABLE, [servo_num], 'C', 8, ''
165
173
  end
166
174
 
167
175
  # Disables a servo (0 to 6). Disabled servos are not driven at all, i.e. a
168
176
  # disabled servo will not hold its position if a load is applied.
169
177
  def disable(servo_num)
170
- send_request FUNCTION_DISABLE, [servo_num], 'C', 0, ''
178
+ check_validity
179
+
180
+ send_request FUNCTION_DISABLE, [servo_num], 'C', 8, ''
171
181
  end
172
182
 
173
183
  # Returns *true* if the specified servo is enabled, *false* otherwise.
174
184
  def is_enabled(servo_num)
175
- send_request FUNCTION_IS_ENABLED, [servo_num], 'C', 1, '?'
185
+ check_validity
186
+
187
+ send_request FUNCTION_IS_ENABLED, [servo_num], 'C', 9, '?'
176
188
  end
177
189
 
178
- # Sets the position in °/100 for the specified servo.
190
+ # Sets the position for the specified servo.
179
191
  #
180
192
  # The default range of the position is -9000 to 9000, but it can be specified
181
193
  # according to your servo with BrickServo#set_degree.
@@ -184,80 +196,92 @@ module Tinkerforge
184
196
  # similar with the Servo Brick, you can also define lengths or speeds with
185
197
  # BrickServo#set_degree.
186
198
  def set_position(servo_num, position)
187
- send_request FUNCTION_SET_POSITION, [servo_num, position], 'C s', 0, ''
199
+ check_validity
200
+
201
+ send_request FUNCTION_SET_POSITION, [servo_num, position], 'C s', 8, ''
188
202
  end
189
203
 
190
204
  # Returns the position of the specified servo as set by BrickServo#set_position.
191
205
  def get_position(servo_num)
192
- send_request FUNCTION_GET_POSITION, [servo_num], 'C', 2, 's'
206
+ check_validity
207
+
208
+ send_request FUNCTION_GET_POSITION, [servo_num], 'C', 10, 's'
193
209
  end
194
210
 
195
211
  # Returns the *current* position of the specified servo. This may not be the
196
212
  # value of BrickServo#set_position if the servo is currently approaching a
197
213
  # position goal.
198
214
  def get_current_position(servo_num)
199
- send_request FUNCTION_GET_CURRENT_POSITION, [servo_num], 'C', 2, 's'
215
+ check_validity
216
+
217
+ send_request FUNCTION_GET_CURRENT_POSITION, [servo_num], 'C', 10, 's'
200
218
  end
201
219
 
202
- # Sets the maximum velocity of the specified servo in °/100s. The velocity
220
+ # Sets the maximum velocity of the specified servo. The velocity
203
221
  # is accelerated according to the value set by BrickServo#set_acceleration.
204
222
  #
205
223
  # The minimum velocity is 0 (no movement) and the maximum velocity is 65535.
206
224
  # With a value of 65535 the position will be set immediately (no velocity).
207
- #
208
- # The default value is 65535.
209
225
  def set_velocity(servo_num, velocity)
210
- send_request FUNCTION_SET_VELOCITY, [servo_num, velocity], 'C S', 0, ''
226
+ check_validity
227
+
228
+ send_request FUNCTION_SET_VELOCITY, [servo_num, velocity], 'C S', 8, ''
211
229
  end
212
230
 
213
231
  # Returns the velocity of the specified servo as set by BrickServo#set_velocity.
214
232
  def get_velocity(servo_num)
215
- send_request FUNCTION_GET_VELOCITY, [servo_num], 'C', 2, 'S'
233
+ check_validity
234
+
235
+ send_request FUNCTION_GET_VELOCITY, [servo_num], 'C', 10, 'S'
216
236
  end
217
237
 
218
238
  # Returns the *current* velocity of the specified servo. This may not be the
219
239
  # value of BrickServo#set_velocity if the servo is currently approaching a
220
240
  # velocity goal.
221
241
  def get_current_velocity(servo_num)
222
- send_request FUNCTION_GET_CURRENT_VELOCITY, [servo_num], 'C', 2, 'S'
242
+ check_validity
243
+
244
+ send_request FUNCTION_GET_CURRENT_VELOCITY, [servo_num], 'C', 10, 'S'
223
245
  end
224
246
 
225
- # Sets the acceleration of the specified servo in °/100s².
247
+ # Sets the acceleration of the specified servo.
226
248
  #
227
249
  # The minimum acceleration is 1 and the maximum acceleration is 65535.
228
250
  # With a value of 65535 the velocity will be set immediately (no acceleration).
229
- #
230
- # The default value is 65535.
231
251
  def set_acceleration(servo_num, acceleration)
232
- send_request FUNCTION_SET_ACCELERATION, [servo_num, acceleration], 'C S', 0, ''
252
+ check_validity
253
+
254
+ send_request FUNCTION_SET_ACCELERATION, [servo_num, acceleration], 'C S', 8, ''
233
255
  end
234
256
 
235
257
  # Returns the acceleration for the specified servo as set by
236
258
  # BrickServo#set_acceleration.
237
259
  def get_acceleration(servo_num)
238
- send_request FUNCTION_GET_ACCELERATION, [servo_num], 'C', 2, 'S'
260
+ check_validity
261
+
262
+ send_request FUNCTION_GET_ACCELERATION, [servo_num], 'C', 10, 'S'
239
263
  end
240
264
 
241
- # Sets the output voltages with which the servos are driven in mV.
242
- # The minimum output voltage is 2000mV and the maximum output voltage is
243
- # 9000mV.
265
+ # Sets the output voltages with which the servos are driven.
244
266
  #
245
267
  # .. note::
246
268
  # We recommend that you set this value to the maximum voltage that is
247
269
  # specified for your servo, most servos achieve their maximum force only
248
270
  # with high voltages.
249
- #
250
- # The default value is 5000.
251
271
  def set_output_voltage(voltage)
252
- send_request FUNCTION_SET_OUTPUT_VOLTAGE, [voltage], 'S', 0, ''
272
+ check_validity
273
+
274
+ send_request FUNCTION_SET_OUTPUT_VOLTAGE, [voltage], 'S', 8, ''
253
275
  end
254
276
 
255
277
  # Returns the output voltage as specified by BrickServo#set_output_voltage.
256
278
  def get_output_voltage
257
- send_request FUNCTION_GET_OUTPUT_VOLTAGE, [], '', 2, 'S'
279
+ check_validity
280
+
281
+ send_request FUNCTION_GET_OUTPUT_VOLTAGE, [], '', 10, 'S'
258
282
  end
259
283
 
260
- # Sets the minimum and maximum pulse width of the specified servo in µs.
284
+ # Sets the minimum and maximum pulse width of the specified servo.
261
285
  #
262
286
  # Usually, servos are controlled with a
263
287
  # `PWM <https://en.wikipedia.org/wiki/Pulse-width_modulation>`__, whereby the
@@ -269,19 +293,19 @@ module Tinkerforge
269
293
  # maximum pulse width, you should set the values accordingly. If your servo
270
294
  # comes without any datasheet you have to find the values via trial and error.
271
295
  #
272
- # Both values have a range from 1 to 65535 (unsigned 16-bit integer). The
273
- # minimum must be smaller than the maximum.
274
- #
275
- # The default values are 1000µs (1ms) and 2000µs (2ms) for minimum and
276
- # maximum pulse width.
296
+ # The minimum must be smaller than the maximum.
277
297
  def set_pulse_width(servo_num, min, max)
278
- send_request FUNCTION_SET_PULSE_WIDTH, [servo_num, min, max], 'C S S', 0, ''
298
+ check_validity
299
+
300
+ send_request FUNCTION_SET_PULSE_WIDTH, [servo_num, min, max], 'C S S', 8, ''
279
301
  end
280
302
 
281
303
  # Returns the minimum and maximum pulse width for the specified servo as set by
282
304
  # BrickServo#set_pulse_width.
283
305
  def get_pulse_width(servo_num)
284
- send_request FUNCTION_GET_PULSE_WIDTH, [servo_num], 'C', 4, 'S S'
306
+ check_validity
307
+
308
+ send_request FUNCTION_GET_PULSE_WIDTH, [servo_num], 'C', 12, 'S S'
285
309
  end
286
310
 
287
311
  # Sets the minimum and maximum degree for the specified servo (by default
@@ -310,21 +334,22 @@ module Tinkerforge
310
334
  # control it with a RC brushless motor controller. In this case you can set the
311
335
  # minimum to 0 and the maximum to 10000. BrickServo#set_position now controls the rpm.
312
336
  #
313
- # Both values have a possible range from -32767 to 32767
314
- # (signed 16-bit integer). The minimum must be smaller than the maximum.
315
- #
316
- # The default values are -9000 and 9000 for the minimum and maximum degree.
337
+ # The minimum must be smaller than the maximum.
317
338
  def set_degree(servo_num, min, max)
318
- send_request FUNCTION_SET_DEGREE, [servo_num, min, max], 'C s s', 0, ''
339
+ check_validity
340
+
341
+ send_request FUNCTION_SET_DEGREE, [servo_num, min, max], 'C s s', 8, ''
319
342
  end
320
343
 
321
344
  # Returns the minimum and maximum degree for the specified servo as set by
322
345
  # BrickServo#set_degree.
323
346
  def get_degree(servo_num)
324
- send_request FUNCTION_GET_DEGREE, [servo_num], 'C', 4, 's s'
347
+ check_validity
348
+
349
+ send_request FUNCTION_GET_DEGREE, [servo_num], 'C', 12, 's s'
325
350
  end
326
351
 
327
- # Sets the period of the specified servo in µs.
352
+ # Sets the period of the specified servo.
328
353
  #
329
354
  # Usually, servos are controlled with a
330
355
  # `PWM <https://en.wikipedia.org/wiki/Pulse-width_modulation>`__. Different
@@ -333,39 +358,45 @@ module Tinkerforge
333
358
  #
334
359
  # If your servo comes with a datasheet that specifies a period, you should
335
360
  # set it accordingly. If you don't have a datasheet and you have no idea
336
- # what the correct period is, the default value (19.5ms) will most likely
361
+ # what the correct period is, the default value will most likely
337
362
  # work fine.
338
- #
339
- # The minimum possible period is 1µs and the maximum is 65535µs.
340
- #
341
- # The default value is 19.5ms (19500µs).
342
363
  def set_period(servo_num, period)
343
- send_request FUNCTION_SET_PERIOD, [servo_num, period], 'C S', 0, ''
364
+ check_validity
365
+
366
+ send_request FUNCTION_SET_PERIOD, [servo_num, period], 'C S', 8, ''
344
367
  end
345
368
 
346
369
  # Returns the period for the specified servo as set by BrickServo#set_period.
347
370
  def get_period(servo_num)
348
- send_request FUNCTION_GET_PERIOD, [servo_num], 'C', 2, 'S'
371
+ check_validity
372
+
373
+ send_request FUNCTION_GET_PERIOD, [servo_num], 'C', 10, 'S'
349
374
  end
350
375
 
351
- # Returns the current consumption of the specified servo in mA.
376
+ # Returns the current consumption of the specified servo.
352
377
  def get_servo_current(servo_num)
353
- send_request FUNCTION_GET_SERVO_CURRENT, [servo_num], 'C', 2, 'S'
378
+ check_validity
379
+
380
+ send_request FUNCTION_GET_SERVO_CURRENT, [servo_num], 'C', 10, 'S'
354
381
  end
355
382
 
356
- # Returns the current consumption of all servos together in mA.
383
+ # Returns the current consumption of all servos together.
357
384
  def get_overall_current
358
- send_request FUNCTION_GET_OVERALL_CURRENT, [], '', 2, 'S'
385
+ check_validity
386
+
387
+ send_request FUNCTION_GET_OVERALL_CURRENT, [], '', 10, 'S'
359
388
  end
360
389
 
361
- # Returns the stack input voltage in mV. The stack input voltage is the
390
+ # Returns the stack input voltage. The stack input voltage is the
362
391
  # voltage that is supplied via the stack, i.e. it is given by a
363
392
  # Step-Down or Step-Up Power Supply.
364
393
  def get_stack_input_voltage
365
- send_request FUNCTION_GET_STACK_INPUT_VOLTAGE, [], '', 2, 'S'
394
+ check_validity
395
+
396
+ send_request FUNCTION_GET_STACK_INPUT_VOLTAGE, [], '', 10, 'S'
366
397
  end
367
398
 
368
- # Returns the external input voltage in mV. The external input voltage is
399
+ # Returns the external input voltage. The external input voltage is
369
400
  # given via the black power input connector on the Servo Brick.
370
401
  #
371
402
  # If there is an external input voltage and a stack input voltage, the motors
@@ -378,23 +409,27 @@ module Tinkerforge
378
409
  # the external connection, it will immediately be driven by the high
379
410
  # stack voltage
380
411
  def get_external_input_voltage
381
- send_request FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE, [], '', 2, 'S'
412
+ check_validity
413
+
414
+ send_request FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE, [], '', 10, 'S'
382
415
  end
383
416
 
384
- # Sets the minimum voltage in mV, below which the CALLBACK_UNDER_VOLTAGE callback
417
+ # Sets the minimum voltage, below which the CALLBACK_UNDER_VOLTAGE callback
385
418
  # is triggered. The minimum possible value that works with the Servo Brick is 5V.
386
419
  # You can use this function to detect the discharge of a battery that is used
387
420
  # to drive the stepper motor. If you have a fixed power supply, you likely do
388
421
  # not need this functionality.
389
- #
390
- # The default value is 5V (5000mV).
391
422
  def set_minimum_voltage(voltage)
392
- send_request FUNCTION_SET_MINIMUM_VOLTAGE, [voltage], 'S', 0, ''
423
+ check_validity
424
+
425
+ send_request FUNCTION_SET_MINIMUM_VOLTAGE, [voltage], 'S', 8, ''
393
426
  end
394
427
 
395
428
  # Returns the minimum voltage as set by BrickServo#set_minimum_voltage
396
429
  def get_minimum_voltage
397
- send_request FUNCTION_GET_MINIMUM_VOLTAGE, [], '', 2, 'S'
430
+ check_validity
431
+
432
+ send_request FUNCTION_GET_MINIMUM_VOLTAGE, [], '', 10, 'S'
398
433
  end
399
434
 
400
435
  # Enables the CALLBACK_POSITION_REACHED callback.
@@ -403,23 +438,27 @@ module Tinkerforge
403
438
  #
404
439
  # .. versionadded:: 2.0.1$nbsp;(Firmware)
405
440
  def enable_position_reached_callback
406
- send_request FUNCTION_ENABLE_POSITION_REACHED_CALLBACK, [], '', 0, ''
441
+ check_validity
442
+
443
+ send_request FUNCTION_ENABLE_POSITION_REACHED_CALLBACK, [], '', 8, ''
407
444
  end
408
445
 
409
446
  # Disables the CALLBACK_POSITION_REACHED callback.
410
447
  #
411
- # Default is disabled.
412
- #
413
448
  # .. versionadded:: 2.0.1$nbsp;(Firmware)
414
449
  def disable_position_reached_callback
415
- send_request FUNCTION_DISABLE_POSITION_REACHED_CALLBACK, [], '', 0, ''
450
+ check_validity
451
+
452
+ send_request FUNCTION_DISABLE_POSITION_REACHED_CALLBACK, [], '', 8, ''
416
453
  end
417
454
 
418
455
  # Returns *true* if CALLBACK_POSITION_REACHED callback is enabled, *false* otherwise.
419
456
  #
420
457
  # .. versionadded:: 2.0.1$nbsp;(Firmware)
421
458
  def is_position_reached_callback_enabled
422
- send_request FUNCTION_IS_POSITION_REACHED_CALLBACK_ENABLED, [], '', 1, '?'
459
+ check_validity
460
+
461
+ send_request FUNCTION_IS_POSITION_REACHED_CALLBACK_ENABLED, [], '', 9, '?'
423
462
  end
424
463
 
425
464
  # Enables the CALLBACK_VELOCITY_REACHED callback.
@@ -428,7 +467,9 @@ module Tinkerforge
428
467
  #
429
468
  # .. versionadded:: 2.0.1$nbsp;(Firmware)
430
469
  def enable_velocity_reached_callback
431
- send_request FUNCTION_ENABLE_VELOCITY_REACHED_CALLBACK, [], '', 0, ''
470
+ check_validity
471
+
472
+ send_request FUNCTION_ENABLE_VELOCITY_REACHED_CALLBACK, [], '', 8, ''
432
473
  end
433
474
 
434
475
  # Disables the CALLBACK_VELOCITY_REACHED callback.
@@ -437,22 +478,26 @@ module Tinkerforge
437
478
  #
438
479
  # .. versionadded:: 2.0.1$nbsp;(Firmware)
439
480
  def disable_velocity_reached_callback
440
- send_request FUNCTION_DISABLE_VELOCITY_REACHED_CALLBACK, [], '', 0, ''
481
+ check_validity
482
+
483
+ send_request FUNCTION_DISABLE_VELOCITY_REACHED_CALLBACK, [], '', 8, ''
441
484
  end
442
485
 
443
486
  # Returns *true* if CALLBACK_VELOCITY_REACHED callback is enabled, *false* otherwise.
444
487
  #
445
488
  # .. versionadded:: 2.0.1$nbsp;(Firmware)
446
489
  def is_velocity_reached_callback_enabled
447
- send_request FUNCTION_IS_VELOCITY_REACHED_CALLBACK_ENABLED, [], '', 1, '?'
490
+ check_validity
491
+
492
+ send_request FUNCTION_IS_VELOCITY_REACHED_CALLBACK_ENABLED, [], '', 9, '?'
448
493
  end
449
494
 
450
495
  # The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is
451
496
  # enabled, the Brick will try to adapt the baudrate for the communication
452
497
  # between Bricks and Bricklets according to the amount of data that is transferred.
453
498
  #
454
- # The baudrate will be increased exponentially if lots of data is send/received and
455
- # decreased linearly if little data is send/received.
499
+ # The baudrate will be increased exponentially if lots of data is sent/received and
500
+ # decreased linearly if little data is sent/received.
456
501
  #
457
502
  # This lowers the baudrate in applications where little data is transferred (e.g.
458
503
  # a weather station) and increases the robustness. If there is lots of data to transfer
@@ -466,20 +511,20 @@ module Tinkerforge
466
511
  # BrickServo#set_spitfp_baudrate. If the dynamic baudrate is disabled, the baudrate
467
512
  # as set by BrickServo#set_spitfp_baudrate will be used statically.
468
513
  #
469
- # The minimum dynamic baudrate has a value range of 400000 to 2000000 baud.
470
- #
471
- # By default dynamic baudrate is enabled and the minimum dynamic baudrate is 400000.
472
- #
473
514
  # .. versionadded:: 2.3.4$nbsp;(Firmware)
474
515
  def set_spitfp_baudrate_config(enable_dynamic_baudrate, minimum_dynamic_baudrate)
475
- send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 0, ''
516
+ check_validity
517
+
518
+ send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 8, ''
476
519
  end
477
520
 
478
521
  # Returns the baudrate config, see BrickServo#set_spitfp_baudrate_config.
479
522
  #
480
523
  # .. versionadded:: 2.3.4$nbsp;(Firmware)
481
524
  def get_spitfp_baudrate_config
482
- send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 5, '? L'
525
+ check_validity
526
+
527
+ send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 13, '? L'
483
528
  end
484
529
 
485
530
  # Returns the timeout count for the different communication methods.
@@ -491,11 +536,12 @@ module Tinkerforge
491
536
  #
492
537
  # .. versionadded:: 2.3.2$nbsp;(Firmware)
493
538
  def get_send_timeout_count(communication_method)
494
- send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 4, 'L'
539
+ check_validity
540
+
541
+ send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 12, 'L'
495
542
  end
496
543
 
497
- # Sets the baudrate for a specific Bricklet port ('a' - 'd'). The
498
- # baudrate can be in the range 400000 to 2000000.
544
+ # Sets the baudrate for a specific Bricklet port.
499
545
  #
500
546
  # If you want to increase the throughput of Bricklets you can increase
501
547
  # the baudrate. If you get a high error count because of high
@@ -509,18 +555,20 @@ module Tinkerforge
509
555
  # or similar is necessary in you applications we recommend to not change
510
556
  # the baudrate.
511
557
  #
512
- # The default baudrate for all ports is 1400000.
513
- #
514
558
  # .. versionadded:: 2.3.2$nbsp;(Firmware)
515
559
  def set_spitfp_baudrate(bricklet_port, baudrate)
516
- send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 0, ''
560
+ check_validity
561
+
562
+ send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 8, ''
517
563
  end
518
564
 
519
565
  # Returns the baudrate for a given Bricklet port, see BrickServo#set_spitfp_baudrate.
520
566
  #
521
567
  # .. versionadded:: 2.3.2$nbsp;(Firmware)
522
568
  def get_spitfp_baudrate(bricklet_port)
523
- send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 4, 'L'
569
+ check_validity
570
+
571
+ send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 12, 'L'
524
572
  end
525
573
 
526
574
  # Returns the error count for the communication between Brick and Bricklet.
@@ -537,7 +585,9 @@ module Tinkerforge
537
585
  #
538
586
  # .. versionadded:: 2.3.2$nbsp;(Firmware)
539
587
  def get_spitfp_error_count(bricklet_port)
540
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 16, 'L L L L'
588
+ check_validity
589
+
590
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 24, 'L L L L'
541
591
  end
542
592
 
543
593
  # Enables the status LED.
@@ -549,7 +599,9 @@ module Tinkerforge
549
599
  #
550
600
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
551
601
  def enable_status_led
552
- send_request FUNCTION_ENABLE_STATUS_LED, [], '', 0, ''
602
+ check_validity
603
+
604
+ send_request FUNCTION_ENABLE_STATUS_LED, [], '', 8, ''
553
605
  end
554
606
 
555
607
  # Disables the status LED.
@@ -561,14 +613,18 @@ module Tinkerforge
561
613
  #
562
614
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
563
615
  def disable_status_led
564
- send_request FUNCTION_DISABLE_STATUS_LED, [], '', 0, ''
616
+ check_validity
617
+
618
+ send_request FUNCTION_DISABLE_STATUS_LED, [], '', 8, ''
565
619
  end
566
620
 
567
621
  # Returns *true* if the status LED is enabled, *false* otherwise.
568
622
  #
569
623
  # .. versionadded:: 2.3.1$nbsp;(Firmware)
570
624
  def is_status_led_enabled
571
- send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 1, '?'
625
+ check_validity
626
+
627
+ send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 9, '?'
572
628
  end
573
629
 
574
630
  # Returns the firmware and protocol version and the name of the Bricklet for a
@@ -577,17 +633,21 @@ module Tinkerforge
577
633
  # This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet
578
634
  # plugins.
579
635
  def get_protocol1_bricklet_name(port)
580
- send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 44, 'C C3 Z40'
636
+ check_validity
637
+
638
+ send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 52, 'C C3 Z40'
581
639
  end
582
640
 
583
- # Returns the temperature in °C/10 as measured inside the microcontroller. The
641
+ # Returns the temperature as measured inside the microcontroller. The
584
642
  # value returned is not the ambient temperature!
585
643
  #
586
644
  # The temperature is only proportional to the real temperature and it has an
587
645
  # accuracy of ±15%. Practically it is only useful as an indicator for
588
646
  # temperature changes.
589
647
  def get_chip_temperature
590
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
648
+ check_validity
649
+
650
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
591
651
  end
592
652
 
593
653
  # Calling this function will reset the Brick. Calling this function
@@ -597,19 +657,43 @@ module Tinkerforge
597
657
  # calling functions on the existing ones will result in
598
658
  # undefined behavior!
599
659
  def reset
600
- send_request FUNCTION_RESET, [], '', 0, ''
660
+ check_validity
661
+
662
+ send_request FUNCTION_RESET, [], '', 8, ''
663
+ end
664
+
665
+ # Writes 32 bytes of firmware to the bricklet attached at the given port.
666
+ # The bytes are written to the position offset * 32.
667
+ #
668
+ # This function is used by Brick Viewer during flashing. It should not be
669
+ # necessary to call it in a normal user program.
670
+ def write_bricklet_plugin(port, offset, chunk)
671
+ check_validity
672
+
673
+ send_request FUNCTION_WRITE_BRICKLET_PLUGIN, [port, offset, chunk], 'k C C32', 8, ''
674
+ end
675
+
676
+ # Reads 32 bytes of firmware from the bricklet attached at the given port.
677
+ # The bytes are read starting at the position offset * 32.
678
+ #
679
+ # This function is used by Brick Viewer during flashing. It should not be
680
+ # necessary to call it in a normal user program.
681
+ def read_bricklet_plugin(port, offset)
682
+ check_validity
683
+
684
+ send_request FUNCTION_READ_BRICKLET_PLUGIN, [port, offset], 'k C', 40, 'C32'
601
685
  end
602
686
 
603
687
  # Returns the UID, the UID where the Brick is connected to,
604
688
  # the position, the hardware and firmware version as well as the
605
689
  # device identifier.
606
690
  #
607
- # The position can be '0'-'8' (stack position).
691
+ # The position is the position in the stack from '0' (bottom) to '8' (top).
608
692
  #
609
693
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
610
694
  # |device_identifier_constant|
611
695
  def get_identity
612
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
696
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
613
697
  end
614
698
 
615
699
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.