tinkerforge 2.1.22 → 2.1.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
|
+
require_relative './ip_connection'
|
13
|
+
|
12
14
|
module Tinkerforge
|
13
15
|
# Drives 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
|
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
|
-
|
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
|
-
|
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
|
-
|
185
|
+
check_validity
|
186
|
+
|
187
|
+
send_request FUNCTION_IS_ENABLED, [servo_num], 'C', 9, '?'
|
176
188
|
end
|
177
189
|
|
178
|
-
# Sets the position
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
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
|
-
#
|
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
|
-
|
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
|
-
|
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
|
-
#
|
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
|
-
|
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
|
-
|
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
|
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
|
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
|
-
|
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
|
-
|
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
|
376
|
+
# Returns the current consumption of the specified servo.
|
352
377
|
def get_servo_current(servo_num)
|
353
|
-
|
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
|
383
|
+
# Returns the current consumption of all servos together.
|
357
384
|
def get_overall_current
|
358
|
-
|
385
|
+
check_validity
|
386
|
+
|
387
|
+
send_request FUNCTION_GET_OVERALL_CURRENT, [], '', 10, 'S'
|
359
388
|
end
|
360
389
|
|
361
|
-
# Returns the stack input voltage
|
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
|
-
|
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
|
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
|
-
|
412
|
+
check_validity
|
413
|
+
|
414
|
+
send_request FUNCTION_GET_EXTERNAL_INPUT_VOLTAGE, [], '', 10, 'S'
|
382
415
|
end
|
383
416
|
|
384
|
-
# Sets the minimum voltage
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
455
|
-
# decreased linearly if little data is
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
@@ -506,21 +552,23 @@ module Tinkerforge
|
|
506
552
|
# function corresponds to the maximum baudrate (see BrickServo#set_spitfp_baudrate_config).
|
507
553
|
#
|
508
554
|
# Regulatory testing is done with the default baudrate. If CE compatibility
|
509
|
-
# or similar is necessary in
|
555
|
+
# or similar is necessary in your 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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
-
# accuracy of
|
645
|
+
# accuracy of ±15%. Practically it is only useful as an indicator for
|
588
646
|
# temperature changes.
|
589
647
|
def get_chip_temperature
|
590
|
-
|
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
|
-
|
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
|
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, [], '',
|
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>.
|