tinkerforge 2.1.22 → 2.1.27
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 +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# Measures relative humidity
|
|
14
16
|
class BrickletHumidityV2 < Device
|
|
@@ -84,7 +86,7 @@ module Tinkerforge
|
|
|
84
86
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
85
87
|
# the IP Connection <tt>ipcon</tt>.
|
|
86
88
|
def initialize(uid, ipcon)
|
|
87
|
-
super uid, ipcon
|
|
89
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
88
90
|
|
|
89
91
|
@api_version = [2, 0, 2]
|
|
90
92
|
|
|
@@ -113,24 +115,25 @@ module Tinkerforge
|
|
|
113
115
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
114
116
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
115
117
|
|
|
116
|
-
@callback_formats[CALLBACK_HUMIDITY] = 'S'
|
|
117
|
-
@callback_formats[CALLBACK_TEMPERATURE] = 's'
|
|
118
|
+
@callback_formats[CALLBACK_HUMIDITY] = [10, 'S']
|
|
119
|
+
@callback_formats[CALLBACK_TEMPERATURE] = [10, 's']
|
|
118
120
|
|
|
121
|
+
@ipcon.add_device self
|
|
119
122
|
end
|
|
120
123
|
|
|
121
|
-
# Returns the humidity measured by the sensor.
|
|
122
|
-
# has a range of 0 to 10000 and is given in %RH/100 (Relative Humidity),
|
|
123
|
-
# i.e. a value of 4223 means that a humidity of 42.23 %RH is measured.
|
|
124
|
+
# Returns the humidity measured by the sensor.
|
|
124
125
|
#
|
|
125
126
|
#
|
|
126
127
|
# If you want to get the value periodically, it is recommended to use the
|
|
127
128
|
# CALLBACK_HUMIDITY callback. You can set the callback configuration
|
|
128
129
|
# with BrickletHumidityV2#set_humidity_callback_configuration.
|
|
129
130
|
def get_humidity
|
|
130
|
-
|
|
131
|
+
check_validity
|
|
132
|
+
|
|
133
|
+
send_request FUNCTION_GET_HUMIDITY, [], '', 10, 'S'
|
|
131
134
|
end
|
|
132
135
|
|
|
133
|
-
# The period
|
|
136
|
+
# The period is the period with which the CALLBACK_HUMIDITY callback is triggered
|
|
134
137
|
# periodically. A value of 0 turns the callback off.
|
|
135
138
|
#
|
|
136
139
|
# If the `value has to change`-parameter is set to true, the callback is only
|
|
@@ -155,30 +158,32 @@ module Tinkerforge
|
|
|
155
158
|
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
156
159
|
#
|
|
157
160
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
158
|
-
#
|
|
159
|
-
# The default value is (0, false, 'x', 0, 0).
|
|
160
161
|
def set_humidity_callback_configuration(period, value_has_to_change, option, min, max)
|
|
161
|
-
|
|
162
|
+
check_validity
|
|
163
|
+
|
|
164
|
+
send_request FUNCTION_SET_HUMIDITY_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 8, ''
|
|
162
165
|
end
|
|
163
166
|
|
|
164
167
|
# Returns the callback configuration as set by BrickletHumidityV2#set_humidity_callback_configuration.
|
|
165
168
|
def get_humidity_callback_configuration
|
|
166
|
-
|
|
169
|
+
check_validity
|
|
170
|
+
|
|
171
|
+
send_request FUNCTION_GET_HUMIDITY_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k S S'
|
|
167
172
|
end
|
|
168
173
|
|
|
169
|
-
# Returns the temperature measured by the sensor.
|
|
170
|
-
# has a range of -4000 to 16500 and is given in °C/100,
|
|
171
|
-
# i.e. a value of 3200 means that a temperature of 32.00 °C is measured.
|
|
174
|
+
# Returns the temperature measured by the sensor.
|
|
172
175
|
#
|
|
173
176
|
#
|
|
174
177
|
# If you want to get the value periodically, it is recommended to use the
|
|
175
178
|
# CALLBACK_TEMPERATURE callback. You can set the callback configuration
|
|
176
179
|
# with BrickletHumidityV2#set_temperature_callback_configuration.
|
|
177
180
|
def get_temperature
|
|
178
|
-
|
|
181
|
+
check_validity
|
|
182
|
+
|
|
183
|
+
send_request FUNCTION_GET_TEMPERATURE, [], '', 10, 's'
|
|
179
184
|
end
|
|
180
185
|
|
|
181
|
-
# The period
|
|
186
|
+
# The period is the period with which the CALLBACK_TEMPERATURE callback is triggered
|
|
182
187
|
# periodically. A value of 0 turns the callback off.
|
|
183
188
|
#
|
|
184
189
|
# If the `value has to change`-parameter is set to true, the callback is only
|
|
@@ -203,28 +208,32 @@ module Tinkerforge
|
|
|
203
208
|
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
204
209
|
#
|
|
205
210
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
206
|
-
#
|
|
207
|
-
# The default value is (0, false, 'x', 0, 0).
|
|
208
211
|
def set_temperature_callback_configuration(period, value_has_to_change, option, min, max)
|
|
209
|
-
|
|
212
|
+
check_validity
|
|
213
|
+
|
|
214
|
+
send_request FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 8, ''
|
|
210
215
|
end
|
|
211
216
|
|
|
212
217
|
# Returns the callback configuration as set by BrickletHumidityV2#set_temperature_callback_configuration.
|
|
213
218
|
def get_temperature_callback_configuration
|
|
214
|
-
|
|
219
|
+
check_validity
|
|
220
|
+
|
|
221
|
+
send_request FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k s s'
|
|
215
222
|
end
|
|
216
223
|
|
|
217
224
|
# Enables/disables the heater. The heater can be used to dry the sensor in
|
|
218
225
|
# extremely wet conditions.
|
|
219
|
-
#
|
|
220
|
-
# By default the heater is disabled.
|
|
221
226
|
def set_heater_configuration(heater_config)
|
|
222
|
-
|
|
227
|
+
check_validity
|
|
228
|
+
|
|
229
|
+
send_request FUNCTION_SET_HEATER_CONFIGURATION, [heater_config], 'C', 8, ''
|
|
223
230
|
end
|
|
224
231
|
|
|
225
232
|
# Returns the heater configuration as set by BrickletHumidityV2#set_heater_configuration.
|
|
226
233
|
def get_heater_configuration
|
|
227
|
-
|
|
234
|
+
check_validity
|
|
235
|
+
|
|
236
|
+
send_request FUNCTION_GET_HEATER_CONFIGURATION, [], '', 9, 'C'
|
|
228
237
|
end
|
|
229
238
|
|
|
230
239
|
# Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
|
|
@@ -233,25 +242,25 @@ module Tinkerforge
|
|
|
233
242
|
# Setting the length to 1 will turn the averaging off. With less
|
|
234
243
|
# averaging, there is more noise on the data.
|
|
235
244
|
#
|
|
236
|
-
# The range for the averaging is 1-1000.
|
|
237
|
-
#
|
|
238
245
|
# New data is gathered every 50ms*. With a moving average of length 1000 the resulting
|
|
239
246
|
# averaging window has a length of 50s. If you want to do long term measurements the longest
|
|
240
247
|
# moving average will give the cleanest results.
|
|
241
248
|
#
|
|
242
|
-
# The default value is 5.
|
|
243
|
-
#
|
|
244
249
|
# \* In firmware version 2.0.3 we added the BrickletHumidityV2#set_samples_per_second function. It
|
|
245
250
|
# configures the measurement frequency. Since high frequencies can result in self-heating
|
|
246
251
|
# of th IC, changed the default value from 20 samples per second to 1. With 1 sample per second
|
|
247
252
|
# a moving average length of 1000 would result in an averaging window of 1000 seconds!
|
|
248
253
|
def set_moving_average_configuration(moving_average_length_humidity, moving_average_length_temperature)
|
|
249
|
-
|
|
254
|
+
check_validity
|
|
255
|
+
|
|
256
|
+
send_request FUNCTION_SET_MOVING_AVERAGE_CONFIGURATION, [moving_average_length_humidity, moving_average_length_temperature], 'S S', 8, ''
|
|
250
257
|
end
|
|
251
258
|
|
|
252
259
|
# Returns the moving average configuration as set by BrickletHumidityV2#set_moving_average_configuration.
|
|
253
260
|
def get_moving_average_configuration
|
|
254
|
-
|
|
261
|
+
check_validity
|
|
262
|
+
|
|
263
|
+
send_request FUNCTION_GET_MOVING_AVERAGE_CONFIGURATION, [], '', 12, 'S S'
|
|
255
264
|
end
|
|
256
265
|
|
|
257
266
|
# Sets the samples per second that are gathered by the humidity/temperature sensor HDC1080.
|
|
@@ -266,14 +275,18 @@ module Tinkerforge
|
|
|
266
275
|
#
|
|
267
276
|
# .. versionadded:: 2.0.3$nbsp;(Plugin)
|
|
268
277
|
def set_samples_per_second(sps)
|
|
269
|
-
|
|
278
|
+
check_validity
|
|
279
|
+
|
|
280
|
+
send_request FUNCTION_SET_SAMPLES_PER_SECOND, [sps], 'C', 8, ''
|
|
270
281
|
end
|
|
271
282
|
|
|
272
283
|
# Returnes the samples per second, as set by BrickletHumidityV2#set_samples_per_second.
|
|
273
284
|
#
|
|
274
285
|
# .. versionadded:: 2.0.3$nbsp;(Plugin)
|
|
275
286
|
def get_samples_per_second
|
|
276
|
-
|
|
287
|
+
check_validity
|
|
288
|
+
|
|
289
|
+
send_request FUNCTION_GET_SAMPLES_PER_SECOND, [], '', 9, 'C'
|
|
277
290
|
end
|
|
278
291
|
|
|
279
292
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -288,7 +301,9 @@ module Tinkerforge
|
|
|
288
301
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
289
302
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
290
303
|
def get_spitfp_error_count
|
|
291
|
-
|
|
304
|
+
check_validity
|
|
305
|
+
|
|
306
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
292
307
|
end
|
|
293
308
|
|
|
294
309
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -301,12 +316,16 @@ module Tinkerforge
|
|
|
301
316
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
302
317
|
# necessary to call it in a normal user program.
|
|
303
318
|
def set_bootloader_mode(mode)
|
|
304
|
-
|
|
319
|
+
check_validity
|
|
320
|
+
|
|
321
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
305
322
|
end
|
|
306
323
|
|
|
307
324
|
# Returns the current bootloader mode, see BrickletHumidityV2#set_bootloader_mode.
|
|
308
325
|
def get_bootloader_mode
|
|
309
|
-
|
|
326
|
+
check_validity
|
|
327
|
+
|
|
328
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
310
329
|
end
|
|
311
330
|
|
|
312
331
|
# Sets the firmware pointer for BrickletHumidityV2#write_firmware. The pointer has
|
|
@@ -316,7 +335,9 @@ module Tinkerforge
|
|
|
316
335
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
317
336
|
# necessary to call it in a normal user program.
|
|
318
337
|
def set_write_firmware_pointer(pointer)
|
|
319
|
-
|
|
338
|
+
check_validity
|
|
339
|
+
|
|
340
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
320
341
|
end
|
|
321
342
|
|
|
322
343
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -328,7 +349,9 @@ module Tinkerforge
|
|
|
328
349
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
329
350
|
# necessary to call it in a normal user program.
|
|
330
351
|
def write_firmware(data)
|
|
331
|
-
|
|
352
|
+
check_validity
|
|
353
|
+
|
|
354
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
332
355
|
end
|
|
333
356
|
|
|
334
357
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -339,22 +362,28 @@ module Tinkerforge
|
|
|
339
362
|
#
|
|
340
363
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
341
364
|
def set_status_led_config(config)
|
|
342
|
-
|
|
365
|
+
check_validity
|
|
366
|
+
|
|
367
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
343
368
|
end
|
|
344
369
|
|
|
345
370
|
# Returns the configuration as set by BrickletHumidityV2#set_status_led_config
|
|
346
371
|
def get_status_led_config
|
|
347
|
-
|
|
372
|
+
check_validity
|
|
373
|
+
|
|
374
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
348
375
|
end
|
|
349
376
|
|
|
350
|
-
# Returns the temperature
|
|
377
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
351
378
|
# value returned is not the ambient temperature!
|
|
352
379
|
#
|
|
353
380
|
# The temperature is only proportional to the real temperature and it has bad
|
|
354
381
|
# accuracy. Practically it is only useful as an indicator for
|
|
355
382
|
# temperature changes.
|
|
356
383
|
def get_chip_temperature
|
|
357
|
-
|
|
384
|
+
check_validity
|
|
385
|
+
|
|
386
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
358
387
|
end
|
|
359
388
|
|
|
360
389
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -364,7 +393,9 @@ module Tinkerforge
|
|
|
364
393
|
# calling functions on the existing ones will result in
|
|
365
394
|
# undefined behavior!
|
|
366
395
|
def reset
|
|
367
|
-
|
|
396
|
+
check_validity
|
|
397
|
+
|
|
398
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
368
399
|
end
|
|
369
400
|
|
|
370
401
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -373,25 +404,31 @@ module Tinkerforge
|
|
|
373
404
|
#
|
|
374
405
|
# We recommend that you use Brick Viewer to change the UID.
|
|
375
406
|
def write_uid(uid)
|
|
376
|
-
|
|
407
|
+
check_validity
|
|
408
|
+
|
|
409
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
377
410
|
end
|
|
378
411
|
|
|
379
412
|
# Returns the current UID as an integer. Encode as
|
|
380
413
|
# Base58 to get the usual string version.
|
|
381
414
|
def read_uid
|
|
382
|
-
|
|
415
|
+
check_validity
|
|
416
|
+
|
|
417
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
383
418
|
end
|
|
384
419
|
|
|
385
420
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
386
421
|
# the position, the hardware and firmware version as well as the
|
|
387
422
|
# device identifier.
|
|
388
423
|
#
|
|
389
|
-
# The position can be 'a', 'b', 'c' or '
|
|
424
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
425
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
426
|
+
# position 'z'.
|
|
390
427
|
#
|
|
391
428
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
392
429
|
# |device_identifier_constant|
|
|
393
430
|
def get_identity
|
|
394
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
431
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
395
432
|
end
|
|
396
433
|
|
|
397
434
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
@@ -0,0 +1,784 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
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
|
+
# Full fledged AHRS with 9 degrees of freedom
|
|
16
|
+
class BrickletIMUV3 < Device
|
|
17
|
+
DEVICE_IDENTIFIER = 2161 # :nodoc:
|
|
18
|
+
DEVICE_DISPLAY_NAME = 'IMU Bricklet 3.0' # :nodoc:
|
|
19
|
+
|
|
20
|
+
# This callback is triggered periodically with the period that is set by
|
|
21
|
+
# BrickletIMUV3#set_acceleration_callback_configuration. The parameters are the acceleration
|
|
22
|
+
# for the x, y and z axis.
|
|
23
|
+
CALLBACK_ACCELERATION = 33
|
|
24
|
+
|
|
25
|
+
# This callback is triggered periodically with the period that is set by
|
|
26
|
+
# BrickletIMUV3#set_magnetic_field_callback_configuration. The parameters are the magnetic
|
|
27
|
+
# field for the x, y and z axis.
|
|
28
|
+
CALLBACK_MAGNETIC_FIELD = 34
|
|
29
|
+
|
|
30
|
+
# This callback is triggered periodically with the period that is set by
|
|
31
|
+
# BrickletIMUV3#set_angular_velocity_callback_configuration. The parameters are the angular
|
|
32
|
+
# velocity for the x, y and z axis.
|
|
33
|
+
CALLBACK_ANGULAR_VELOCITY = 35
|
|
34
|
+
|
|
35
|
+
# This callback is triggered periodically with the period that is set by
|
|
36
|
+
# BrickletIMUV3#set_temperature_callback_configuration. The parameter is the temperature.
|
|
37
|
+
CALLBACK_TEMPERATURE = 36
|
|
38
|
+
|
|
39
|
+
# This callback is triggered periodically with the period that is set by
|
|
40
|
+
# BrickletIMUV3#set_linear_acceleration_callback_configuration. The parameters are the
|
|
41
|
+
# linear acceleration for the x, y and z axis.
|
|
42
|
+
CALLBACK_LINEAR_ACCELERATION = 37
|
|
43
|
+
|
|
44
|
+
# This callback is triggered periodically with the period that is set by
|
|
45
|
+
# BrickletIMUV3#set_gravity_vector_callback_configuration. The parameters gravity vector
|
|
46
|
+
# for the x, y and z axis.
|
|
47
|
+
CALLBACK_GRAVITY_VECTOR = 38
|
|
48
|
+
|
|
49
|
+
# This callback is triggered periodically with the period that is set by
|
|
50
|
+
# BrickletIMUV3#set_orientation_callback_configuration. The parameters are the orientation
|
|
51
|
+
# (heading (yaw), roll, pitch) of the IMU Brick in Euler angles. See
|
|
52
|
+
# BrickletIMUV3#get_orientation for details.
|
|
53
|
+
CALLBACK_ORIENTATION = 39
|
|
54
|
+
|
|
55
|
+
# This callback is triggered periodically with the period that is set by
|
|
56
|
+
# BrickletIMUV3#set_quaternion_callback_configuration. The parameters are the orientation
|
|
57
|
+
# (w, x, y, z) of the IMU Brick in quaternions. See BrickletIMUV3#get_quaternion
|
|
58
|
+
# for details.
|
|
59
|
+
CALLBACK_QUATERNION = 40
|
|
60
|
+
|
|
61
|
+
# This callback is triggered periodically with the period that is set by
|
|
62
|
+
# BrickletIMUV3#set_all_data_callback_configuration. The parameters are as for
|
|
63
|
+
# BrickletIMUV3#get_all_data.
|
|
64
|
+
CALLBACK_ALL_DATA = 41
|
|
65
|
+
|
|
66
|
+
FUNCTION_GET_ACCELERATION = 1 # :nodoc:
|
|
67
|
+
FUNCTION_GET_MAGNETIC_FIELD = 2 # :nodoc:
|
|
68
|
+
FUNCTION_GET_ANGULAR_VELOCITY = 3 # :nodoc:
|
|
69
|
+
FUNCTION_GET_TEMPERATURE = 4 # :nodoc:
|
|
70
|
+
FUNCTION_GET_ORIENTATION = 5 # :nodoc:
|
|
71
|
+
FUNCTION_GET_LINEAR_ACCELERATION = 6 # :nodoc:
|
|
72
|
+
FUNCTION_GET_GRAVITY_VECTOR = 7 # :nodoc:
|
|
73
|
+
FUNCTION_GET_QUATERNION = 8 # :nodoc:
|
|
74
|
+
FUNCTION_GET_ALL_DATA = 9 # :nodoc:
|
|
75
|
+
FUNCTION_SAVE_CALIBRATION = 10 # :nodoc:
|
|
76
|
+
FUNCTION_SET_SENSOR_CONFIGURATION = 11 # :nodoc:
|
|
77
|
+
FUNCTION_GET_SENSOR_CONFIGURATION = 12 # :nodoc:
|
|
78
|
+
FUNCTION_SET_SENSOR_FUSION_MODE = 13 # :nodoc:
|
|
79
|
+
FUNCTION_GET_SENSOR_FUSION_MODE = 14 # :nodoc:
|
|
80
|
+
FUNCTION_SET_ACCELERATION_CALLBACK_CONFIGURATION = 15 # :nodoc:
|
|
81
|
+
FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION = 16 # :nodoc:
|
|
82
|
+
FUNCTION_SET_MAGNETIC_FIELD_CALLBACK_CONFIGURATION = 17 # :nodoc:
|
|
83
|
+
FUNCTION_GET_MAGNETIC_FIELD_CALLBACK_CONFIGURATION = 18 # :nodoc:
|
|
84
|
+
FUNCTION_SET_ANGULAR_VELOCITY_CALLBACK_CONFIGURATION = 19 # :nodoc:
|
|
85
|
+
FUNCTION_GET_ANGULAR_VELOCITY_CALLBACK_CONFIGURATION = 20 # :nodoc:
|
|
86
|
+
FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION = 21 # :nodoc:
|
|
87
|
+
FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION = 22 # :nodoc:
|
|
88
|
+
FUNCTION_SET_ORIENTATION_CALLBACK_CONFIGURATION = 23 # :nodoc:
|
|
89
|
+
FUNCTION_GET_ORIENTATION_CALLBACK_CONFIGURATION = 24 # :nodoc:
|
|
90
|
+
FUNCTION_SET_LINEAR_ACCELERATION_CALLBACK_CONFIGURATION = 25 # :nodoc:
|
|
91
|
+
FUNCTION_GET_LINEAR_ACCELERATION_CALLBACK_CONFIGURATION = 26 # :nodoc:
|
|
92
|
+
FUNCTION_SET_GRAVITY_VECTOR_CALLBACK_CONFIGURATION = 27 # :nodoc:
|
|
93
|
+
FUNCTION_GET_GRAVITY_VECTOR_CALLBACK_CONFIGURATION = 28 # :nodoc:
|
|
94
|
+
FUNCTION_SET_QUATERNION_CALLBACK_CONFIGURATION = 29 # :nodoc:
|
|
95
|
+
FUNCTION_GET_QUATERNION_CALLBACK_CONFIGURATION = 30 # :nodoc:
|
|
96
|
+
FUNCTION_SET_ALL_DATA_CALLBACK_CONFIGURATION = 31 # :nodoc:
|
|
97
|
+
FUNCTION_GET_ALL_DATA_CALLBACK_CONFIGURATION = 32 # :nodoc:
|
|
98
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
99
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
100
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
101
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
102
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
103
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
104
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
105
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
106
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
107
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
108
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
109
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
110
|
+
|
|
111
|
+
MAGNETOMETER_RATE_2HZ = 0 # :nodoc:
|
|
112
|
+
MAGNETOMETER_RATE_6HZ = 1 # :nodoc:
|
|
113
|
+
MAGNETOMETER_RATE_8HZ = 2 # :nodoc:
|
|
114
|
+
MAGNETOMETER_RATE_10HZ = 3 # :nodoc:
|
|
115
|
+
MAGNETOMETER_RATE_15HZ = 4 # :nodoc:
|
|
116
|
+
MAGNETOMETER_RATE_20HZ = 5 # :nodoc:
|
|
117
|
+
MAGNETOMETER_RATE_25HZ = 6 # :nodoc:
|
|
118
|
+
MAGNETOMETER_RATE_30HZ = 7 # :nodoc:
|
|
119
|
+
GYROSCOPE_RANGE_2000DPS = 0 # :nodoc:
|
|
120
|
+
GYROSCOPE_RANGE_1000DPS = 1 # :nodoc:
|
|
121
|
+
GYROSCOPE_RANGE_500DPS = 2 # :nodoc:
|
|
122
|
+
GYROSCOPE_RANGE_250DPS = 3 # :nodoc:
|
|
123
|
+
GYROSCOPE_RANGE_125DPS = 4 # :nodoc:
|
|
124
|
+
GYROSCOPE_BANDWIDTH_523HZ = 0 # :nodoc:
|
|
125
|
+
GYROSCOPE_BANDWIDTH_230HZ = 1 # :nodoc:
|
|
126
|
+
GYROSCOPE_BANDWIDTH_116HZ = 2 # :nodoc:
|
|
127
|
+
GYROSCOPE_BANDWIDTH_47HZ = 3 # :nodoc:
|
|
128
|
+
GYROSCOPE_BANDWIDTH_23HZ = 4 # :nodoc:
|
|
129
|
+
GYROSCOPE_BANDWIDTH_12HZ = 5 # :nodoc:
|
|
130
|
+
GYROSCOPE_BANDWIDTH_64HZ = 6 # :nodoc:
|
|
131
|
+
GYROSCOPE_BANDWIDTH_32HZ = 7 # :nodoc:
|
|
132
|
+
ACCELEROMETER_RANGE_2G = 0 # :nodoc:
|
|
133
|
+
ACCELEROMETER_RANGE_4G = 1 # :nodoc:
|
|
134
|
+
ACCELEROMETER_RANGE_8G = 2 # :nodoc:
|
|
135
|
+
ACCELEROMETER_RANGE_16G = 3 # :nodoc:
|
|
136
|
+
ACCELEROMETER_BANDWIDTH_7_81HZ = 0 # :nodoc:
|
|
137
|
+
ACCELEROMETER_BANDWIDTH_15_63HZ = 1 # :nodoc:
|
|
138
|
+
ACCELEROMETER_BANDWIDTH_31_25HZ = 2 # :nodoc:
|
|
139
|
+
ACCELEROMETER_BANDWIDTH_62_5HZ = 3 # :nodoc:
|
|
140
|
+
ACCELEROMETER_BANDWIDTH_125HZ = 4 # :nodoc:
|
|
141
|
+
ACCELEROMETER_BANDWIDTH_250HZ = 5 # :nodoc:
|
|
142
|
+
ACCELEROMETER_BANDWIDTH_500HZ = 6 # :nodoc:
|
|
143
|
+
ACCELEROMETER_BANDWIDTH_1000HZ = 7 # :nodoc:
|
|
144
|
+
SENSOR_FUSION_OFF = 0 # :nodoc:
|
|
145
|
+
SENSOR_FUSION_ON = 1 # :nodoc:
|
|
146
|
+
SENSOR_FUSION_ON_WITHOUT_MAGNETOMETER = 2 # :nodoc:
|
|
147
|
+
SENSOR_FUSION_ON_WITHOUT_FAST_MAGNETOMETER_CALIBRATION = 3 # :nodoc:
|
|
148
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
149
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
150
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
151
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
152
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
153
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
154
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
155
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
156
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
157
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
158
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
159
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
160
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
161
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
162
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
163
|
+
|
|
164
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
165
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
166
|
+
def initialize(uid, ipcon)
|
|
167
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
168
|
+
|
|
169
|
+
@api_version = [2, 0, 0]
|
|
170
|
+
|
|
171
|
+
@response_expected[FUNCTION_GET_ACCELERATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
172
|
+
@response_expected[FUNCTION_GET_MAGNETIC_FIELD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
173
|
+
@response_expected[FUNCTION_GET_ANGULAR_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
174
|
+
@response_expected[FUNCTION_GET_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
175
|
+
@response_expected[FUNCTION_GET_ORIENTATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
176
|
+
@response_expected[FUNCTION_GET_LINEAR_ACCELERATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
177
|
+
@response_expected[FUNCTION_GET_GRAVITY_VECTOR] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
178
|
+
@response_expected[FUNCTION_GET_QUATERNION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
179
|
+
@response_expected[FUNCTION_GET_ALL_DATA] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
180
|
+
@response_expected[FUNCTION_SAVE_CALIBRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
181
|
+
@response_expected[FUNCTION_SET_SENSOR_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
|
182
|
+
@response_expected[FUNCTION_GET_SENSOR_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
183
|
+
@response_expected[FUNCTION_SET_SENSOR_FUSION_MODE] = RESPONSE_EXPECTED_FALSE
|
|
184
|
+
@response_expected[FUNCTION_GET_SENSOR_FUSION_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
185
|
+
@response_expected[FUNCTION_SET_ACCELERATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
186
|
+
@response_expected[FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
187
|
+
@response_expected[FUNCTION_SET_MAGNETIC_FIELD_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
188
|
+
@response_expected[FUNCTION_GET_MAGNETIC_FIELD_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
189
|
+
@response_expected[FUNCTION_SET_ANGULAR_VELOCITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
190
|
+
@response_expected[FUNCTION_GET_ANGULAR_VELOCITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
191
|
+
@response_expected[FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
192
|
+
@response_expected[FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
193
|
+
@response_expected[FUNCTION_SET_ORIENTATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
194
|
+
@response_expected[FUNCTION_GET_ORIENTATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
195
|
+
@response_expected[FUNCTION_SET_LINEAR_ACCELERATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
196
|
+
@response_expected[FUNCTION_GET_LINEAR_ACCELERATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
197
|
+
@response_expected[FUNCTION_SET_GRAVITY_VECTOR_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
198
|
+
@response_expected[FUNCTION_GET_GRAVITY_VECTOR_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
199
|
+
@response_expected[FUNCTION_SET_QUATERNION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
200
|
+
@response_expected[FUNCTION_GET_QUATERNION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
201
|
+
@response_expected[FUNCTION_SET_ALL_DATA_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
202
|
+
@response_expected[FUNCTION_GET_ALL_DATA_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
203
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
204
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
205
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
206
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
207
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
208
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
209
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
210
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
211
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
212
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
213
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
214
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
215
|
+
|
|
216
|
+
@callback_formats[CALLBACK_ACCELERATION] = [14, 's s s']
|
|
217
|
+
@callback_formats[CALLBACK_MAGNETIC_FIELD] = [14, 's s s']
|
|
218
|
+
@callback_formats[CALLBACK_ANGULAR_VELOCITY] = [14, 's s s']
|
|
219
|
+
@callback_formats[CALLBACK_TEMPERATURE] = [9, 'c']
|
|
220
|
+
@callback_formats[CALLBACK_LINEAR_ACCELERATION] = [14, 's s s']
|
|
221
|
+
@callback_formats[CALLBACK_GRAVITY_VECTOR] = [14, 's s s']
|
|
222
|
+
@callback_formats[CALLBACK_ORIENTATION] = [14, 's s s']
|
|
223
|
+
@callback_formats[CALLBACK_QUATERNION] = [16, 's s s s']
|
|
224
|
+
@callback_formats[CALLBACK_ALL_DATA] = [54, 's3 s3 s3 s3 s4 s3 s3 c C']
|
|
225
|
+
|
|
226
|
+
@ipcon.add_device self
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Returns the calibrated acceleration from the accelerometer for the
|
|
230
|
+
# x, y and z axis. The acceleration is in the range configured with
|
|
231
|
+
# BrickletIMUV3#set_sensor_configuration.
|
|
232
|
+
#
|
|
233
|
+
# If you want to get the acceleration periodically, it is recommended
|
|
234
|
+
# to use the CALLBACK_ACCELERATION callback and set the period with
|
|
235
|
+
# BrickletIMUV3#set_acceleration_callback_configuration.
|
|
236
|
+
def get_acceleration
|
|
237
|
+
check_validity
|
|
238
|
+
|
|
239
|
+
send_request FUNCTION_GET_ACCELERATION, [], '', 14, 's s s'
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# Returns the calibrated magnetic field from the magnetometer for the
|
|
243
|
+
# x, y and z axis.
|
|
244
|
+
#
|
|
245
|
+
# If you want to get the magnetic field periodically, it is recommended
|
|
246
|
+
# to use the CALLBACK_MAGNETIC_FIELD callback and set the period with
|
|
247
|
+
# BrickletIMUV3#set_magnetic_field_callback_configuration.
|
|
248
|
+
def get_magnetic_field
|
|
249
|
+
check_validity
|
|
250
|
+
|
|
251
|
+
send_request FUNCTION_GET_MAGNETIC_FIELD, [], '', 14, 's s s'
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Returns the calibrated angular velocity from the gyroscope for the
|
|
255
|
+
# x, y and z axis. The angular velocity is in the range configured with
|
|
256
|
+
# BrickletIMUV3#set_sensor_configuration.
|
|
257
|
+
#
|
|
258
|
+
# If you want to get the angular velocity periodically, it is recommended
|
|
259
|
+
# to use the CALLBACK_ANGULAR_VELOCITY acallback nd set the period with
|
|
260
|
+
# BrickletIMUV3#set_angular_velocity_callback_configuration.
|
|
261
|
+
def get_angular_velocity
|
|
262
|
+
check_validity
|
|
263
|
+
|
|
264
|
+
send_request FUNCTION_GET_ANGULAR_VELOCITY, [], '', 14, 's s s'
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# Returns the temperature of the IMU Brick.
|
|
268
|
+
# The temperature is measured in the core of the BNO055 IC, it is not the
|
|
269
|
+
# ambient temperature
|
|
270
|
+
def get_temperature
|
|
271
|
+
check_validity
|
|
272
|
+
|
|
273
|
+
send_request FUNCTION_GET_TEMPERATURE, [], '', 9, 'c'
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Returns the current orientation (heading, roll, pitch) of the IMU Brick as
|
|
277
|
+
# independent Euler angles. Note that Euler angles always
|
|
278
|
+
# experience a `gimbal lock <https://en.wikipedia.org/wiki/Gimbal_lock>`__.
|
|
279
|
+
# We recommend that you use quaternions instead, if you need the absolute
|
|
280
|
+
# orientation.
|
|
281
|
+
#
|
|
282
|
+
# If you want to get the orientation periodically, it is recommended
|
|
283
|
+
# to use the CALLBACK_ORIENTATION callback and set the period with
|
|
284
|
+
# BrickletIMUV3#set_orientation_callback_configuration.
|
|
285
|
+
def get_orientation
|
|
286
|
+
check_validity
|
|
287
|
+
|
|
288
|
+
send_request FUNCTION_GET_ORIENTATION, [], '', 14, 's s s'
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# Returns the linear acceleration of the IMU Brick for the
|
|
292
|
+
# x, y and z axis. The acceleration is in the range configured with
|
|
293
|
+
# BrickletIMUV3#set_sensor_configuration.
|
|
294
|
+
#
|
|
295
|
+
# The linear acceleration is the acceleration in each of the three
|
|
296
|
+
# axis of the IMU Brick with the influences of gravity removed.
|
|
297
|
+
#
|
|
298
|
+
# It is also possible to get the gravity vector with the influence of linear
|
|
299
|
+
# acceleration removed, see BrickletIMUV3#get_gravity_vector.
|
|
300
|
+
#
|
|
301
|
+
# If you want to get the linear acceleration periodically, it is recommended
|
|
302
|
+
# to use the CALLBACK_LINEAR_ACCELERATION callback and set the period with
|
|
303
|
+
# BrickletIMUV3#set_linear_acceleration_callback_configuration.
|
|
304
|
+
def get_linear_acceleration
|
|
305
|
+
check_validity
|
|
306
|
+
|
|
307
|
+
send_request FUNCTION_GET_LINEAR_ACCELERATION, [], '', 14, 's s s'
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# Returns the current gravity vector of the IMU Brick for the
|
|
311
|
+
# x, y and z axis.
|
|
312
|
+
#
|
|
313
|
+
# The gravity vector is the acceleration that occurs due to gravity.
|
|
314
|
+
# Influences of additional linear acceleration are removed.
|
|
315
|
+
#
|
|
316
|
+
# It is also possible to get the linear acceleration with the influence
|
|
317
|
+
# of gravity removed, see BrickletIMUV3#get_linear_acceleration.
|
|
318
|
+
#
|
|
319
|
+
# If you want to get the gravity vector periodically, it is recommended
|
|
320
|
+
# to use the CALLBACK_GRAVITY_VECTOR callback and set the period with
|
|
321
|
+
# BrickletIMUV3#set_gravity_vector_callback_configuration.
|
|
322
|
+
def get_gravity_vector
|
|
323
|
+
check_validity
|
|
324
|
+
|
|
325
|
+
send_request FUNCTION_GET_GRAVITY_VECTOR, [], '', 14, 's s s'
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
# Returns the current orientation (w, x, y, z) of the IMU Brick as
|
|
329
|
+
# `quaternions <https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation>`__.
|
|
330
|
+
#
|
|
331
|
+
# You have to divide the return values by 16383 (14 bit) to get
|
|
332
|
+
# the usual range of -1.0 to +1.0 for quaternions.
|
|
333
|
+
#
|
|
334
|
+
# If you want to get the quaternions periodically, it is recommended
|
|
335
|
+
# to use the CALLBACK_QUATERNION callback and set the period with
|
|
336
|
+
# BrickletIMUV3#set_quaternion_callback_configuration.
|
|
337
|
+
def get_quaternion
|
|
338
|
+
check_validity
|
|
339
|
+
|
|
340
|
+
send_request FUNCTION_GET_QUATERNION, [], '', 16, 's s s s'
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# Return all of the available data of the IMU Brick.
|
|
344
|
+
#
|
|
345
|
+
# * acceleration (see BrickletIMUV3#get_acceleration)
|
|
346
|
+
# * magnetic field (see BrickletIMUV3#get_magnetic_field)
|
|
347
|
+
# * angular velocity (see BrickletIMUV3#get_angular_velocity)
|
|
348
|
+
# * Euler angles (see BrickletIMUV3#get_orientation)
|
|
349
|
+
# * quaternion (see BrickletIMUV3#get_quaternion)
|
|
350
|
+
# * linear acceleration (see BrickletIMUV3#get_linear_acceleration)
|
|
351
|
+
# * gravity vector (see BrickletIMUV3#get_gravity_vector)
|
|
352
|
+
# * temperature (see BrickletIMUV3#get_temperature)
|
|
353
|
+
# * calibration status (see below)
|
|
354
|
+
#
|
|
355
|
+
# The calibration status consists of four pairs of two bits. Each pair
|
|
356
|
+
# of bits represents the status of the current calibration.
|
|
357
|
+
#
|
|
358
|
+
# * bit 0-1: Magnetometer
|
|
359
|
+
# * bit 2-3: Accelerometer
|
|
360
|
+
# * bit 4-5: Gyroscope
|
|
361
|
+
# * bit 6-7: System
|
|
362
|
+
#
|
|
363
|
+
# A value of 0 means for "not calibrated" and a value of 3 means
|
|
364
|
+
# "fully calibrated". In your program you should always be able to
|
|
365
|
+
# ignore the calibration status, it is used by the calibration
|
|
366
|
+
# window of the Brick Viewer and it can be ignored after the first
|
|
367
|
+
# calibration. See the documentation in the calibration window for
|
|
368
|
+
# more information regarding the calibration of the IMU Brick.
|
|
369
|
+
#
|
|
370
|
+
# If you want to get the data periodically, it is recommended
|
|
371
|
+
# to use the CALLBACK_ALL_DATA callback and set the period with
|
|
372
|
+
# BrickletIMUV3#set_all_data_callback_configuration.
|
|
373
|
+
def get_all_data
|
|
374
|
+
check_validity
|
|
375
|
+
|
|
376
|
+
send_request FUNCTION_GET_ALL_DATA, [], '', 54, 's3 s3 s3 s3 s4 s3 s3 c C'
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# A call of this function saves the current calibration to be used
|
|
380
|
+
# as a starting point for the next restart of continuous calibration
|
|
381
|
+
# of the IMU Brick.
|
|
382
|
+
#
|
|
383
|
+
# A return value of *true* means that the calibration could be used and
|
|
384
|
+
# *false* means that it could not be used (this happens if the calibration
|
|
385
|
+
# status is not "fully calibrated").
|
|
386
|
+
#
|
|
387
|
+
# This function is used by the calibration window of the Brick Viewer, you
|
|
388
|
+
# should not need to call it in your program.
|
|
389
|
+
def save_calibration
|
|
390
|
+
check_validity
|
|
391
|
+
|
|
392
|
+
send_request FUNCTION_SAVE_CALIBRATION, [], '', 9, '?'
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Sets the available sensor configuration for the Magnetometer, Gyroscope and
|
|
396
|
+
# Accelerometer. The Accelerometer Range is user selectable in all fusion modes,
|
|
397
|
+
# all other configurations are auto-controlled in fusion mode.
|
|
398
|
+
def set_sensor_configuration(magnetometer_rate, gyroscope_range, gyroscope_bandwidth, accelerometer_range, accelerometer_bandwidth)
|
|
399
|
+
check_validity
|
|
400
|
+
|
|
401
|
+
send_request FUNCTION_SET_SENSOR_CONFIGURATION, [magnetometer_rate, gyroscope_range, gyroscope_bandwidth, accelerometer_range, accelerometer_bandwidth], 'C C C C C', 8, ''
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
# Returns the sensor configuration as set by BrickletIMUV3#set_sensor_configuration.
|
|
405
|
+
def get_sensor_configuration
|
|
406
|
+
check_validity
|
|
407
|
+
|
|
408
|
+
send_request FUNCTION_GET_SENSOR_CONFIGURATION, [], '', 13, 'C C C C C'
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
# If the fusion mode is turned off, the functions BrickletIMUV3#get_acceleration,
|
|
412
|
+
# BrickletIMUV3#get_magnetic_field and BrickletIMUV3#get_angular_velocity return uncalibrated
|
|
413
|
+
# and uncompensated sensor data. All other sensor data getters return no data.
|
|
414
|
+
#
|
|
415
|
+
# Since firmware version 2.0.6 you can also use a fusion mode without magnetometer.
|
|
416
|
+
# In this mode the calculated orientation is relative (with magnetometer it is
|
|
417
|
+
# absolute with respect to the earth). However, the calculation can't be influenced
|
|
418
|
+
# by spurious magnetic fields.
|
|
419
|
+
#
|
|
420
|
+
# Since firmware version 2.0.13 you can also use a fusion mode without fast
|
|
421
|
+
# magnetometer calibration. This mode is the same as the normal fusion mode,
|
|
422
|
+
# but the fast magnetometer calibration is turned off. So to find the orientation
|
|
423
|
+
# the first time will likely take longer, but small magnetic influences might
|
|
424
|
+
# not affect the automatic calibration as much.
|
|
425
|
+
def set_sensor_fusion_mode(mode)
|
|
426
|
+
check_validity
|
|
427
|
+
|
|
428
|
+
send_request FUNCTION_SET_SENSOR_FUSION_MODE, [mode], 'C', 8, ''
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
# Returns the sensor fusion mode as set by BrickletIMUV3#set_sensor_fusion_mode.
|
|
432
|
+
def get_sensor_fusion_mode
|
|
433
|
+
check_validity
|
|
434
|
+
|
|
435
|
+
send_request FUNCTION_GET_SENSOR_FUSION_MODE, [], '', 9, 'C'
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
# The period is the period with which the CALLBACK_ACCELERATION callback
|
|
439
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
|
440
|
+
#
|
|
441
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
442
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
443
|
+
# period, the callback is triggered immediately on change.
|
|
444
|
+
#
|
|
445
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
446
|
+
# independent of the value.
|
|
447
|
+
def set_acceleration_callback_configuration(period, value_has_to_change)
|
|
448
|
+
check_validity
|
|
449
|
+
|
|
450
|
+
send_request FUNCTION_SET_ACCELERATION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
# Returns the callback configuration as set by BrickletIMUV3#set_acceleration_callback_configuration.
|
|
454
|
+
def get_acceleration_callback_configuration
|
|
455
|
+
check_validity
|
|
456
|
+
|
|
457
|
+
send_request FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
# The period is the period with which the CALLBACK_MAGNETIC_FIELD callback
|
|
461
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
|
462
|
+
#
|
|
463
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
464
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
465
|
+
# period, the callback is triggered immediately on change.
|
|
466
|
+
#
|
|
467
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
468
|
+
# independent of the value.
|
|
469
|
+
def set_magnetic_field_callback_configuration(period, value_has_to_change)
|
|
470
|
+
check_validity
|
|
471
|
+
|
|
472
|
+
send_request FUNCTION_SET_MAGNETIC_FIELD_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
# Returns the callback configuration as set by BrickletIMUV3#set_magnetic_field_callback_configuration.
|
|
476
|
+
def get_magnetic_field_callback_configuration
|
|
477
|
+
check_validity
|
|
478
|
+
|
|
479
|
+
send_request FUNCTION_GET_MAGNETIC_FIELD_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
# The period is the period with which the CALLBACK_ANGULAR_VELOCITY callback
|
|
483
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
|
484
|
+
#
|
|
485
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
486
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
487
|
+
# period, the callback is triggered immediately on change.
|
|
488
|
+
#
|
|
489
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
490
|
+
# independent of the value.
|
|
491
|
+
def set_angular_velocity_callback_configuration(period, value_has_to_change)
|
|
492
|
+
check_validity
|
|
493
|
+
|
|
494
|
+
send_request FUNCTION_SET_ANGULAR_VELOCITY_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
# Returns the callback configuration as set by BrickletIMUV3#set_angular_velocity_callback_configuration.
|
|
498
|
+
def get_angular_velocity_callback_configuration
|
|
499
|
+
check_validity
|
|
500
|
+
|
|
501
|
+
send_request FUNCTION_GET_ANGULAR_VELOCITY_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
# The period is the period with which the CALLBACK_TEMPERATURE callback
|
|
505
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
|
506
|
+
#
|
|
507
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
508
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
509
|
+
# period, the callback is triggered immediately on change.
|
|
510
|
+
#
|
|
511
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
512
|
+
# independent of the value.
|
|
513
|
+
def set_temperature_callback_configuration(period, value_has_to_change)
|
|
514
|
+
check_validity
|
|
515
|
+
|
|
516
|
+
send_request FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
# Returns the callback configuration as set by BrickletIMUV3#set_temperature_callback_configuration.
|
|
520
|
+
def get_temperature_callback_configuration
|
|
521
|
+
check_validity
|
|
522
|
+
|
|
523
|
+
send_request FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
# The period is the period with which the CALLBACK_ORIENTATION callback
|
|
527
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
|
528
|
+
#
|
|
529
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
530
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
531
|
+
# period, the callback is triggered immediately on change.
|
|
532
|
+
#
|
|
533
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
534
|
+
# independent of the value.
|
|
535
|
+
def set_orientation_callback_configuration(period, value_has_to_change)
|
|
536
|
+
check_validity
|
|
537
|
+
|
|
538
|
+
send_request FUNCTION_SET_ORIENTATION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
539
|
+
end
|
|
540
|
+
|
|
541
|
+
# Returns the callback configuration as set by BrickletIMUV3#set_orientation_callback_configuration.
|
|
542
|
+
def get_orientation_callback_configuration
|
|
543
|
+
check_validity
|
|
544
|
+
|
|
545
|
+
send_request FUNCTION_GET_ORIENTATION_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
# The period is the period with which the CALLBACK_LINEAR_ACCELERATION callback
|
|
549
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
|
550
|
+
#
|
|
551
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
552
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
553
|
+
# period, the callback is triggered immediately on change.
|
|
554
|
+
#
|
|
555
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
556
|
+
# independent of the value.
|
|
557
|
+
def set_linear_acceleration_callback_configuration(period, value_has_to_change)
|
|
558
|
+
check_validity
|
|
559
|
+
|
|
560
|
+
send_request FUNCTION_SET_LINEAR_ACCELERATION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
# Returns the callback configuration as set by BrickletIMUV3#set_linear_acceleration_callback_configuration.
|
|
564
|
+
def get_linear_acceleration_callback_configuration
|
|
565
|
+
check_validity
|
|
566
|
+
|
|
567
|
+
send_request FUNCTION_GET_LINEAR_ACCELERATION_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
# The period is the period with which the CALLBACK_GRAVITY_VECTOR callback
|
|
571
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
|
572
|
+
#
|
|
573
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
574
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
575
|
+
# period, the callback is triggered immediately on change.
|
|
576
|
+
#
|
|
577
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
578
|
+
# independent of the value.
|
|
579
|
+
def set_gravity_vector_callback_configuration(period, value_has_to_change)
|
|
580
|
+
check_validity
|
|
581
|
+
|
|
582
|
+
send_request FUNCTION_SET_GRAVITY_VECTOR_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
583
|
+
end
|
|
584
|
+
|
|
585
|
+
# Returns the callback configuration as set by BrickletIMUV3#set_gravity_vector_callback_configuration.
|
|
586
|
+
def get_gravity_vector_callback_configuration
|
|
587
|
+
check_validity
|
|
588
|
+
|
|
589
|
+
send_request FUNCTION_GET_GRAVITY_VECTOR_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
# The period is the period with which the CALLBACK_QUATERNION callback
|
|
593
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
|
594
|
+
#
|
|
595
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
596
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
597
|
+
# period, the callback is triggered immediately on change.
|
|
598
|
+
#
|
|
599
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
600
|
+
# independent of the value.
|
|
601
|
+
def set_quaternion_callback_configuration(period, value_has_to_change)
|
|
602
|
+
check_validity
|
|
603
|
+
|
|
604
|
+
send_request FUNCTION_SET_QUATERNION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
# Returns the callback configuration as set by BrickletIMUV3#set_quaternion_callback_configuration.
|
|
608
|
+
def get_quaternion_callback_configuration
|
|
609
|
+
check_validity
|
|
610
|
+
|
|
611
|
+
send_request FUNCTION_GET_QUATERNION_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
612
|
+
end
|
|
613
|
+
|
|
614
|
+
# The period is the period with which the CALLBACK_ALL_DATA callback
|
|
615
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
|
616
|
+
#
|
|
617
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
618
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
619
|
+
# period, the callback is triggered immediately on change.
|
|
620
|
+
#
|
|
621
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
622
|
+
# independent of the value.
|
|
623
|
+
def set_all_data_callback_configuration(period, value_has_to_change)
|
|
624
|
+
check_validity
|
|
625
|
+
|
|
626
|
+
send_request FUNCTION_SET_ALL_DATA_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
627
|
+
end
|
|
628
|
+
|
|
629
|
+
# Returns the callback configuration as set by BrickletIMUV3#set_all_data_callback_configuration.
|
|
630
|
+
def get_all_data_callback_configuration
|
|
631
|
+
check_validity
|
|
632
|
+
|
|
633
|
+
send_request FUNCTION_GET_ALL_DATA_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
634
|
+
end
|
|
635
|
+
|
|
636
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
637
|
+
#
|
|
638
|
+
# The errors are divided into
|
|
639
|
+
#
|
|
640
|
+
# * ACK checksum errors,
|
|
641
|
+
# * message checksum errors,
|
|
642
|
+
# * framing errors and
|
|
643
|
+
# * overflow errors.
|
|
644
|
+
#
|
|
645
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
646
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
647
|
+
def get_spitfp_error_count
|
|
648
|
+
check_validity
|
|
649
|
+
|
|
650
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
651
|
+
end
|
|
652
|
+
|
|
653
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
654
|
+
# mode change was instigated.
|
|
655
|
+
#
|
|
656
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
657
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
658
|
+
# device identifier and CRC are present and correct.
|
|
659
|
+
#
|
|
660
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
661
|
+
# necessary to call it in a normal user program.
|
|
662
|
+
def set_bootloader_mode(mode)
|
|
663
|
+
check_validity
|
|
664
|
+
|
|
665
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
# Returns the current bootloader mode, see BrickletIMUV3#set_bootloader_mode.
|
|
669
|
+
def get_bootloader_mode
|
|
670
|
+
check_validity
|
|
671
|
+
|
|
672
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
673
|
+
end
|
|
674
|
+
|
|
675
|
+
# Sets the firmware pointer for BrickletIMUV3#write_firmware. The pointer has
|
|
676
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
677
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
678
|
+
#
|
|
679
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
680
|
+
# necessary to call it in a normal user program.
|
|
681
|
+
def set_write_firmware_pointer(pointer)
|
|
682
|
+
check_validity
|
|
683
|
+
|
|
684
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
688
|
+
# BrickletIMUV3#set_write_firmware_pointer before. The firmware is written
|
|
689
|
+
# to flash every 4 chunks.
|
|
690
|
+
#
|
|
691
|
+
# You can only write firmware in bootloader mode.
|
|
692
|
+
#
|
|
693
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
694
|
+
# necessary to call it in a normal user program.
|
|
695
|
+
def write_firmware(data)
|
|
696
|
+
check_validity
|
|
697
|
+
|
|
698
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
699
|
+
end
|
|
700
|
+
|
|
701
|
+
# Sets the status LED configuration. By default the LED shows
|
|
702
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
703
|
+
# for every 10 received data packets.
|
|
704
|
+
#
|
|
705
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
706
|
+
#
|
|
707
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
708
|
+
def set_status_led_config(config)
|
|
709
|
+
check_validity
|
|
710
|
+
|
|
711
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
712
|
+
end
|
|
713
|
+
|
|
714
|
+
# Returns the configuration as set by BrickletIMUV3#set_status_led_config
|
|
715
|
+
def get_status_led_config
|
|
716
|
+
check_validity
|
|
717
|
+
|
|
718
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
719
|
+
end
|
|
720
|
+
|
|
721
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
722
|
+
# value returned is not the ambient temperature!
|
|
723
|
+
#
|
|
724
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
725
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
726
|
+
# temperature changes.
|
|
727
|
+
def get_chip_temperature
|
|
728
|
+
check_validity
|
|
729
|
+
|
|
730
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
734
|
+
# will be lost.
|
|
735
|
+
#
|
|
736
|
+
# After a reset you have to create new device objects,
|
|
737
|
+
# calling functions on the existing ones will result in
|
|
738
|
+
# undefined behavior!
|
|
739
|
+
def reset
|
|
740
|
+
check_validity
|
|
741
|
+
|
|
742
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
743
|
+
end
|
|
744
|
+
|
|
745
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
746
|
+
# you have to decode the Base58 encoded UID string into an
|
|
747
|
+
# integer first.
|
|
748
|
+
#
|
|
749
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
750
|
+
def write_uid(uid)
|
|
751
|
+
check_validity
|
|
752
|
+
|
|
753
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
754
|
+
end
|
|
755
|
+
|
|
756
|
+
# Returns the current UID as an integer. Encode as
|
|
757
|
+
# Base58 to get the usual string version.
|
|
758
|
+
def read_uid
|
|
759
|
+
check_validity
|
|
760
|
+
|
|
761
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
762
|
+
end
|
|
763
|
+
|
|
764
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
765
|
+
# the position, the hardware and firmware version as well as the
|
|
766
|
+
# device identifier.
|
|
767
|
+
#
|
|
768
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
769
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
770
|
+
# position 'z'.
|
|
771
|
+
#
|
|
772
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
773
|
+
# |device_identifier_constant|
|
|
774
|
+
def get_identity
|
|
775
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
776
|
+
end
|
|
777
|
+
|
|
778
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
779
|
+
def register_callback(id, &block)
|
|
780
|
+
callback = block
|
|
781
|
+
@registered_callbacks[id] = callback
|
|
782
|
+
end
|
|
783
|
+
end
|
|
784
|
+
end
|