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