tinkerforge 2.1.24 → 2.1.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +156 -75
- data/lib/tinkerforge/brick_hat.rb +69 -31
- data/lib/tinkerforge/brick_hat_zero.rb +55 -23
- data/lib/tinkerforge/brick_imu.rb +185 -78
- data/lib/tinkerforge/brick_imu_v2.rb +209 -106
- data/lib/tinkerforge/brick_master.rb +491 -183
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +186 -102
- data/lib/tinkerforge/brick_silent_stepper.rb +247 -167
- data/lib/tinkerforge/brick_stepper.rb +211 -99
- data/lib/tinkerforge/bricklet_accelerometer.rb +57 -23
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +104 -54
- data/lib/tinkerforge/bricklet_air_quality.rb +116 -59
- data/lib/tinkerforge/bricklet_ambient_light.rb +50 -21
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +44 -24
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +65 -27
- data/lib/tinkerforge/bricklet_analog_in.rb +62 -25
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +56 -23
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +66 -25
- data/lib/tinkerforge/bricklet_analog_out.rb +22 -9
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +19 -8
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +53 -20
- data/lib/tinkerforge/bricklet_barometer.rb +100 -27
- data/lib/tinkerforge/bricklet_barometer_v2.rb +98 -37
- data/lib/tinkerforge/bricklet_can.rb +83 -19
- data/lib/tinkerforge/bricklet_can_v2.rb +171 -38
- data/lib/tinkerforge/bricklet_co2.rb +33 -14
- data/lib/tinkerforge/bricklet_co2_v2.rb +97 -38
- data/lib/tinkerforge/bricklet_color.rb +68 -27
- data/lib/tinkerforge/bricklet_color_v2.rb +86 -33
- data/lib/tinkerforge/bricklet_compass.rb +77 -30
- data/lib/tinkerforge/bricklet_current12.rb +57 -24
- data/lib/tinkerforge/bricklet_current25.rb +57 -24
- data/lib/tinkerforge/bricklet_dc_v2.rb +521 -0
- data/lib/tinkerforge/bricklet_distance_ir.rb +56 -23
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +82 -31
- data/lib/tinkerforge/bricklet_distance_us.rb +39 -16
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +66 -25
- data/lib/tinkerforge/bricklet_dmx.rb +87 -34
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -10
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +63 -24
- data/lib/tinkerforge/bricklet_dual_relay.rb +26 -11
- data/lib/tinkerforge/bricklet_dust_detector.rb +39 -16
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +87 -32
- data/lib/tinkerforge/bricklet_energy_monitor.rb +72 -27
- data/lib/tinkerforge/bricklet_gps.rb +63 -26
- data/lib/tinkerforge/bricklet_gps_v2.rb +116 -47
- data/lib/tinkerforge/bricklet_hall_effect.rb +42 -23
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +70 -27
- data/lib/tinkerforge/bricklet_humidity.rb +50 -21
- data/lib/tinkerforge/bricklet_humidity_v2.rb +82 -31
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +37 -14
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +80 -29
- data/lib/tinkerforge/bricklet_industrial_counter.rb +100 -39
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +44 -17
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +76 -29
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +35 -14
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +72 -27
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +39 -16
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -30
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +48 -19
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +137 -31
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +60 -23
- data/lib/tinkerforge/bricklet_industrial_ptc.rb +475 -0
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +35 -14
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +66 -25
- data/lib/tinkerforge/bricklet_io16.rb +54 -21
- data/lib/tinkerforge/bricklet_io16_v2.rb +89 -34
- data/lib/tinkerforge/bricklet_io4.rb +54 -23
- data/lib/tinkerforge/bricklet_io4_v2.rb +95 -36
- data/lib/tinkerforge/bricklet_isolator.rb +72 -29
- data/lib/tinkerforge/bricklet_joystick.rb +58 -25
- data/lib/tinkerforge/bricklet_joystick_v2.rb +67 -26
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +81 -32
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +95 -36
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +191 -70
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +44 -18
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +57 -23
- data/lib/tinkerforge/bricklet_led_strip.rb +59 -22
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +90 -46
- data/lib/tinkerforge/bricklet_line.rb +33 -14
- data/lib/tinkerforge/bricklet_linear_poti.rb +50 -21
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +54 -21
- data/lib/tinkerforge/bricklet_load_cell.rb +60 -23
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +79 -30
- data/lib/tinkerforge/bricklet_moisture.rb +39 -16
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +61 -27
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +70 -27
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -13
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +75 -28
- data/lib/tinkerforge/bricklet_nfc.rb +126 -62
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +28 -11
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +65 -24
- data/lib/tinkerforge/bricklet_oled_64x48.rb +28 -11
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -28
- data/lib/tinkerforge/bricklet_particulate_matter.rb +74 -30
- data/lib/tinkerforge/bricklet_performance_dc.rb +682 -0
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +18 -9
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +21 -10
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +79 -42
- data/lib/tinkerforge/bricklet_ptc.rb +73 -42
- data/lib/tinkerforge/bricklet_ptc_v2.rb +94 -48
- data/lib/tinkerforge/bricklet_real_time_clock.rb +44 -33
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +77 -44
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +38 -19
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +59 -24
- data/lib/tinkerforge/bricklet_rotary_poti.rb +52 -28
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +56 -23
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +117 -44
- data/lib/tinkerforge/bricklet_rs485.rb +222 -95
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +74 -35
- data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
- data/lib/tinkerforge/bricklet_silent_stepper_v2.rb +1024 -0
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +34 -18
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +71 -31
- data/lib/tinkerforge/bricklet_temperature.rb +39 -16
- data/lib/tinkerforge/bricklet_temperature_ir.rb +56 -23
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +70 -27
- data/lib/tinkerforge/bricklet_temperature_v2.rb +60 -25
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +104 -44
- data/lib/tinkerforge/bricklet_thermocouple.rb +44 -24
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +64 -27
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +35 -18
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +84 -37
- data/lib/tinkerforge/bricklet_voltage.rb +51 -28
- data/lib/tinkerforge/bricklet_voltage_current.rb +90 -73
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +89 -68
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +79 -30
- data/lib/tinkerforge/device_display_names.rb +170 -0
- data/lib/tinkerforge/ip_connection.rb +153 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +11 -3
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2021-05-06. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.29 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
|
+
require_relative './ip_connection'
|
13
|
+
|
12
14
|
module Tinkerforge
|
13
15
|
# HAT for Raspberry Pi with 8 Bricklets ports and real-time clock
|
14
16
|
class BrickHAT < Device
|
@@ -62,7 +64,7 @@ module Tinkerforge
|
|
62
64
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
63
65
|
# the IP Connection <tt>ipcon</tt>.
|
64
66
|
def initialize(uid, ipcon)
|
65
|
-
super uid, ipcon
|
67
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
66
68
|
|
67
69
|
@api_version = [2, 0, 1]
|
68
70
|
|
@@ -86,8 +88,9 @@ module Tinkerforge
|
|
86
88
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
87
89
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
88
90
|
|
89
|
-
@callback_formats[CALLBACK_VOLTAGES] = 'S S'
|
91
|
+
@callback_formats[CALLBACK_VOLTAGES] = [12, 'S S']
|
90
92
|
|
93
|
+
@ipcon.add_device self
|
91
94
|
end
|
92
95
|
|
93
96
|
# Sets the sleep mode.
|
@@ -98,8 +101,8 @@ module Tinkerforge
|
|
98
101
|
#
|
99
102
|
# Parameters:
|
100
103
|
#
|
101
|
-
# * Power Off Delay: Time
|
102
|
-
# * Power Off Duration: Duration
|
104
|
+
# * Power Off Delay: Time before the RPi/Bricklets are powered off.
|
105
|
+
# * Power Off Duration: Duration that the RPi/Bricklets stay powered off.
|
103
106
|
# * Raspberry Pi Off: RPi is powered off if set to true.
|
104
107
|
# * Bricklets Off: Bricklets are powered off if set to true.
|
105
108
|
# * Enable Sleep Indicator: If set to true, the status LED will blink in a 1s interval
|
@@ -113,27 +116,33 @@ module Tinkerforge
|
|
113
116
|
# (10, 2, true, false, false). If the RPi crashes or gets stuck
|
114
117
|
# the HAT will reset the RPi after 10 seconds.
|
115
118
|
def set_sleep_mode(power_off_delay, power_off_duration, raspberry_pi_off, bricklets_off, enable_sleep_indicator)
|
116
|
-
|
119
|
+
check_validity
|
120
|
+
|
121
|
+
send_request FUNCTION_SET_SLEEP_MODE, [power_off_delay, power_off_duration, raspberry_pi_off, bricklets_off, enable_sleep_indicator], 'L L ? ? ?', 8, ''
|
117
122
|
end
|
118
123
|
|
119
124
|
# Returns the sleep mode settings as set by BrickHAT#set_sleep_mode.
|
120
125
|
def get_sleep_mode
|
121
|
-
|
126
|
+
check_validity
|
127
|
+
|
128
|
+
send_request FUNCTION_GET_SLEEP_MODE, [], '', 19, 'L L ? ? ?'
|
122
129
|
end
|
123
130
|
|
124
131
|
# Set to true/false to turn the power supply of the connected Bricklets on/off.
|
125
|
-
#
|
126
|
-
# By default the Bricklets are on.
|
127
132
|
def set_bricklet_power(bricklet_power)
|
128
|
-
|
133
|
+
check_validity
|
134
|
+
|
135
|
+
send_request FUNCTION_SET_BRICKLET_POWER, [bricklet_power], '?', 8, ''
|
129
136
|
end
|
130
137
|
|
131
138
|
# Returns the power status of the connected Bricklets as set by BrickHAT#set_bricklet_power.
|
132
139
|
def get_bricklet_power
|
133
|
-
|
140
|
+
check_validity
|
141
|
+
|
142
|
+
send_request FUNCTION_GET_BRICKLET_POWER, [], '', 9, '?'
|
134
143
|
end
|
135
144
|
|
136
|
-
# Returns the USB supply voltage and the DC input supply voltage
|
145
|
+
# Returns the USB supply voltage and the DC input supply voltage.
|
137
146
|
#
|
138
147
|
# There are three possible combinations:
|
139
148
|
#
|
@@ -148,7 +157,9 @@ module Tinkerforge
|
|
148
157
|
# disconnect the DC input (or if the DC input voltage falls below the
|
149
158
|
# USB voltage).
|
150
159
|
def get_voltages
|
151
|
-
|
160
|
+
check_validity
|
161
|
+
|
162
|
+
send_request FUNCTION_GET_VOLTAGES, [], '', 12, 'S S'
|
152
163
|
end
|
153
164
|
|
154
165
|
# The period is the period with which the CALLBACK_VOLTAGES
|
@@ -163,7 +174,9 @@ module Tinkerforge
|
|
163
174
|
#
|
164
175
|
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
165
176
|
def set_voltages_callback_configuration(period, value_has_to_change)
|
166
|
-
|
177
|
+
check_validity
|
178
|
+
|
179
|
+
send_request FUNCTION_SET_VOLTAGES_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
167
180
|
end
|
168
181
|
|
169
182
|
# Returns the callback configuration as set by
|
@@ -171,7 +184,9 @@ module Tinkerforge
|
|
171
184
|
#
|
172
185
|
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
173
186
|
def get_voltages_callback_configuration
|
174
|
-
|
187
|
+
check_validity
|
188
|
+
|
189
|
+
send_request FUNCTION_GET_VOLTAGES_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
175
190
|
end
|
176
191
|
|
177
192
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -186,7 +201,9 @@ module Tinkerforge
|
|
186
201
|
# The errors counts are for errors that occur on the Bricklet side. All
|
187
202
|
# Bricks have a similar function that returns the errors on the Brick side.
|
188
203
|
def get_spitfp_error_count
|
189
|
-
|
204
|
+
check_validity
|
205
|
+
|
206
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
190
207
|
end
|
191
208
|
|
192
209
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -199,12 +216,16 @@ module Tinkerforge
|
|
199
216
|
# This function is used by Brick Viewer during flashing. It should not be
|
200
217
|
# necessary to call it in a normal user program.
|
201
218
|
def set_bootloader_mode(mode)
|
202
|
-
|
219
|
+
check_validity
|
220
|
+
|
221
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
203
222
|
end
|
204
223
|
|
205
224
|
# Returns the current bootloader mode, see BrickHAT#set_bootloader_mode.
|
206
225
|
def get_bootloader_mode
|
207
|
-
|
226
|
+
check_validity
|
227
|
+
|
228
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
208
229
|
end
|
209
230
|
|
210
231
|
# Sets the firmware pointer for BrickHAT#write_firmware. The pointer has
|
@@ -214,7 +235,9 @@ module Tinkerforge
|
|
214
235
|
# This function is used by Brick Viewer during flashing. It should not be
|
215
236
|
# necessary to call it in a normal user program.
|
216
237
|
def set_write_firmware_pointer(pointer)
|
217
|
-
|
238
|
+
check_validity
|
239
|
+
|
240
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
218
241
|
end
|
219
242
|
|
220
243
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -226,7 +249,9 @@ module Tinkerforge
|
|
226
249
|
# This function is used by Brick Viewer during flashing. It should not be
|
227
250
|
# necessary to call it in a normal user program.
|
228
251
|
def write_firmware(data)
|
229
|
-
|
252
|
+
check_validity
|
253
|
+
|
254
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
230
255
|
end
|
231
256
|
|
232
257
|
# Sets the status LED configuration. By default the LED shows
|
@@ -237,22 +262,28 @@ module Tinkerforge
|
|
237
262
|
#
|
238
263
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
239
264
|
def set_status_led_config(config)
|
240
|
-
|
265
|
+
check_validity
|
266
|
+
|
267
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
241
268
|
end
|
242
269
|
|
243
270
|
# Returns the configuration as set by BrickHAT#set_status_led_config
|
244
271
|
def get_status_led_config
|
245
|
-
|
272
|
+
check_validity
|
273
|
+
|
274
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
246
275
|
end
|
247
276
|
|
248
|
-
# Returns the temperature
|
277
|
+
# Returns the temperature as measured inside the microcontroller. The
|
249
278
|
# value returned is not the ambient temperature!
|
250
279
|
#
|
251
280
|
# The temperature is only proportional to the real temperature and it has bad
|
252
281
|
# accuracy. Practically it is only useful as an indicator for
|
253
282
|
# temperature changes.
|
254
283
|
def get_chip_temperature
|
255
|
-
|
284
|
+
check_validity
|
285
|
+
|
286
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
256
287
|
end
|
257
288
|
|
258
289
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -262,7 +293,9 @@ module Tinkerforge
|
|
262
293
|
# calling functions on the existing ones will result in
|
263
294
|
# undefined behavior!
|
264
295
|
def reset
|
265
|
-
|
296
|
+
check_validity
|
297
|
+
|
298
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
266
299
|
end
|
267
300
|
|
268
301
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -271,25 +304,30 @@ module Tinkerforge
|
|
271
304
|
#
|
272
305
|
# We recommend that you use Brick Viewer to change the UID.
|
273
306
|
def write_uid(uid)
|
274
|
-
|
307
|
+
check_validity
|
308
|
+
|
309
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
275
310
|
end
|
276
311
|
|
277
312
|
# Returns the current UID as an integer. Encode as
|
278
313
|
# Base58 to get the usual string version.
|
279
314
|
def read_uid
|
280
|
-
|
315
|
+
check_validity
|
316
|
+
|
317
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
281
318
|
end
|
282
319
|
|
283
|
-
# Returns the UID, the UID where the
|
320
|
+
# Returns the UID, the UID where the HAT is connected to
|
321
|
+
# (typically '0' as the HAT is the root device in the topology),
|
284
322
|
# the position, the hardware and firmware version as well as the
|
285
323
|
# device identifier.
|
286
324
|
#
|
287
|
-
# The
|
325
|
+
# The HAT (Zero) Brick is always at position 'i'.
|
288
326
|
#
|
289
327
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
290
328
|
# |device_identifier_constant|
|
291
329
|
def get_identity
|
292
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
330
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
293
331
|
end
|
294
332
|
|
295
333
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2021-05-06. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.29 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
|
+
require_relative './ip_connection'
|
13
|
+
|
12
14
|
module Tinkerforge
|
13
15
|
# HAT for Raspberry Pi Zero with 4 Bricklets ports
|
14
16
|
class BrickHATZero < Device
|
@@ -63,7 +65,7 @@ module Tinkerforge
|
|
63
65
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
64
66
|
# the IP Connection <tt>ipcon</tt>.
|
65
67
|
def initialize(uid, ipcon)
|
66
|
-
super uid, ipcon
|
68
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
67
69
|
|
68
70
|
@api_version = [2, 0, 1]
|
69
71
|
|
@@ -83,18 +85,21 @@ module Tinkerforge
|
|
83
85
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
84
86
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
85
87
|
|
86
|
-
@callback_formats[CALLBACK_USB_VOLTAGE] = 'S'
|
88
|
+
@callback_formats[CALLBACK_USB_VOLTAGE] = [10, 'S']
|
87
89
|
|
90
|
+
@ipcon.add_device self
|
88
91
|
end
|
89
92
|
|
90
|
-
# Returns the USB supply voltage of the Raspberry Pi
|
93
|
+
# Returns the USB supply voltage of the Raspberry Pi.
|
91
94
|
#
|
92
95
|
#
|
93
96
|
# If you want to get the value periodically, it is recommended to use the
|
94
97
|
# CALLBACK_USB_VOLTAGE callback. You can set the callback configuration
|
95
98
|
# with BrickHATZero#set_usb_voltage_callback_configuration.
|
96
99
|
def get_usb_voltage
|
97
|
-
|
100
|
+
check_validity
|
101
|
+
|
102
|
+
send_request FUNCTION_GET_USB_VOLTAGE, [], '', 10, 'S'
|
98
103
|
end
|
99
104
|
|
100
105
|
# The period is the period with which the CALLBACK_USB_VOLTAGE callback is triggered
|
@@ -125,14 +130,18 @@ module Tinkerforge
|
|
125
130
|
#
|
126
131
|
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
127
132
|
def set_usb_voltage_callback_configuration(period, value_has_to_change, option, min, max)
|
128
|
-
|
133
|
+
check_validity
|
134
|
+
|
135
|
+
send_request FUNCTION_SET_USB_VOLTAGE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 8, ''
|
129
136
|
end
|
130
137
|
|
131
138
|
# Returns the callback configuration as set by BrickHATZero#set_usb_voltage_callback_configuration.
|
132
139
|
#
|
133
140
|
# .. versionadded:: 2.0.1$nbsp;(Firmware)
|
134
141
|
def get_usb_voltage_callback_configuration
|
135
|
-
|
142
|
+
check_validity
|
143
|
+
|
144
|
+
send_request FUNCTION_GET_USB_VOLTAGE_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k S S'
|
136
145
|
end
|
137
146
|
|
138
147
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -147,7 +156,9 @@ module Tinkerforge
|
|
147
156
|
# The errors counts are for errors that occur on the Bricklet side. All
|
148
157
|
# Bricks have a similar function that returns the errors on the Brick side.
|
149
158
|
def get_spitfp_error_count
|
150
|
-
|
159
|
+
check_validity
|
160
|
+
|
161
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
151
162
|
end
|
152
163
|
|
153
164
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -160,12 +171,16 @@ module Tinkerforge
|
|
160
171
|
# This function is used by Brick Viewer during flashing. It should not be
|
161
172
|
# necessary to call it in a normal user program.
|
162
173
|
def set_bootloader_mode(mode)
|
163
|
-
|
174
|
+
check_validity
|
175
|
+
|
176
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
164
177
|
end
|
165
178
|
|
166
179
|
# Returns the current bootloader mode, see BrickHATZero#set_bootloader_mode.
|
167
180
|
def get_bootloader_mode
|
168
|
-
|
181
|
+
check_validity
|
182
|
+
|
183
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
169
184
|
end
|
170
185
|
|
171
186
|
# Sets the firmware pointer for BrickHATZero#write_firmware. The pointer has
|
@@ -175,7 +190,9 @@ module Tinkerforge
|
|
175
190
|
# This function is used by Brick Viewer during flashing. It should not be
|
176
191
|
# necessary to call it in a normal user program.
|
177
192
|
def set_write_firmware_pointer(pointer)
|
178
|
-
|
193
|
+
check_validity
|
194
|
+
|
195
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
179
196
|
end
|
180
197
|
|
181
198
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -187,7 +204,9 @@ module Tinkerforge
|
|
187
204
|
# This function is used by Brick Viewer during flashing. It should not be
|
188
205
|
# necessary to call it in a normal user program.
|
189
206
|
def write_firmware(data)
|
190
|
-
|
207
|
+
check_validity
|
208
|
+
|
209
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
191
210
|
end
|
192
211
|
|
193
212
|
# Sets the status LED configuration. By default the LED shows
|
@@ -198,22 +217,28 @@ module Tinkerforge
|
|
198
217
|
#
|
199
218
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
200
219
|
def set_status_led_config(config)
|
201
|
-
|
220
|
+
check_validity
|
221
|
+
|
222
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
202
223
|
end
|
203
224
|
|
204
225
|
# Returns the configuration as set by BrickHATZero#set_status_led_config
|
205
226
|
def get_status_led_config
|
206
|
-
|
227
|
+
check_validity
|
228
|
+
|
229
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
207
230
|
end
|
208
231
|
|
209
|
-
# Returns the temperature
|
232
|
+
# Returns the temperature as measured inside the microcontroller. The
|
210
233
|
# value returned is not the ambient temperature!
|
211
234
|
#
|
212
235
|
# The temperature is only proportional to the real temperature and it has bad
|
213
236
|
# accuracy. Practically it is only useful as an indicator for
|
214
237
|
# temperature changes.
|
215
238
|
def get_chip_temperature
|
216
|
-
|
239
|
+
check_validity
|
240
|
+
|
241
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
217
242
|
end
|
218
243
|
|
219
244
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -223,7 +248,9 @@ module Tinkerforge
|
|
223
248
|
# calling functions on the existing ones will result in
|
224
249
|
# undefined behavior!
|
225
250
|
def reset
|
226
|
-
|
251
|
+
check_validity
|
252
|
+
|
253
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
227
254
|
end
|
228
255
|
|
229
256
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -232,25 +259,30 @@ module Tinkerforge
|
|
232
259
|
#
|
233
260
|
# We recommend that you use Brick Viewer to change the UID.
|
234
261
|
def write_uid(uid)
|
235
|
-
|
262
|
+
check_validity
|
263
|
+
|
264
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
236
265
|
end
|
237
266
|
|
238
267
|
# Returns the current UID as an integer. Encode as
|
239
268
|
# Base58 to get the usual string version.
|
240
269
|
def read_uid
|
241
|
-
|
270
|
+
check_validity
|
271
|
+
|
272
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
242
273
|
end
|
243
274
|
|
244
|
-
# Returns the UID, the UID where the
|
275
|
+
# Returns the UID, the UID where the HAT is connected to
|
276
|
+
# (typically '0' as the HAT is the root device in the topology),
|
245
277
|
# the position, the hardware and firmware version as well as the
|
246
278
|
# device identifier.
|
247
279
|
#
|
248
|
-
# The
|
280
|
+
# The HAT (Zero) Brick is always at position 'i'.
|
249
281
|
#
|
250
282
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
251
283
|
# |device_identifier_constant|
|
252
284
|
def get_identity
|
253
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
285
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
254
286
|
end
|
255
287
|
|
256
288
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2021-05-06. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.29 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
|
+
require_relative './ip_connection'
|
13
|
+
|
12
14
|
module Tinkerforge
|
13
15
|
# Full fledged AHRS with 9 degrees of freedom
|
14
16
|
class BrickIMU < Device
|
@@ -93,6 +95,8 @@ module Tinkerforge
|
|
93
95
|
FUNCTION_GET_PROTOCOL1_BRICKLET_NAME = 241 # :nodoc:
|
94
96
|
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
95
97
|
FUNCTION_RESET = 243 # :nodoc:
|
98
|
+
FUNCTION_WRITE_BRICKLET_PLUGIN = 246 # :nodoc:
|
99
|
+
FUNCTION_READ_BRICKLET_PLUGIN = 247 # :nodoc:
|
96
100
|
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
97
101
|
|
98
102
|
CALIBRATION_TYPE_ACCELEROMETER_GAIN = 0 # :nodoc:
|
@@ -113,7 +117,7 @@ module Tinkerforge
|
|
113
117
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
114
118
|
# the IP Connection <tt>ipcon</tt>.
|
115
119
|
def initialize(uid, ipcon)
|
116
|
-
super uid, ipcon
|
120
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
117
121
|
|
118
122
|
@api_version = [2, 0, 4]
|
119
123
|
|
@@ -162,35 +166,42 @@ module Tinkerforge
|
|
162
166
|
@response_expected[FUNCTION_GET_PROTOCOL1_BRICKLET_NAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
163
167
|
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
164
168
|
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
169
|
+
@response_expected[FUNCTION_WRITE_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_FALSE
|
170
|
+
@response_expected[FUNCTION_READ_BRICKLET_PLUGIN] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
165
171
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
166
172
|
|
167
|
-
@callback_formats[CALLBACK_ACCELERATION] = 's s s'
|
168
|
-
@callback_formats[CALLBACK_MAGNETIC_FIELD] = 's s s'
|
169
|
-
@callback_formats[CALLBACK_ANGULAR_VELOCITY] = 's s s'
|
170
|
-
@callback_formats[CALLBACK_ALL_DATA] = 's s s s s s s s s s'
|
171
|
-
@callback_formats[CALLBACK_ORIENTATION] = 's s s'
|
172
|
-
@callback_formats[CALLBACK_QUATERNION] = 'e e e e'
|
173
|
+
@callback_formats[CALLBACK_ACCELERATION] = [14, 's s s']
|
174
|
+
@callback_formats[CALLBACK_MAGNETIC_FIELD] = [14, 's s s']
|
175
|
+
@callback_formats[CALLBACK_ANGULAR_VELOCITY] = [14, 's s s']
|
176
|
+
@callback_formats[CALLBACK_ALL_DATA] = [28, 's s s s s s s s s s']
|
177
|
+
@callback_formats[CALLBACK_ORIENTATION] = [14, 's s s']
|
178
|
+
@callback_formats[CALLBACK_QUATERNION] = [24, 'e e e e']
|
173
179
|
|
180
|
+
@ipcon.add_device self
|
174
181
|
end
|
175
182
|
|
176
183
|
# Returns the calibrated acceleration from the accelerometer for the
|
177
|
-
# x, y and z axis
|
184
|
+
# x, y and z axis.
|
178
185
|
#
|
179
186
|
# If you want to get the acceleration periodically, it is recommended
|
180
187
|
# to use the CALLBACK_ACCELERATION callback and set the period with
|
181
188
|
# BrickIMU#set_acceleration_period.
|
182
189
|
def get_acceleration
|
183
|
-
|
190
|
+
check_validity
|
191
|
+
|
192
|
+
send_request FUNCTION_GET_ACCELERATION, [], '', 14, 's s s'
|
184
193
|
end
|
185
194
|
|
186
195
|
# Returns the calibrated magnetic field from the magnetometer for the
|
187
|
-
# x, y and z axis
|
196
|
+
# x, y and z axis.
|
188
197
|
#
|
189
198
|
# If you want to get the magnetic field periodically, it is recommended
|
190
199
|
# to use the CALLBACK_MAGNETIC_FIELD callback and set the period with
|
191
200
|
# BrickIMU#set_magnetic_field_period.
|
192
201
|
def get_magnetic_field
|
193
|
-
|
202
|
+
check_validity
|
203
|
+
|
204
|
+
send_request FUNCTION_GET_MAGNETIC_FIELD, [], '', 14, 's s s'
|
194
205
|
end
|
195
206
|
|
196
207
|
# Returns the calibrated angular velocity from the gyroscope for the
|
@@ -201,23 +212,25 @@ module Tinkerforge
|
|
201
212
|
# to use the CALLBACK_ANGULAR_VELOCITY callback and set the period with
|
202
213
|
# BrickIMU#set_angular_velocity_period.
|
203
214
|
def get_angular_velocity
|
204
|
-
|
215
|
+
check_validity
|
216
|
+
|
217
|
+
send_request FUNCTION_GET_ANGULAR_VELOCITY, [], '', 14, 's s s'
|
205
218
|
end
|
206
219
|
|
207
220
|
# Returns the data from BrickIMU#get_acceleration, BrickIMU#get_magnetic_field
|
208
221
|
# and BrickIMU#get_angular_velocity as well as the temperature of the IMU Brick.
|
209
222
|
#
|
210
|
-
# The temperature is given in °C/100.
|
211
|
-
#
|
212
223
|
# If you want to get the data periodically, it is recommended
|
213
224
|
# to use the CALLBACK_ALL_DATA callback and set the period with
|
214
225
|
# BrickIMU#set_all_data_period.
|
215
226
|
def get_all_data
|
216
|
-
|
227
|
+
check_validity
|
228
|
+
|
229
|
+
send_request FUNCTION_GET_ALL_DATA, [], '', 28, 's s s s s s s s s s'
|
217
230
|
end
|
218
231
|
|
219
232
|
# Returns the current orientation (roll, pitch, yaw) of the IMU Brick as Euler
|
220
|
-
# angles
|
233
|
+
# angles. Note that Euler angles always experience a
|
221
234
|
# `gimbal lock <https://en.wikipedia.org/wiki/Gimbal_lock>`__.
|
222
235
|
#
|
223
236
|
# We recommend that you use quaternions instead.
|
@@ -229,7 +242,9 @@ module Tinkerforge
|
|
229
242
|
# to use the CALLBACK_ORIENTATION callback and set the period with
|
230
243
|
# BrickIMU#set_orientation_period.
|
231
244
|
def get_orientation
|
232
|
-
|
245
|
+
check_validity
|
246
|
+
|
247
|
+
send_request FUNCTION_GET_ORIENTATION, [], '', 14, 's s s'
|
233
248
|
end
|
234
249
|
|
235
250
|
# Returns the current orientation (x, y, z, w) of the IMU as
|
@@ -264,52 +279,69 @@ module Tinkerforge
|
|
264
279
|
# to use the CALLBACK_QUATERNION callback and set the period with
|
265
280
|
# BrickIMU#set_quaternion_period.
|
266
281
|
def get_quaternion
|
267
|
-
|
282
|
+
check_validity
|
283
|
+
|
284
|
+
send_request FUNCTION_GET_QUATERNION, [], '', 24, 'e e e e'
|
268
285
|
end
|
269
286
|
|
270
|
-
# Returns the temperature of the IMU Brick.
|
271
|
-
# °C/100.
|
287
|
+
# Returns the temperature of the IMU Brick.
|
272
288
|
def get_imu_temperature
|
273
|
-
|
289
|
+
check_validity
|
290
|
+
|
291
|
+
send_request FUNCTION_GET_IMU_TEMPERATURE, [], '', 10, 's'
|
274
292
|
end
|
275
293
|
|
276
294
|
# Turns the orientation and direction LEDs of the IMU Brick on.
|
277
295
|
def leds_on
|
278
|
-
|
296
|
+
check_validity
|
297
|
+
|
298
|
+
send_request FUNCTION_LEDS_ON, [], '', 8, ''
|
279
299
|
end
|
280
300
|
|
281
301
|
# Turns the orientation and direction LEDs of the IMU Brick off.
|
282
302
|
def leds_off
|
283
|
-
|
303
|
+
check_validity
|
304
|
+
|
305
|
+
send_request FUNCTION_LEDS_OFF, [], '', 8, ''
|
284
306
|
end
|
285
307
|
|
286
308
|
# Returns *true* if the orientation and direction LEDs of the IMU Brick
|
287
309
|
# are on, *false* otherwise.
|
288
310
|
def are_leds_on
|
289
|
-
|
311
|
+
check_validity
|
312
|
+
|
313
|
+
send_request FUNCTION_ARE_LEDS_ON, [], '', 9, '?'
|
290
314
|
end
|
291
315
|
|
292
316
|
# Not implemented yet.
|
293
317
|
def set_acceleration_range(range)
|
294
|
-
|
318
|
+
check_validity
|
319
|
+
|
320
|
+
send_request FUNCTION_SET_ACCELERATION_RANGE, [range], 'C', 8, ''
|
295
321
|
end
|
296
322
|
|
297
323
|
# Not implemented yet.
|
298
324
|
def get_acceleration_range
|
299
|
-
|
325
|
+
check_validity
|
326
|
+
|
327
|
+
send_request FUNCTION_GET_ACCELERATION_RANGE, [], '', 9, 'C'
|
300
328
|
end
|
301
329
|
|
302
330
|
# Not implemented yet.
|
303
331
|
def set_magnetometer_range(range)
|
304
|
-
|
332
|
+
check_validity
|
333
|
+
|
334
|
+
send_request FUNCTION_SET_MAGNETOMETER_RANGE, [range], 'C', 8, ''
|
305
335
|
end
|
306
336
|
|
307
337
|
# Not implemented yet.
|
308
338
|
def get_magnetometer_range
|
309
|
-
|
339
|
+
check_validity
|
340
|
+
|
341
|
+
send_request FUNCTION_GET_MAGNETOMETER_RANGE, [], '', 9, 'C'
|
310
342
|
end
|
311
343
|
|
312
|
-
# Sets the convergence speed of the IMU Brick
|
344
|
+
# Sets the convergence speed of the IMU Brick. The convergence speed
|
313
345
|
# determines how the different sensor measurements are fused.
|
314
346
|
#
|
315
347
|
# If the orientation of the IMU Brick is off by 10° and the convergence speed is
|
@@ -334,15 +366,17 @@ module Tinkerforge
|
|
334
366
|
#
|
335
367
|
# You might want to play around with the convergence speed in the Brick Viewer to
|
336
368
|
# get a feeling for a good value for your application.
|
337
|
-
#
|
338
|
-
# The default value is 30.
|
339
369
|
def set_convergence_speed(speed)
|
340
|
-
|
370
|
+
check_validity
|
371
|
+
|
372
|
+
send_request FUNCTION_SET_CONVERGENCE_SPEED, [speed], 'S', 8, ''
|
341
373
|
end
|
342
374
|
|
343
375
|
# Returns the convergence speed as set by BrickIMU#set_convergence_speed.
|
344
376
|
def get_convergence_speed
|
345
|
-
|
377
|
+
check_validity
|
378
|
+
|
379
|
+
send_request FUNCTION_GET_CONVERGENCE_SPEED, [], '', 10, 'S'
|
346
380
|
end
|
347
381
|
|
348
382
|
# There are several different types that can be calibrated:
|
@@ -378,78 +412,106 @@ module Tinkerforge
|
|
378
412
|
# We highly recommend that you use the Brick Viewer to calibrate your
|
379
413
|
# IMU Brick.
|
380
414
|
def set_calibration(typ, data)
|
381
|
-
|
415
|
+
check_validity
|
416
|
+
|
417
|
+
send_request FUNCTION_SET_CALIBRATION, [typ, data], 'C s10', 8, ''
|
382
418
|
end
|
383
419
|
|
384
420
|
# Returns the calibration for a given type as set by BrickIMU#set_calibration.
|
385
421
|
def get_calibration(typ)
|
386
|
-
|
422
|
+
check_validity
|
423
|
+
|
424
|
+
send_request FUNCTION_GET_CALIBRATION, [typ], 'C', 28, 's10'
|
387
425
|
end
|
388
426
|
|
389
427
|
# Sets the period with which the CALLBACK_ACCELERATION callback is triggered
|
390
428
|
# periodically. A value of 0 turns the callback off.
|
391
429
|
def set_acceleration_period(period)
|
392
|
-
|
430
|
+
check_validity
|
431
|
+
|
432
|
+
send_request FUNCTION_SET_ACCELERATION_PERIOD, [period], 'L', 8, ''
|
393
433
|
end
|
394
434
|
|
395
435
|
# Returns the period as set by BrickIMU#set_acceleration_period.
|
396
436
|
def get_acceleration_period
|
397
|
-
|
437
|
+
check_validity
|
438
|
+
|
439
|
+
send_request FUNCTION_GET_ACCELERATION_PERIOD, [], '', 12, 'L'
|
398
440
|
end
|
399
441
|
|
400
442
|
# Sets the period with which the CALLBACK_MAGNETIC_FIELD callback is
|
401
443
|
# triggered periodically. A value of 0 turns the callback off.
|
402
444
|
def set_magnetic_field_period(period)
|
403
|
-
|
445
|
+
check_validity
|
446
|
+
|
447
|
+
send_request FUNCTION_SET_MAGNETIC_FIELD_PERIOD, [period], 'L', 8, ''
|
404
448
|
end
|
405
449
|
|
406
450
|
# Returns the period as set by BrickIMU#set_magnetic_field_period.
|
407
451
|
def get_magnetic_field_period
|
408
|
-
|
452
|
+
check_validity
|
453
|
+
|
454
|
+
send_request FUNCTION_GET_MAGNETIC_FIELD_PERIOD, [], '', 12, 'L'
|
409
455
|
end
|
410
456
|
|
411
457
|
# Sets the period with which the CALLBACK_ANGULAR_VELOCITY callback is
|
412
458
|
# triggered periodically. A value of 0 turns the callback off.
|
413
459
|
def set_angular_velocity_period(period)
|
414
|
-
|
460
|
+
check_validity
|
461
|
+
|
462
|
+
send_request FUNCTION_SET_ANGULAR_VELOCITY_PERIOD, [period], 'L', 8, ''
|
415
463
|
end
|
416
464
|
|
417
465
|
# Returns the period as set by BrickIMU#set_angular_velocity_period.
|
418
466
|
def get_angular_velocity_period
|
419
|
-
|
467
|
+
check_validity
|
468
|
+
|
469
|
+
send_request FUNCTION_GET_ANGULAR_VELOCITY_PERIOD, [], '', 12, 'L'
|
420
470
|
end
|
421
471
|
|
422
472
|
# Sets the period with which the CALLBACK_ALL_DATA callback is triggered
|
423
473
|
# periodically. A value of 0 turns the callback off.
|
424
474
|
def set_all_data_period(period)
|
425
|
-
|
475
|
+
check_validity
|
476
|
+
|
477
|
+
send_request FUNCTION_SET_ALL_DATA_PERIOD, [period], 'L', 8, ''
|
426
478
|
end
|
427
479
|
|
428
480
|
# Returns the period as set by BrickIMU#set_all_data_period.
|
429
481
|
def get_all_data_period
|
430
|
-
|
482
|
+
check_validity
|
483
|
+
|
484
|
+
send_request FUNCTION_GET_ALL_DATA_PERIOD, [], '', 12, 'L'
|
431
485
|
end
|
432
486
|
|
433
487
|
# Sets the period with which the CALLBACK_ORIENTATION callback is triggered
|
434
488
|
# periodically. A value of 0 turns the callback off.
|
435
489
|
def set_orientation_period(period)
|
436
|
-
|
490
|
+
check_validity
|
491
|
+
|
492
|
+
send_request FUNCTION_SET_ORIENTATION_PERIOD, [period], 'L', 8, ''
|
437
493
|
end
|
438
494
|
|
439
495
|
# Returns the period as set by BrickIMU#set_orientation_period.
|
440
496
|
def get_orientation_period
|
441
|
-
|
497
|
+
check_validity
|
498
|
+
|
499
|
+
send_request FUNCTION_GET_ORIENTATION_PERIOD, [], '', 12, 'L'
|
442
500
|
end
|
443
501
|
|
444
502
|
# Sets the period with which the CALLBACK_QUATERNION callback is triggered
|
445
503
|
# periodically. A value of 0 turns the callback off.
|
446
504
|
def set_quaternion_period(period)
|
447
|
-
|
505
|
+
check_validity
|
506
|
+
|
507
|
+
send_request FUNCTION_SET_QUATERNION_PERIOD, [period], 'L', 8, ''
|
448
508
|
end
|
449
509
|
|
450
510
|
# Returns the period as set by BrickIMU#set_quaternion_period.
|
451
511
|
def get_quaternion_period
|
452
|
-
|
512
|
+
check_validity
|
513
|
+
|
514
|
+
send_request FUNCTION_GET_QUATERNION_PERIOD, [], '', 12, 'L'
|
453
515
|
end
|
454
516
|
|
455
517
|
# Turns the orientation calculation of the IMU Brick on.
|
@@ -458,7 +520,9 @@ module Tinkerforge
|
|
458
520
|
#
|
459
521
|
# .. versionadded:: 2.0.2$nbsp;(Firmware)
|
460
522
|
def orientation_calculation_on
|
461
|
-
|
523
|
+
check_validity
|
524
|
+
|
525
|
+
send_request FUNCTION_ORIENTATION_CALCULATION_ON, [], '', 8, ''
|
462
526
|
end
|
463
527
|
|
464
528
|
# Turns the orientation calculation of the IMU Brick off.
|
@@ -475,7 +539,9 @@ module Tinkerforge
|
|
475
539
|
#
|
476
540
|
# .. versionadded:: 2.0.2$nbsp;(Firmware)
|
477
541
|
def orientation_calculation_off
|
478
|
-
|
542
|
+
check_validity
|
543
|
+
|
544
|
+
send_request FUNCTION_ORIENTATION_CALCULATION_OFF, [], '', 8, ''
|
479
545
|
end
|
480
546
|
|
481
547
|
# Returns *true* if the orientation calculation of the IMU Brick
|
@@ -483,15 +549,17 @@ module Tinkerforge
|
|
483
549
|
#
|
484
550
|
# .. versionadded:: 2.0.2$nbsp;(Firmware)
|
485
551
|
def is_orientation_calculation_on
|
486
|
-
|
552
|
+
check_validity
|
553
|
+
|
554
|
+
send_request FUNCTION_IS_ORIENTATION_CALCULATION_ON, [], '', 9, '?'
|
487
555
|
end
|
488
556
|
|
489
557
|
# The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is
|
490
558
|
# enabled, the Brick will try to adapt the baudrate for the communication
|
491
559
|
# between Bricks and Bricklets according to the amount of data that is transferred.
|
492
560
|
#
|
493
|
-
# The baudrate will be increased exponentially if lots of data is
|
494
|
-
# decreased linearly if little data is
|
561
|
+
# The baudrate will be increased exponentially if lots of data is sent/received and
|
562
|
+
# decreased linearly if little data is sent/received.
|
495
563
|
#
|
496
564
|
# This lowers the baudrate in applications where little data is transferred (e.g.
|
497
565
|
# a weather station) and increases the robustness. If there is lots of data to transfer
|
@@ -505,20 +573,20 @@ module Tinkerforge
|
|
505
573
|
# BrickIMU#set_spitfp_baudrate. If the dynamic baudrate is disabled, the baudrate
|
506
574
|
# as set by BrickIMU#set_spitfp_baudrate will be used statically.
|
507
575
|
#
|
508
|
-
# The minimum dynamic baudrate has a value range of 400000 to 2000000 baud.
|
509
|
-
#
|
510
|
-
# By default dynamic baudrate is enabled and the minimum dynamic baudrate is 400000.
|
511
|
-
#
|
512
576
|
# .. versionadded:: 2.3.5$nbsp;(Firmware)
|
513
577
|
def set_spitfp_baudrate_config(enable_dynamic_baudrate, minimum_dynamic_baudrate)
|
514
|
-
|
578
|
+
check_validity
|
579
|
+
|
580
|
+
send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 8, ''
|
515
581
|
end
|
516
582
|
|
517
583
|
# Returns the baudrate config, see BrickIMU#set_spitfp_baudrate_config.
|
518
584
|
#
|
519
585
|
# .. versionadded:: 2.3.5$nbsp;(Firmware)
|
520
586
|
def get_spitfp_baudrate_config
|
521
|
-
|
587
|
+
check_validity
|
588
|
+
|
589
|
+
send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 13, '? L'
|
522
590
|
end
|
523
591
|
|
524
592
|
# Returns the timeout count for the different communication methods.
|
@@ -530,11 +598,12 @@ module Tinkerforge
|
|
530
598
|
#
|
531
599
|
# .. versionadded:: 2.3.3$nbsp;(Firmware)
|
532
600
|
def get_send_timeout_count(communication_method)
|
533
|
-
|
601
|
+
check_validity
|
602
|
+
|
603
|
+
send_request FUNCTION_GET_SEND_TIMEOUT_COUNT, [communication_method], 'C', 12, 'L'
|
534
604
|
end
|
535
605
|
|
536
|
-
# Sets the baudrate for a specific Bricklet port
|
537
|
-
# baudrate can be in the range 400000 to 2000000.
|
606
|
+
# Sets the baudrate for a specific Bricklet port.
|
538
607
|
#
|
539
608
|
# If you want to increase the throughput of Bricklets you can increase
|
540
609
|
# the baudrate. If you get a high error count because of high
|
@@ -545,21 +614,23 @@ module Tinkerforge
|
|
545
614
|
# function corresponds to the maximum baudrate (see BrickIMU#set_spitfp_baudrate_config).
|
546
615
|
#
|
547
616
|
# Regulatory testing is done with the default baudrate. If CE compatibility
|
548
|
-
# or similar is necessary in
|
617
|
+
# or similar is necessary in your applications we recommend to not change
|
549
618
|
# the baudrate.
|
550
619
|
#
|
551
|
-
# The default baudrate for all ports is 1400000.
|
552
|
-
#
|
553
620
|
# .. versionadded:: 2.3.3$nbsp;(Firmware)
|
554
621
|
def set_spitfp_baudrate(bricklet_port, baudrate)
|
555
|
-
|
622
|
+
check_validity
|
623
|
+
|
624
|
+
send_request FUNCTION_SET_SPITFP_BAUDRATE, [bricklet_port, baudrate], 'k L', 8, ''
|
556
625
|
end
|
557
626
|
|
558
627
|
# Returns the baudrate for a given Bricklet port, see BrickIMU#set_spitfp_baudrate.
|
559
628
|
#
|
560
629
|
# .. versionadded:: 2.3.3$nbsp;(Firmware)
|
561
630
|
def get_spitfp_baudrate(bricklet_port)
|
562
|
-
|
631
|
+
check_validity
|
632
|
+
|
633
|
+
send_request FUNCTION_GET_SPITFP_BAUDRATE, [bricklet_port], 'k', 12, 'L'
|
563
634
|
end
|
564
635
|
|
565
636
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -576,7 +647,9 @@ module Tinkerforge
|
|
576
647
|
#
|
577
648
|
# .. versionadded:: 2.3.3$nbsp;(Firmware)
|
578
649
|
def get_spitfp_error_count(bricklet_port)
|
579
|
-
|
650
|
+
check_validity
|
651
|
+
|
652
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [bricklet_port], 'k', 24, 'L L L L'
|
580
653
|
end
|
581
654
|
|
582
655
|
# Enables the status LED.
|
@@ -588,7 +661,9 @@ module Tinkerforge
|
|
588
661
|
#
|
589
662
|
# .. versionadded:: 2.3.1$nbsp;(Firmware)
|
590
663
|
def enable_status_led
|
591
|
-
|
664
|
+
check_validity
|
665
|
+
|
666
|
+
send_request FUNCTION_ENABLE_STATUS_LED, [], '', 8, ''
|
592
667
|
end
|
593
668
|
|
594
669
|
# Disables the status LED.
|
@@ -600,14 +675,18 @@ module Tinkerforge
|
|
600
675
|
#
|
601
676
|
# .. versionadded:: 2.3.1$nbsp;(Firmware)
|
602
677
|
def disable_status_led
|
603
|
-
|
678
|
+
check_validity
|
679
|
+
|
680
|
+
send_request FUNCTION_DISABLE_STATUS_LED, [], '', 8, ''
|
604
681
|
end
|
605
682
|
|
606
683
|
# Returns *true* if the status LED is enabled, *false* otherwise.
|
607
684
|
#
|
608
685
|
# .. versionadded:: 2.3.1$nbsp;(Firmware)
|
609
686
|
def is_status_led_enabled
|
610
|
-
|
687
|
+
check_validity
|
688
|
+
|
689
|
+
send_request FUNCTION_IS_STATUS_LED_ENABLED, [], '', 9, '?'
|
611
690
|
end
|
612
691
|
|
613
692
|
# Returns the firmware and protocol version and the name of the Bricklet for a
|
@@ -616,17 +695,21 @@ module Tinkerforge
|
|
616
695
|
# This functions sole purpose is to allow automatic flashing of v1.x.y Bricklet
|
617
696
|
# plugins.
|
618
697
|
def get_protocol1_bricklet_name(port)
|
619
|
-
|
698
|
+
check_validity
|
699
|
+
|
700
|
+
send_request FUNCTION_GET_PROTOCOL1_BRICKLET_NAME, [port], 'k', 52, 'C C3 Z40'
|
620
701
|
end
|
621
702
|
|
622
|
-
# Returns the temperature
|
703
|
+
# Returns the temperature as measured inside the microcontroller. The
|
623
704
|
# value returned is not the ambient temperature!
|
624
705
|
#
|
625
706
|
# The temperature is only proportional to the real temperature and it has an
|
626
707
|
# accuracy of ±15%. Practically it is only useful as an indicator for
|
627
708
|
# temperature changes.
|
628
709
|
def get_chip_temperature
|
629
|
-
|
710
|
+
check_validity
|
711
|
+
|
712
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
630
713
|
end
|
631
714
|
|
632
715
|
# Calling this function will reset the Brick. Calling this function
|
@@ -636,19 +719,43 @@ module Tinkerforge
|
|
636
719
|
# calling functions on the existing ones will result in
|
637
720
|
# undefined behavior!
|
638
721
|
def reset
|
639
|
-
|
722
|
+
check_validity
|
723
|
+
|
724
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
725
|
+
end
|
726
|
+
|
727
|
+
# Writes 32 bytes of firmware to the bricklet attached at the given port.
|
728
|
+
# The bytes are written to the position offset * 32.
|
729
|
+
#
|
730
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
731
|
+
# necessary to call it in a normal user program.
|
732
|
+
def write_bricklet_plugin(port, offset, chunk)
|
733
|
+
check_validity
|
734
|
+
|
735
|
+
send_request FUNCTION_WRITE_BRICKLET_PLUGIN, [port, offset, chunk], 'k C C32', 8, ''
|
736
|
+
end
|
737
|
+
|
738
|
+
# Reads 32 bytes of firmware from the bricklet attached at the given port.
|
739
|
+
# The bytes are read starting at the position offset * 32.
|
740
|
+
#
|
741
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
742
|
+
# necessary to call it in a normal user program.
|
743
|
+
def read_bricklet_plugin(port, offset)
|
744
|
+
check_validity
|
745
|
+
|
746
|
+
send_request FUNCTION_READ_BRICKLET_PLUGIN, [port, offset], 'k C', 40, 'C32'
|
640
747
|
end
|
641
748
|
|
642
749
|
# Returns the UID, the UID where the Brick is connected to,
|
643
750
|
# the position, the hardware and firmware version as well as the
|
644
751
|
# device identifier.
|
645
752
|
#
|
646
|
-
# The position
|
753
|
+
# The position is the position in the stack from '0' (bottom) to '8' (top).
|
647
754
|
#
|
648
755
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
649
756
|
# |device_identifier_constant|
|
650
757
|
def get_identity
|
651
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
758
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
652
759
|
end
|
653
760
|
|
654
761
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|