tinkerforge 2.1.24 → 2.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
# Measures Particulate Matter concentration (PM1.0, PM2.5 and PM10)
|
|
14
16
|
class BrickletParticulateMatter < Device
|
|
@@ -68,7 +70,7 @@ module Tinkerforge
|
|
|
68
70
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
69
71
|
# the IP Connection <tt>ipcon</tt>.
|
|
70
72
|
def initialize(uid, ipcon)
|
|
71
|
-
super uid, ipcon
|
|
73
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
72
74
|
|
|
73
75
|
@api_version = [2, 0, 0]
|
|
74
76
|
|
|
@@ -94,9 +96,10 @@ module Tinkerforge
|
|
|
94
96
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
95
97
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
96
98
|
|
|
97
|
-
@callback_formats[CALLBACK_PM_CONCENTRATION] = 'S S S'
|
|
98
|
-
@callback_formats[CALLBACK_PM_COUNT] = 'S S S S S S'
|
|
99
|
+
@callback_formats[CALLBACK_PM_CONCENTRATION] = [14, 'S S S']
|
|
100
|
+
@callback_formats[CALLBACK_PM_COUNT] = [20, 'S S S S S S']
|
|
99
101
|
|
|
102
|
+
@ipcon.add_device self
|
|
100
103
|
end
|
|
101
104
|
|
|
102
105
|
# Returns the particulate matter concentration, broken down as:
|
|
@@ -112,7 +115,9 @@ module Tinkerforge
|
|
|
112
115
|
# CALLBACK_PM_CONCENTRATION callback. You can set the callback configuration
|
|
113
116
|
# with BrickletParticulateMatter#set_pm_concentration_callback_configuration.
|
|
114
117
|
def get_pm_concentration
|
|
115
|
-
|
|
118
|
+
check_validity
|
|
119
|
+
|
|
120
|
+
send_request FUNCTION_GET_PM_CONCENTRATION, [], '', 14, 'S S S'
|
|
116
121
|
end
|
|
117
122
|
|
|
118
123
|
# Returns the number of particulates in 100 ml of air, broken down by their
|
|
@@ -132,11 +137,12 @@ module Tinkerforge
|
|
|
132
137
|
# CALLBACK_PM_COUNT callback. You can set the callback configuration
|
|
133
138
|
# with BrickletParticulateMatter#set_pm_count_callback_configuration.
|
|
134
139
|
def get_pm_count
|
|
135
|
-
|
|
140
|
+
check_validity
|
|
141
|
+
|
|
142
|
+
send_request FUNCTION_GET_PM_COUNT, [], '', 20, 'S S S S S S'
|
|
136
143
|
end
|
|
137
144
|
|
|
138
|
-
# Enables/Disables the fan and the laser diode of the sensors.
|
|
139
|
-
# enabled by default.
|
|
145
|
+
# Enables/Disables the fan and the laser diode of the sensors.
|
|
140
146
|
#
|
|
141
147
|
# The sensor takes about 30 seconds after it is enabled to settle and produce stable
|
|
142
148
|
# values.
|
|
@@ -145,12 +151,16 @@ module Tinkerforge
|
|
|
145
151
|
# an interval with a long idle time (e.g. hourly) you should turn the
|
|
146
152
|
# laser diode off between the measurements.
|
|
147
153
|
def set_enable(enable)
|
|
148
|
-
|
|
154
|
+
check_validity
|
|
155
|
+
|
|
156
|
+
send_request FUNCTION_SET_ENABLE, [enable], '?', 8, ''
|
|
149
157
|
end
|
|
150
158
|
|
|
151
159
|
# Returns the state of the sensor as set by BrickletParticulateMatter#set_enable.
|
|
152
160
|
def get_enable
|
|
153
|
-
|
|
161
|
+
check_validity
|
|
162
|
+
|
|
163
|
+
send_request FUNCTION_GET_ENABLE, [], '', 9, '?'
|
|
154
164
|
end
|
|
155
165
|
|
|
156
166
|
# Returns information about the sensor:
|
|
@@ -160,7 +170,9 @@ module Tinkerforge
|
|
|
160
170
|
# * the number of framing and checksum errors that occurred in the communication
|
|
161
171
|
# with the sensor.
|
|
162
172
|
def get_sensor_info
|
|
163
|
-
|
|
173
|
+
check_validity
|
|
174
|
+
|
|
175
|
+
send_request FUNCTION_GET_SENSOR_INFO, [], '', 12, 'C C C C'
|
|
164
176
|
end
|
|
165
177
|
|
|
166
178
|
# The period is the period with which the CALLBACK_PM_CONCENTRATION
|
|
@@ -173,13 +185,17 @@ module Tinkerforge
|
|
|
173
185
|
# If it is set to false, the callback is continuously triggered with the period,
|
|
174
186
|
# independent of the value.
|
|
175
187
|
def set_pm_concentration_callback_configuration(period, value_has_to_change)
|
|
176
|
-
|
|
188
|
+
check_validity
|
|
189
|
+
|
|
190
|
+
send_request FUNCTION_SET_PM_CONCENTRATION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
177
191
|
end
|
|
178
192
|
|
|
179
193
|
# Returns the callback configuration as set by
|
|
180
194
|
# BrickletParticulateMatter#set_pm_concentration_callback_configuration.
|
|
181
195
|
def get_pm_concentration_callback_configuration
|
|
182
|
-
|
|
196
|
+
check_validity
|
|
197
|
+
|
|
198
|
+
send_request FUNCTION_GET_PM_CONCENTRATION_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
183
199
|
end
|
|
184
200
|
|
|
185
201
|
# The period is the period with which the CALLBACK_PM_COUNT callback
|
|
@@ -192,13 +208,17 @@ module Tinkerforge
|
|
|
192
208
|
# If it is set to false, the callback is continuously triggered with the period,
|
|
193
209
|
# independent of the value.
|
|
194
210
|
def set_pm_count_callback_configuration(period, value_has_to_change)
|
|
195
|
-
|
|
211
|
+
check_validity
|
|
212
|
+
|
|
213
|
+
send_request FUNCTION_SET_PM_COUNT_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
196
214
|
end
|
|
197
215
|
|
|
198
216
|
# Returns the callback configuration as set by
|
|
199
217
|
# BrickletParticulateMatter#set_pm_count_callback_configuration.
|
|
200
218
|
def get_pm_count_callback_configuration
|
|
201
|
-
|
|
219
|
+
check_validity
|
|
220
|
+
|
|
221
|
+
send_request FUNCTION_GET_PM_COUNT_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
202
222
|
end
|
|
203
223
|
|
|
204
224
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -213,7 +233,9 @@ module Tinkerforge
|
|
|
213
233
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
214
234
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
215
235
|
def get_spitfp_error_count
|
|
216
|
-
|
|
236
|
+
check_validity
|
|
237
|
+
|
|
238
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
217
239
|
end
|
|
218
240
|
|
|
219
241
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -226,12 +248,16 @@ module Tinkerforge
|
|
|
226
248
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
227
249
|
# necessary to call it in a normal user program.
|
|
228
250
|
def set_bootloader_mode(mode)
|
|
229
|
-
|
|
251
|
+
check_validity
|
|
252
|
+
|
|
253
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
230
254
|
end
|
|
231
255
|
|
|
232
256
|
# Returns the current bootloader mode, see BrickletParticulateMatter#set_bootloader_mode.
|
|
233
257
|
def get_bootloader_mode
|
|
234
|
-
|
|
258
|
+
check_validity
|
|
259
|
+
|
|
260
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
235
261
|
end
|
|
236
262
|
|
|
237
263
|
# Sets the firmware pointer for BrickletParticulateMatter#write_firmware. The pointer has
|
|
@@ -241,7 +267,9 @@ module Tinkerforge
|
|
|
241
267
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
242
268
|
# necessary to call it in a normal user program.
|
|
243
269
|
def set_write_firmware_pointer(pointer)
|
|
244
|
-
|
|
270
|
+
check_validity
|
|
271
|
+
|
|
272
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
245
273
|
end
|
|
246
274
|
|
|
247
275
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -253,7 +281,9 @@ module Tinkerforge
|
|
|
253
281
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
254
282
|
# necessary to call it in a normal user program.
|
|
255
283
|
def write_firmware(data)
|
|
256
|
-
|
|
284
|
+
check_validity
|
|
285
|
+
|
|
286
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
257
287
|
end
|
|
258
288
|
|
|
259
289
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -264,22 +294,28 @@ module Tinkerforge
|
|
|
264
294
|
#
|
|
265
295
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
266
296
|
def set_status_led_config(config)
|
|
267
|
-
|
|
297
|
+
check_validity
|
|
298
|
+
|
|
299
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
268
300
|
end
|
|
269
301
|
|
|
270
302
|
# Returns the configuration as set by BrickletParticulateMatter#set_status_led_config
|
|
271
303
|
def get_status_led_config
|
|
272
|
-
|
|
304
|
+
check_validity
|
|
305
|
+
|
|
306
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
273
307
|
end
|
|
274
308
|
|
|
275
|
-
# Returns the temperature
|
|
309
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
276
310
|
# value returned is not the ambient temperature!
|
|
277
311
|
#
|
|
278
312
|
# The temperature is only proportional to the real temperature and it has bad
|
|
279
313
|
# accuracy. Practically it is only useful as an indicator for
|
|
280
314
|
# temperature changes.
|
|
281
315
|
def get_chip_temperature
|
|
282
|
-
|
|
316
|
+
check_validity
|
|
317
|
+
|
|
318
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
283
319
|
end
|
|
284
320
|
|
|
285
321
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -289,7 +325,9 @@ module Tinkerforge
|
|
|
289
325
|
# calling functions on the existing ones will result in
|
|
290
326
|
# undefined behavior!
|
|
291
327
|
def reset
|
|
292
|
-
|
|
328
|
+
check_validity
|
|
329
|
+
|
|
330
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
293
331
|
end
|
|
294
332
|
|
|
295
333
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -298,25 +336,31 @@ module Tinkerforge
|
|
|
298
336
|
#
|
|
299
337
|
# We recommend that you use Brick Viewer to change the UID.
|
|
300
338
|
def write_uid(uid)
|
|
301
|
-
|
|
339
|
+
check_validity
|
|
340
|
+
|
|
341
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
302
342
|
end
|
|
303
343
|
|
|
304
344
|
# Returns the current UID as an integer. Encode as
|
|
305
345
|
# Base58 to get the usual string version.
|
|
306
346
|
def read_uid
|
|
307
|
-
|
|
347
|
+
check_validity
|
|
348
|
+
|
|
349
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
308
350
|
end
|
|
309
351
|
|
|
310
352
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
311
353
|
# the position, the hardware and firmware version as well as the
|
|
312
354
|
# device identifier.
|
|
313
355
|
#
|
|
314
|
-
# The position can be 'a', 'b', 'c' or '
|
|
356
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
357
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
358
|
+
# position 'z'.
|
|
315
359
|
#
|
|
316
360
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
317
361
|
# |device_identifier_constant|
|
|
318
362
|
def get_identity
|
|
319
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
363
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
320
364
|
end
|
|
321
365
|
|
|
322
366
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2021-05-06. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.29 #
|
|
6
|
+
# #
|
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
|
10
|
+
#############################################################
|
|
11
|
+
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
14
|
+
module Tinkerforge
|
|
15
|
+
# Drives one brushed DC motor with up to 36V and 10A
|
|
16
|
+
class BrickletPerformanceDC < Device
|
|
17
|
+
DEVICE_IDENTIFIER = 2156 # :nodoc:
|
|
18
|
+
DEVICE_DISPLAY_NAME = 'Performance DC Bricklet' # :nodoc:
|
|
19
|
+
|
|
20
|
+
# This callback is triggered if either the current consumption
|
|
21
|
+
# is too high or the temperature of the driver chip is too high
|
|
22
|
+
# (above 150°C) or the user defined thermal shutdown is triggered (see BrickletPerformanceDC#set_thermal_shutdown).
|
|
23
|
+
# n case of a voltage below 6V (input voltage) this
|
|
24
|
+
# callback is triggered as well.
|
|
25
|
+
#
|
|
26
|
+
# If this callback is triggered, the driver chip gets disabled at the same time.
|
|
27
|
+
# That means, BrickletPerformanceDC#set_enabled has to be called to drive the motor again.
|
|
28
|
+
CALLBACK_EMERGENCY_SHUTDOWN = 35
|
|
29
|
+
|
|
30
|
+
# This callback is triggered whenever a set velocity is reached. For example:
|
|
31
|
+
# If a velocity of 0 is present, acceleration is set to 5000 and velocity
|
|
32
|
+
# to 10000, the CALLBACK_VELOCITY_REACHED callback will be triggered after about
|
|
33
|
+
# 2 seconds, when the set velocity is actually reached.
|
|
34
|
+
#
|
|
35
|
+
# .. note::
|
|
36
|
+
# Since we can't get any feedback from the DC motor, this only works if the
|
|
37
|
+
# acceleration (see BrickletPerformanceDC#set_motion) is set smaller or equal to the
|
|
38
|
+
# maximum acceleration of the motor. Otherwise the motor will lag behind the
|
|
39
|
+
# control value and the callback will be triggered too early.
|
|
40
|
+
CALLBACK_VELOCITY_REACHED = 36
|
|
41
|
+
|
|
42
|
+
# This callback is triggered with the period that is set by
|
|
43
|
+
# BrickletPerformanceDC#set_current_velocity_callback_configuration. The parameter is the *current*
|
|
44
|
+
# velocity used by the motor.
|
|
45
|
+
#
|
|
46
|
+
# The CALLBACK_CURRENT_VELOCITY callback is only triggered after the set period
|
|
47
|
+
# if there is a change in the velocity.
|
|
48
|
+
CALLBACK_CURRENT_VELOCITY = 37
|
|
49
|
+
|
|
50
|
+
# This callback is triggered by GPIO changes if it is activated through BrickletPerformanceDC#set_gpio_action.
|
|
51
|
+
#
|
|
52
|
+
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
53
|
+
CALLBACK_GPIO_STATE = 38
|
|
54
|
+
|
|
55
|
+
FUNCTION_SET_ENABLED = 1 # :nodoc:
|
|
56
|
+
FUNCTION_GET_ENABLED = 2 # :nodoc:
|
|
57
|
+
FUNCTION_SET_VELOCITY = 3 # :nodoc:
|
|
58
|
+
FUNCTION_GET_VELOCITY = 4 # :nodoc:
|
|
59
|
+
FUNCTION_GET_CURRENT_VELOCITY = 5 # :nodoc:
|
|
60
|
+
FUNCTION_SET_MOTION = 6 # :nodoc:
|
|
61
|
+
FUNCTION_GET_MOTION = 7 # :nodoc:
|
|
62
|
+
FUNCTION_FULL_BRAKE = 8 # :nodoc:
|
|
63
|
+
FUNCTION_SET_DRIVE_MODE = 9 # :nodoc:
|
|
64
|
+
FUNCTION_GET_DRIVE_MODE = 10 # :nodoc:
|
|
65
|
+
FUNCTION_SET_PWM_FREQUENCY = 11 # :nodoc:
|
|
66
|
+
FUNCTION_GET_PWM_FREQUENCY = 12 # :nodoc:
|
|
67
|
+
FUNCTION_GET_POWER_STATISTICS = 13 # :nodoc:
|
|
68
|
+
FUNCTION_SET_THERMAL_SHUTDOWN = 14 # :nodoc:
|
|
69
|
+
FUNCTION_GET_THERMAL_SHUTDOWN = 15 # :nodoc:
|
|
70
|
+
FUNCTION_SET_GPIO_CONFIGURATION = 16 # :nodoc:
|
|
71
|
+
FUNCTION_GET_GPIO_CONFIGURATION = 17 # :nodoc:
|
|
72
|
+
FUNCTION_SET_GPIO_ACTION = 18 # :nodoc:
|
|
73
|
+
FUNCTION_GET_GPIO_ACTION = 19 # :nodoc:
|
|
74
|
+
FUNCTION_GET_GPIO_STATE = 20 # :nodoc:
|
|
75
|
+
FUNCTION_SET_ERROR_LED_CONFIG = 21 # :nodoc:
|
|
76
|
+
FUNCTION_GET_ERROR_LED_CONFIG = 22 # :nodoc:
|
|
77
|
+
FUNCTION_SET_CW_LED_CONFIG = 23 # :nodoc:
|
|
78
|
+
FUNCTION_GET_CW_LED_CONFIG = 24 # :nodoc:
|
|
79
|
+
FUNCTION_SET_CCW_LED_CONFIG = 25 # :nodoc:
|
|
80
|
+
FUNCTION_GET_CCW_LED_CONFIG = 26 # :nodoc:
|
|
81
|
+
FUNCTION_SET_GPIO_LED_CONFIG = 27 # :nodoc:
|
|
82
|
+
FUNCTION_GET_GPIO_LED_CONFIG = 28 # :nodoc:
|
|
83
|
+
FUNCTION_SET_EMERGENCY_SHUTDOWN_CALLBACK_CONFIGURATION = 29 # :nodoc:
|
|
84
|
+
FUNCTION_GET_EMERGENCY_SHUTDOWN_CALLBACK_CONFIGURATION = 30 # :nodoc:
|
|
85
|
+
FUNCTION_SET_VELOCITY_REACHED_CALLBACK_CONFIGURATION = 31 # :nodoc:
|
|
86
|
+
FUNCTION_GET_VELOCITY_REACHED_CALLBACK_CONFIGURATION = 32 # :nodoc:
|
|
87
|
+
FUNCTION_SET_CURRENT_VELOCITY_CALLBACK_CONFIGURATION = 33 # :nodoc:
|
|
88
|
+
FUNCTION_GET_CURRENT_VELOCITY_CALLBACK_CONFIGURATION = 34 # :nodoc:
|
|
89
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
90
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
91
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
92
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
93
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
94
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
95
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
96
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
97
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
98
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
99
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
100
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
101
|
+
|
|
102
|
+
DRIVE_MODE_DRIVE_BRAKE = 0 # :nodoc:
|
|
103
|
+
DRIVE_MODE_DRIVE_COAST = 1 # :nodoc:
|
|
104
|
+
GPIO_ACTION_NONE = 0 # :nodoc:
|
|
105
|
+
GPIO_ACTION_NORMAL_STOP_RISING_EDGE = 1 # :nodoc:
|
|
106
|
+
GPIO_ACTION_NORMAL_STOP_FALLING_EDGE = 2 # :nodoc:
|
|
107
|
+
GPIO_ACTION_FULL_BRAKE_RISING_EDGE = 4 # :nodoc:
|
|
108
|
+
GPIO_ACTION_FULL_BRAKE_FALLING_EDGE = 8 # :nodoc:
|
|
109
|
+
GPIO_ACTION_CALLBACK_RISING_EDGE = 16 # :nodoc:
|
|
110
|
+
GPIO_ACTION_CALLBACK_FALLING_EDGE = 32 # :nodoc:
|
|
111
|
+
ERROR_LED_CONFIG_OFF = 0 # :nodoc:
|
|
112
|
+
ERROR_LED_CONFIG_ON = 1 # :nodoc:
|
|
113
|
+
ERROR_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
114
|
+
ERROR_LED_CONFIG_SHOW_ERROR = 3 # :nodoc:
|
|
115
|
+
CW_LED_CONFIG_OFF = 0 # :nodoc:
|
|
116
|
+
CW_LED_CONFIG_ON = 1 # :nodoc:
|
|
117
|
+
CW_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
118
|
+
CW_LED_CONFIG_SHOW_CW_AS_FORWARD = 3 # :nodoc:
|
|
119
|
+
CW_LED_CONFIG_SHOW_CW_AS_BACKWARD = 4 # :nodoc:
|
|
120
|
+
CCW_LED_CONFIG_OFF = 0 # :nodoc:
|
|
121
|
+
CCW_LED_CONFIG_ON = 1 # :nodoc:
|
|
122
|
+
CCW_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
123
|
+
CCW_LED_CONFIG_SHOW_CCW_AS_FORWARD = 3 # :nodoc:
|
|
124
|
+
CCW_LED_CONFIG_SHOW_CCW_AS_BACKWARD = 4 # :nodoc:
|
|
125
|
+
GPIO_LED_CONFIG_OFF = 0 # :nodoc:
|
|
126
|
+
GPIO_LED_CONFIG_ON = 1 # :nodoc:
|
|
127
|
+
GPIO_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
128
|
+
GPIO_LED_CONFIG_SHOW_GPIO_ACTIVE_HIGH = 3 # :nodoc:
|
|
129
|
+
GPIO_LED_CONFIG_SHOW_GPIO_ACTIVE_LOW = 4 # :nodoc:
|
|
130
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
131
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
132
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
133
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
134
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
135
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
136
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
137
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
138
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
139
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
140
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
141
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
142
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
143
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
144
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
145
|
+
|
|
146
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
147
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
148
|
+
def initialize(uid, ipcon)
|
|
149
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
150
|
+
|
|
151
|
+
@api_version = [2, 0, 1]
|
|
152
|
+
|
|
153
|
+
@response_expected[FUNCTION_SET_ENABLED] = RESPONSE_EXPECTED_FALSE
|
|
154
|
+
@response_expected[FUNCTION_GET_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
155
|
+
@response_expected[FUNCTION_SET_VELOCITY] = RESPONSE_EXPECTED_FALSE
|
|
156
|
+
@response_expected[FUNCTION_GET_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
157
|
+
@response_expected[FUNCTION_GET_CURRENT_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
158
|
+
@response_expected[FUNCTION_SET_MOTION] = RESPONSE_EXPECTED_FALSE
|
|
159
|
+
@response_expected[FUNCTION_GET_MOTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
160
|
+
@response_expected[FUNCTION_FULL_BRAKE] = RESPONSE_EXPECTED_FALSE
|
|
161
|
+
@response_expected[FUNCTION_SET_DRIVE_MODE] = RESPONSE_EXPECTED_FALSE
|
|
162
|
+
@response_expected[FUNCTION_GET_DRIVE_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
163
|
+
@response_expected[FUNCTION_SET_PWM_FREQUENCY] = RESPONSE_EXPECTED_FALSE
|
|
164
|
+
@response_expected[FUNCTION_GET_PWM_FREQUENCY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
165
|
+
@response_expected[FUNCTION_GET_POWER_STATISTICS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
166
|
+
@response_expected[FUNCTION_SET_THERMAL_SHUTDOWN] = RESPONSE_EXPECTED_FALSE
|
|
167
|
+
@response_expected[FUNCTION_GET_THERMAL_SHUTDOWN] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
168
|
+
@response_expected[FUNCTION_SET_GPIO_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
|
169
|
+
@response_expected[FUNCTION_GET_GPIO_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
170
|
+
@response_expected[FUNCTION_SET_GPIO_ACTION] = RESPONSE_EXPECTED_FALSE
|
|
171
|
+
@response_expected[FUNCTION_GET_GPIO_ACTION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
172
|
+
@response_expected[FUNCTION_GET_GPIO_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
173
|
+
@response_expected[FUNCTION_SET_ERROR_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
174
|
+
@response_expected[FUNCTION_GET_ERROR_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
175
|
+
@response_expected[FUNCTION_SET_CW_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
176
|
+
@response_expected[FUNCTION_GET_CW_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
177
|
+
@response_expected[FUNCTION_SET_CCW_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
178
|
+
@response_expected[FUNCTION_GET_CCW_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
179
|
+
@response_expected[FUNCTION_SET_GPIO_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
180
|
+
@response_expected[FUNCTION_GET_GPIO_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
181
|
+
@response_expected[FUNCTION_SET_EMERGENCY_SHUTDOWN_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
182
|
+
@response_expected[FUNCTION_GET_EMERGENCY_SHUTDOWN_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
183
|
+
@response_expected[FUNCTION_SET_VELOCITY_REACHED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
184
|
+
@response_expected[FUNCTION_GET_VELOCITY_REACHED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
185
|
+
@response_expected[FUNCTION_SET_CURRENT_VELOCITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
186
|
+
@response_expected[FUNCTION_GET_CURRENT_VELOCITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
187
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
188
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
189
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
190
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
191
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
192
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
193
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
194
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
195
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
196
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
197
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
198
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
199
|
+
|
|
200
|
+
@callback_formats[CALLBACK_EMERGENCY_SHUTDOWN] = [8, '']
|
|
201
|
+
@callback_formats[CALLBACK_VELOCITY_REACHED] = [10, 's']
|
|
202
|
+
@callback_formats[CALLBACK_CURRENT_VELOCITY] = [10, 's']
|
|
203
|
+
@callback_formats[CALLBACK_GPIO_STATE] = [9, '?2']
|
|
204
|
+
|
|
205
|
+
@ipcon.add_device self
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Enables/Disables the driver chip. The driver parameters can be configured
|
|
209
|
+
# (velocity, acceleration, etc) before it is enabled.
|
|
210
|
+
def set_enabled(enabled)
|
|
211
|
+
check_validity
|
|
212
|
+
|
|
213
|
+
send_request FUNCTION_SET_ENABLED, [enabled], '?', 8, ''
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Returns *true* if the driver chip is enabled, *false* otherwise.
|
|
217
|
+
def get_enabled
|
|
218
|
+
check_validity
|
|
219
|
+
|
|
220
|
+
send_request FUNCTION_GET_ENABLED, [], '', 9, '?'
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Sets the velocity of the motor. Whereas -32767 is full speed backward,
|
|
224
|
+
# 0 is stop and 32767 is full speed forward. Depending on the
|
|
225
|
+
# acceleration (see BrickletPerformanceDC#set_motion), the motor is not immediately
|
|
226
|
+
# brought to the velocity but smoothly accelerated.
|
|
227
|
+
#
|
|
228
|
+
# The velocity describes the duty cycle of the PWM with which the motor is
|
|
229
|
+
# controlled, e.g. a velocity of 3277 sets a PWM with a 10% duty cycle.
|
|
230
|
+
# You can not only control the duty cycle of the PWM but also the frequency,
|
|
231
|
+
# see BrickletPerformanceDC#set_pwm_frequency.
|
|
232
|
+
def set_velocity(velocity)
|
|
233
|
+
check_validity
|
|
234
|
+
|
|
235
|
+
send_request FUNCTION_SET_VELOCITY, [velocity], 's', 8, ''
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# Returns the velocity as set by BrickletPerformanceDC#set_velocity.
|
|
239
|
+
def get_velocity
|
|
240
|
+
check_validity
|
|
241
|
+
|
|
242
|
+
send_request FUNCTION_GET_VELOCITY, [], '', 10, 's'
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# Returns the *current* velocity of the motor. This value is different
|
|
246
|
+
# from BrickletPerformanceDC#get_velocity whenever the motor is currently accelerating
|
|
247
|
+
# to a goal set by BrickletPerformanceDC#set_velocity.
|
|
248
|
+
def get_current_velocity
|
|
249
|
+
check_validity
|
|
250
|
+
|
|
251
|
+
send_request FUNCTION_GET_CURRENT_VELOCITY, [], '', 10, 's'
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Sets the acceleration and deceleration of the motor. It is given in *velocity/s*.
|
|
255
|
+
# An acceleration of 10000 means, that every second the velocity is increased
|
|
256
|
+
# by 10000 (or about 30% duty cycle).
|
|
257
|
+
#
|
|
258
|
+
# For example: If the current velocity is 0 and you want to accelerate to a
|
|
259
|
+
# velocity of 16000 (about 50% duty cycle) in 10 seconds, you should set
|
|
260
|
+
# an acceleration of 1600.
|
|
261
|
+
#
|
|
262
|
+
# If acceleration and deceleration is set to 0, there is no speed ramping, i.e. a
|
|
263
|
+
# new velocity is immediately given to the motor.
|
|
264
|
+
def set_motion(acceleration, deceleration)
|
|
265
|
+
check_validity
|
|
266
|
+
|
|
267
|
+
send_request FUNCTION_SET_MOTION, [acceleration, deceleration], 'S S', 8, ''
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Returns the acceleration/deceleration as set by BrickletPerformanceDC#set_motion.
|
|
271
|
+
def get_motion
|
|
272
|
+
check_validity
|
|
273
|
+
|
|
274
|
+
send_request FUNCTION_GET_MOTION, [], '', 12, 'S S'
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# Executes an active full brake.
|
|
278
|
+
#
|
|
279
|
+
# .. warning::
|
|
280
|
+
# This function is for emergency purposes,
|
|
281
|
+
# where an immediate brake is necessary. Depending on the current velocity and
|
|
282
|
+
# the strength of the motor, a full brake can be quite violent.
|
|
283
|
+
#
|
|
284
|
+
# Call BrickletPerformanceDC#set_velocity with 0 if you just want to stop the motor.
|
|
285
|
+
def full_brake
|
|
286
|
+
check_validity
|
|
287
|
+
|
|
288
|
+
send_request FUNCTION_FULL_BRAKE, [], '', 8, ''
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# Sets the drive mode. Possible modes are:
|
|
292
|
+
#
|
|
293
|
+
# * 0 = Drive/Brake
|
|
294
|
+
# * 1 = Drive/Coast
|
|
295
|
+
#
|
|
296
|
+
# These modes are different kinds of motor controls.
|
|
297
|
+
#
|
|
298
|
+
# In Drive/Brake mode, the motor is always either driving or braking. There
|
|
299
|
+
# is no freewheeling. Advantages are: A more linear correlation between
|
|
300
|
+
# PWM and velocity, more exact accelerations and the possibility to drive
|
|
301
|
+
# with slower velocities.
|
|
302
|
+
#
|
|
303
|
+
# In Drive/Coast mode, the motor is always either driving or freewheeling.
|
|
304
|
+
# Advantages are: Less current consumption and less demands on the motor and
|
|
305
|
+
# driver chip.
|
|
306
|
+
def set_drive_mode(mode)
|
|
307
|
+
check_validity
|
|
308
|
+
|
|
309
|
+
send_request FUNCTION_SET_DRIVE_MODE, [mode], 'C', 8, ''
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# Returns the drive mode, as set by BrickletPerformanceDC#set_drive_mode.
|
|
313
|
+
def get_drive_mode
|
|
314
|
+
check_validity
|
|
315
|
+
|
|
316
|
+
send_request FUNCTION_GET_DRIVE_MODE, [], '', 9, 'C'
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
# Sets the frequency of the PWM with which the motor is driven.
|
|
320
|
+
# Often a high frequency
|
|
321
|
+
# is less noisy and the motor runs smoother. However, with a low frequency
|
|
322
|
+
# there are less switches and therefore fewer switching losses. Also with
|
|
323
|
+
# most motors lower frequencies enable higher torque.
|
|
324
|
+
#
|
|
325
|
+
# If you have no idea what all this means, just ignore this function and use
|
|
326
|
+
# the default frequency, it will very likely work fine.
|
|
327
|
+
def set_pwm_frequency(frequency)
|
|
328
|
+
check_validity
|
|
329
|
+
|
|
330
|
+
send_request FUNCTION_SET_PWM_FREQUENCY, [frequency], 'S', 8, ''
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
# Returns the PWM frequency as set by BrickletPerformanceDC#set_pwm_frequency.
|
|
334
|
+
def get_pwm_frequency
|
|
335
|
+
check_validity
|
|
336
|
+
|
|
337
|
+
send_request FUNCTION_GET_PWM_FREQUENCY, [], '', 10, 'S'
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# Returns input voltage, current usage and temperature of the driver.
|
|
341
|
+
def get_power_statistics
|
|
342
|
+
check_validity
|
|
343
|
+
|
|
344
|
+
send_request FUNCTION_GET_POWER_STATISTICS, [], '', 14, 'S S s'
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
# Sets a temperature threshold that is used for thermal shutdown.
|
|
348
|
+
#
|
|
349
|
+
# Additionally to this user defined threshold the driver chip will shut down at a
|
|
350
|
+
# temperature of 150°C.
|
|
351
|
+
#
|
|
352
|
+
# If a thermal shutdown is triggered the driver is disabled and has to be
|
|
353
|
+
# explicitly re-enabled with BrickletPerformanceDC#set_enabled.
|
|
354
|
+
def set_thermal_shutdown(temperature)
|
|
355
|
+
check_validity
|
|
356
|
+
|
|
357
|
+
send_request FUNCTION_SET_THERMAL_SHUTDOWN, [temperature], 'C', 8, ''
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Returns the thermal shutdown temperature as set by BrickletPerformanceDC#set_thermal_shutdown.
|
|
361
|
+
def get_thermal_shutdown
|
|
362
|
+
check_validity
|
|
363
|
+
|
|
364
|
+
send_request FUNCTION_GET_THERMAL_SHUTDOWN, [], '', 9, 'C'
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
# Sets the GPIO configuration for the given channel.
|
|
368
|
+
# You can configure a debounce and the deceleration that is used if the action is
|
|
369
|
+
# configured as ``normal stop``. See BrickletPerformanceDC#set_gpio_action.
|
|
370
|
+
def set_gpio_configuration(channel, debounce, stop_deceleration)
|
|
371
|
+
check_validity
|
|
372
|
+
|
|
373
|
+
send_request FUNCTION_SET_GPIO_CONFIGURATION, [channel, debounce, stop_deceleration], 'C S S', 8, ''
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
# Returns the GPIO configuration for a channel as set by BrickletPerformanceDC#set_gpio_configuration.
|
|
377
|
+
def get_gpio_configuration(channel)
|
|
378
|
+
check_validity
|
|
379
|
+
|
|
380
|
+
send_request FUNCTION_GET_GPIO_CONFIGURATION, [channel], 'C', 12, 'S S'
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
# Sets the GPIO action for the given channel.
|
|
384
|
+
#
|
|
385
|
+
# The action can be a normal stop, a full brake or a callback. Each for a rising
|
|
386
|
+
# edge or falling edge. The actions are a bitmask they can be used at the same time.
|
|
387
|
+
# You can for example trigger a full brake and a callback at the same time or for
|
|
388
|
+
# rising and falling edge.
|
|
389
|
+
#
|
|
390
|
+
# The deceleration speed for the normal stop can be configured with
|
|
391
|
+
# BrickletPerformanceDC#set_gpio_configuration.
|
|
392
|
+
def set_gpio_action(channel, action)
|
|
393
|
+
check_validity
|
|
394
|
+
|
|
395
|
+
send_request FUNCTION_SET_GPIO_ACTION, [channel, action], 'C L', 8, ''
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
# Returns the GPIO action for a channel as set by BrickletPerformanceDC#set_gpio_action.
|
|
399
|
+
def get_gpio_action(channel)
|
|
400
|
+
check_validity
|
|
401
|
+
|
|
402
|
+
send_request FUNCTION_GET_GPIO_ACTION, [channel], 'C', 12, 'L'
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
# Returns the GPIO state for both channels. True if the state is ``high`` and
|
|
406
|
+
# false if the state is ``low``.
|
|
407
|
+
def get_gpio_state
|
|
408
|
+
check_validity
|
|
409
|
+
|
|
410
|
+
send_request FUNCTION_GET_GPIO_STATE, [], '', 9, '?2'
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
# Configures the error LED to be either turned off, turned on, blink in
|
|
414
|
+
# heartbeat mode or show an error.
|
|
415
|
+
#
|
|
416
|
+
# If the LED is configured to show errors it has three different states:
|
|
417
|
+
#
|
|
418
|
+
# * Off: No error present.
|
|
419
|
+
# * 1s interval blinking: Input voltage too low (below 6V).
|
|
420
|
+
# * 250ms interval blinking: Overtemperature or overcurrent.
|
|
421
|
+
def set_error_led_config(config)
|
|
422
|
+
check_validity
|
|
423
|
+
|
|
424
|
+
send_request FUNCTION_SET_ERROR_LED_CONFIG, [config], 'C', 8, ''
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
# Returns the LED configuration as set by BrickletPerformanceDC#set_error_led_config
|
|
428
|
+
def get_error_led_config
|
|
429
|
+
check_validity
|
|
430
|
+
|
|
431
|
+
send_request FUNCTION_GET_ERROR_LED_CONFIG, [], '', 9, 'C'
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
# Configures the CW LED to be either turned off, turned on, blink in
|
|
435
|
+
# heartbeat mode or if the motor turn clockwise.
|
|
436
|
+
def set_cw_led_config(config)
|
|
437
|
+
check_validity
|
|
438
|
+
|
|
439
|
+
send_request FUNCTION_SET_CW_LED_CONFIG, [config], 'C', 8, ''
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
# Returns the LED configuration as set by BrickletPerformanceDC#set_cw_led_config
|
|
443
|
+
def get_cw_led_config
|
|
444
|
+
check_validity
|
|
445
|
+
|
|
446
|
+
send_request FUNCTION_GET_CW_LED_CONFIG, [], '', 9, 'C'
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
# Configures the CCW LED to be either turned off, turned on, blink in
|
|
450
|
+
# heartbeat mode or if the motor turn counter-clockwise.
|
|
451
|
+
def set_ccw_led_config(config)
|
|
452
|
+
check_validity
|
|
453
|
+
|
|
454
|
+
send_request FUNCTION_SET_CCW_LED_CONFIG, [config], 'C', 8, ''
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
# Returns the LED configuration as set by BrickletPerformanceDC#set_ccw_led_config
|
|
458
|
+
def get_ccw_led_config
|
|
459
|
+
check_validity
|
|
460
|
+
|
|
461
|
+
send_request FUNCTION_GET_CCW_LED_CONFIG, [], '', 9, 'C'
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
# Configures the GPIO LED to be either turned off, turned on, blink in
|
|
465
|
+
# heartbeat mode or the GPIO state.
|
|
466
|
+
#
|
|
467
|
+
# The GPIO LED can be configured for both channels.
|
|
468
|
+
def set_gpio_led_config(channel, config)
|
|
469
|
+
check_validity
|
|
470
|
+
|
|
471
|
+
send_request FUNCTION_SET_GPIO_LED_CONFIG, [channel, config], 'C C', 8, ''
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
# Returns the LED configuration as set by BrickletPerformanceDC#set_gpio_led_config
|
|
475
|
+
def get_gpio_led_config(channel)
|
|
476
|
+
check_validity
|
|
477
|
+
|
|
478
|
+
send_request FUNCTION_GET_GPIO_LED_CONFIG, [channel], 'C', 9, 'C'
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
# Enable/Disable CALLBACK_EMERGENCY_SHUTDOWN callback.
|
|
482
|
+
def set_emergency_shutdown_callback_configuration(enabled)
|
|
483
|
+
check_validity
|
|
484
|
+
|
|
485
|
+
send_request FUNCTION_SET_EMERGENCY_SHUTDOWN_CALLBACK_CONFIGURATION, [enabled], '?', 8, ''
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
# Returns the callback configuration as set by
|
|
489
|
+
# BrickletPerformanceDC#set_emergency_shutdown_callback_configuration.
|
|
490
|
+
def get_emergency_shutdown_callback_configuration
|
|
491
|
+
check_validity
|
|
492
|
+
|
|
493
|
+
send_request FUNCTION_GET_EMERGENCY_SHUTDOWN_CALLBACK_CONFIGURATION, [], '', 9, '?'
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
# Enable/Disable CALLBACK_VELOCITY_REACHED callback.
|
|
497
|
+
def set_velocity_reached_callback_configuration(enabled)
|
|
498
|
+
check_validity
|
|
499
|
+
|
|
500
|
+
send_request FUNCTION_SET_VELOCITY_REACHED_CALLBACK_CONFIGURATION, [enabled], '?', 8, ''
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
# Returns the callback configuration as set by
|
|
504
|
+
# BrickletPerformanceDC#set_velocity_reached_callback_configuration.
|
|
505
|
+
def get_velocity_reached_callback_configuration
|
|
506
|
+
check_validity
|
|
507
|
+
|
|
508
|
+
send_request FUNCTION_GET_VELOCITY_REACHED_CALLBACK_CONFIGURATION, [], '', 9, '?'
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
# The period is the period with which the CALLBACK_CURRENT_VELOCITY
|
|
512
|
+
# callback is triggered periodically. A value of 0 turns the callback off.
|
|
513
|
+
#
|
|
514
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
515
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
516
|
+
# period, the callback is triggered immediately on change.
|
|
517
|
+
#
|
|
518
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
519
|
+
# independent of the value.
|
|
520
|
+
def set_current_velocity_callback_configuration(period, value_has_to_change)
|
|
521
|
+
check_validity
|
|
522
|
+
|
|
523
|
+
send_request FUNCTION_SET_CURRENT_VELOCITY_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
# Returns the callback configuration as set by
|
|
527
|
+
# BrickletPerformanceDC#set_current_velocity_callback_configuration.
|
|
528
|
+
def get_current_velocity_callback_configuration
|
|
529
|
+
check_validity
|
|
530
|
+
|
|
531
|
+
send_request FUNCTION_GET_CURRENT_VELOCITY_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
535
|
+
#
|
|
536
|
+
# The errors are divided into
|
|
537
|
+
#
|
|
538
|
+
# * ACK checksum errors,
|
|
539
|
+
# * message checksum errors,
|
|
540
|
+
# * framing errors and
|
|
541
|
+
# * overflow errors.
|
|
542
|
+
#
|
|
543
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
544
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
545
|
+
def get_spitfp_error_count
|
|
546
|
+
check_validity
|
|
547
|
+
|
|
548
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
552
|
+
# mode change was instigated.
|
|
553
|
+
#
|
|
554
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
555
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
556
|
+
# device identifier and CRC are present and correct.
|
|
557
|
+
#
|
|
558
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
559
|
+
# necessary to call it in a normal user program.
|
|
560
|
+
def set_bootloader_mode(mode)
|
|
561
|
+
check_validity
|
|
562
|
+
|
|
563
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
# Returns the current bootloader mode, see BrickletPerformanceDC#set_bootloader_mode.
|
|
567
|
+
def get_bootloader_mode
|
|
568
|
+
check_validity
|
|
569
|
+
|
|
570
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
# Sets the firmware pointer for BrickletPerformanceDC#write_firmware. The pointer has
|
|
574
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
575
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
576
|
+
#
|
|
577
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
578
|
+
# necessary to call it in a normal user program.
|
|
579
|
+
def set_write_firmware_pointer(pointer)
|
|
580
|
+
check_validity
|
|
581
|
+
|
|
582
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
583
|
+
end
|
|
584
|
+
|
|
585
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
586
|
+
# BrickletPerformanceDC#set_write_firmware_pointer before. The firmware is written
|
|
587
|
+
# to flash every 4 chunks.
|
|
588
|
+
#
|
|
589
|
+
# You can only write firmware in bootloader mode.
|
|
590
|
+
#
|
|
591
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
592
|
+
# necessary to call it in a normal user program.
|
|
593
|
+
def write_firmware(data)
|
|
594
|
+
check_validity
|
|
595
|
+
|
|
596
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
# Sets the status LED configuration. By default the LED shows
|
|
600
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
601
|
+
# for every 10 received data packets.
|
|
602
|
+
#
|
|
603
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
604
|
+
#
|
|
605
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
606
|
+
def set_status_led_config(config)
|
|
607
|
+
check_validity
|
|
608
|
+
|
|
609
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
# Returns the configuration as set by BrickletPerformanceDC#set_status_led_config
|
|
613
|
+
def get_status_led_config
|
|
614
|
+
check_validity
|
|
615
|
+
|
|
616
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
620
|
+
# value returned is not the ambient temperature!
|
|
621
|
+
#
|
|
622
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
623
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
624
|
+
# temperature changes.
|
|
625
|
+
def get_chip_temperature
|
|
626
|
+
check_validity
|
|
627
|
+
|
|
628
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
632
|
+
# will be lost.
|
|
633
|
+
#
|
|
634
|
+
# After a reset you have to create new device objects,
|
|
635
|
+
# calling functions on the existing ones will result in
|
|
636
|
+
# undefined behavior!
|
|
637
|
+
def reset
|
|
638
|
+
check_validity
|
|
639
|
+
|
|
640
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
644
|
+
# you have to decode the Base58 encoded UID string into an
|
|
645
|
+
# integer first.
|
|
646
|
+
#
|
|
647
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
648
|
+
def write_uid(uid)
|
|
649
|
+
check_validity
|
|
650
|
+
|
|
651
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
652
|
+
end
|
|
653
|
+
|
|
654
|
+
# Returns the current UID as an integer. Encode as
|
|
655
|
+
# Base58 to get the usual string version.
|
|
656
|
+
def read_uid
|
|
657
|
+
check_validity
|
|
658
|
+
|
|
659
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
660
|
+
end
|
|
661
|
+
|
|
662
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
663
|
+
# the position, the hardware and firmware version as well as the
|
|
664
|
+
# device identifier.
|
|
665
|
+
#
|
|
666
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
667
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
668
|
+
# position 'z'.
|
|
669
|
+
#
|
|
670
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
671
|
+
# |device_identifier_constant|
|
|
672
|
+
def get_identity
|
|
673
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
674
|
+
end
|
|
675
|
+
|
|
676
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
677
|
+
def register_callback(id, &block)
|
|
678
|
+
callback = block
|
|
679
|
+
@registered_callbacks[id] = callback
|
|
680
|
+
end
|
|
681
|
+
end
|
|
682
|
+
end
|