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