tinkerforge 2.1.21 → 2.1.22
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 +2 -2
- data/lib/tinkerforge/brick_hat.rb +256 -0
- data/lib/tinkerforge/brick_hat_zero.rb +196 -0
- data/lib/tinkerforge/brick_imu.rb +2 -2
- data/lib/tinkerforge/brick_imu_v2.rb +2 -2
- data/lib/tinkerforge/brick_master.rb +12 -9
- data/lib/tinkerforge/brick_red.rb +2 -2
- data/lib/tinkerforge/brick_servo.rb +2 -2
- data/lib/tinkerforge/brick_silent_stepper.rb +2 -2
- data/lib/tinkerforge/brick_stepper.rb +2 -2
- data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +16 -6
- data/lib/tinkerforge/bricklet_air_quality.rb +59 -3
- data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +3 -3
- data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +2 -2
- data/lib/tinkerforge/bricklet_barometer.rb +2 -2
- data/lib/tinkerforge/bricklet_barometer_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_can.rb +2 -2
- data/lib/tinkerforge/bricklet_can_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_co2.rb +2 -2
- data/lib/tinkerforge/bricklet_co2_v2.rb +479 -0
- data/lib/tinkerforge/bricklet_color.rb +2 -2
- data/lib/tinkerforge/bricklet_current12.rb +2 -2
- data/lib/tinkerforge/bricklet_current25.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +3 -3
- data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
- data/lib/tinkerforge/bricklet_dmx.rb +2 -2
- data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_dual_relay.rb +5 -3
- data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +600 -0
- data/lib/tinkerforge/bricklet_gps.rb +2 -2
- data/lib/tinkerforge/bricklet_gps_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +333 -0
- data/lib/tinkerforge/bricklet_humidity.rb +2 -2
- data/lib/tinkerforge/bricklet_humidity_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_counter.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +3 -3
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +9 -4
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +12 -2
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +6 -3
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +9 -4
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +7 -2
- data/lib/tinkerforge/bricklet_io16.rb +11 -2
- data/lib/tinkerforge/bricklet_io16_v2.rb +10 -2
- data/lib/tinkerforge/bricklet_io4.rb +10 -2
- data/lib/tinkerforge/bricklet_io4_v2.rb +15 -2
- data/lib/tinkerforge/bricklet_isolator.rb +2 -2
- data/lib/tinkerforge/bricklet_joystick.rb +9 -9
- data/lib/tinkerforge/bricklet_joystick_v2.rb +294 -0
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +3 -3
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +447 -0
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
- data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_line.rb +2 -2
- data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +259 -0
- data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_moisture.rb +2 -2
- data/lib/tinkerforge/bricklet_motion_detector.rb +3 -3
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +5 -7
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
- data/lib/tinkerforge/bricklet_nfc.rb +2 -2
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
- data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
- data/lib/tinkerforge/bricklet_one_wire.rb +2 -2
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +14 -2
- data/lib/tinkerforge/bricklet_particulate_matter.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +311 -0
- data/lib/tinkerforge/bricklet_ptc.rb +2 -2
- data/lib/tinkerforge/bricklet_ptc_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +3 -3
- data/lib/tinkerforge/bricklet_rgb_led.rb +4 -4
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +203 -0
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_rs232.rb +2 -2
- data/lib/tinkerforge/bricklet_rs232_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_rs485.rb +2 -2
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +309 -0
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +3 -3
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +3 -3
- data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +5 -2
- data/lib/tinkerforge/bricklet_temperature_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +4 -4
- data/lib/tinkerforge/bricklet_thermocouple.rb +2 -2
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_tilt.rb +2 -2
- data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +2 -2
- data/lib/tinkerforge/ip_connection.rb +21 -4
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -3
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
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
|
+
module Tinkerforge
|
|
13
|
+
# 2-axis joystick with push-button
|
|
14
|
+
class BrickletJoystickV2 < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 2138 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'Joystick Bricklet 2.0' # :nodoc:
|
|
17
|
+
|
|
18
|
+
# This callback is triggered periodically according to the configuration set by
|
|
19
|
+
# BrickletJoystickV2#set_position_callback_configuration.
|
|
20
|
+
#
|
|
21
|
+
# The parameters are the same as with BrickletJoystickV2#get_position.
|
|
22
|
+
CALLBACK_POSITION = 6
|
|
23
|
+
|
|
24
|
+
# This callback is triggered periodically according to the configuration set by
|
|
25
|
+
# BrickletJoystickV2#set_pressed_callback_configuration.
|
|
26
|
+
#
|
|
27
|
+
# The parameters are the same as with BrickletJoystickV2#is_pressed.
|
|
28
|
+
CALLBACK_PRESSED = 9
|
|
29
|
+
|
|
30
|
+
FUNCTION_GET_POSITION = 1 # :nodoc:
|
|
31
|
+
FUNCTION_IS_PRESSED = 2 # :nodoc:
|
|
32
|
+
FUNCTION_CALIBRATE = 3 # :nodoc:
|
|
33
|
+
FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION = 4 # :nodoc:
|
|
34
|
+
FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION = 5 # :nodoc:
|
|
35
|
+
FUNCTION_SET_PRESSED_CALLBACK_CONFIGURATION = 7 # :nodoc:
|
|
36
|
+
FUNCTION_GET_PRESSED_CALLBACK_CONFIGURATION = 8 # :nodoc:
|
|
37
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
38
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
39
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
40
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
41
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
42
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
43
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
44
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
45
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
46
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
47
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
48
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
49
|
+
|
|
50
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
51
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
52
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
53
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
54
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
55
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
56
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
57
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
58
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
59
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
60
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
61
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
62
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
63
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
64
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
65
|
+
|
|
66
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
67
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
68
|
+
def initialize(uid, ipcon)
|
|
69
|
+
super uid, ipcon
|
|
70
|
+
|
|
71
|
+
@api_version = [2, 0, 0]
|
|
72
|
+
|
|
73
|
+
@response_expected[FUNCTION_GET_POSITION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
74
|
+
@response_expected[FUNCTION_IS_PRESSED] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
75
|
+
@response_expected[FUNCTION_CALIBRATE] = RESPONSE_EXPECTED_FALSE
|
|
76
|
+
@response_expected[FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
77
|
+
@response_expected[FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
78
|
+
@response_expected[FUNCTION_SET_PRESSED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
79
|
+
@response_expected[FUNCTION_GET_PRESSED_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
80
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
81
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
82
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
83
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
84
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
85
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
86
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
87
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
88
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
89
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
90
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
91
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
92
|
+
|
|
93
|
+
@callback_formats[CALLBACK_POSITION] = 's s'
|
|
94
|
+
@callback_formats[CALLBACK_PRESSED] = '?'
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Returns the position of the joystick. The value ranges between -100 and
|
|
99
|
+
# 100 for both axis. The middle position of the joystick is x=0, y=0. The
|
|
100
|
+
# returned values are averaged and calibrated (see BrickletJoystickV2#calibrate).
|
|
101
|
+
#
|
|
102
|
+
# If you want to get the position periodically, it is recommended to use the
|
|
103
|
+
# CALLBACK_POSITION callback and set the period with
|
|
104
|
+
# BrickletJoystickV2#set_position_callback_configuration.
|
|
105
|
+
def get_position
|
|
106
|
+
send_request FUNCTION_GET_POSITION, [], '', 4, 's s'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Returns *true* if the button is pressed and *false* otherwise.
|
|
110
|
+
#
|
|
111
|
+
# If you want to get the press-state periodically, it is recommended to use the
|
|
112
|
+
# CALLBACK_PRESSED callback and set the period with
|
|
113
|
+
# BrickletJoystickV2#set_pressed_callback_configuration.
|
|
114
|
+
def is_pressed
|
|
115
|
+
send_request FUNCTION_IS_PRESSED, [], '', 1, '?'
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Calibrates the middle position of the joystick. If your Joystick Bricklet 2.0
|
|
119
|
+
# does not return x=0 and y=0 in the middle position, call this function
|
|
120
|
+
# while the joystick is standing still in the middle position.
|
|
121
|
+
#
|
|
122
|
+
# The resulting calibration will be saved in non-volatile memory,
|
|
123
|
+
# thus you only have to calibrate it once.
|
|
124
|
+
def calibrate
|
|
125
|
+
send_request FUNCTION_CALIBRATE, [], '', 0, ''
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# The period in ms is the period with which the CALLBACK_POSITION
|
|
129
|
+
# callback is triggered periodically. A value of 0 turns the callback off.
|
|
130
|
+
#
|
|
131
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
132
|
+
# triggered after at least one of the values has changed. If the values didn't
|
|
133
|
+
# change within the period, the callback is triggered immediately on change.
|
|
134
|
+
#
|
|
135
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
136
|
+
# independent of the value.
|
|
137
|
+
#
|
|
138
|
+
# The default value is (0, false).
|
|
139
|
+
def set_position_callback_configuration(period, value_has_to_change)
|
|
140
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Returns the callback configuration as set by
|
|
144
|
+
# BrickletJoystickV2#set_position_callback_configuration.
|
|
145
|
+
def get_position_callback_configuration
|
|
146
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# The period in ms is the period with which the CALLBACK_PRESSED
|
|
150
|
+
# callback is triggered periodically. A value of 0 turns the callback off.
|
|
151
|
+
#
|
|
152
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
153
|
+
# triggered after at least one of the values has changed. If the values didn't
|
|
154
|
+
# change within the period, the callback is triggered immediately on change.
|
|
155
|
+
#
|
|
156
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
157
|
+
# independent of the value.
|
|
158
|
+
#
|
|
159
|
+
# The default value is (0, false).
|
|
160
|
+
def set_pressed_callback_configuration(period, value_has_to_change)
|
|
161
|
+
send_request FUNCTION_SET_PRESSED_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Returns the callback configuration as set by
|
|
165
|
+
# BrickletJoystickV2#set_pressed_callback_configuration.
|
|
166
|
+
def get_pressed_callback_configuration
|
|
167
|
+
send_request FUNCTION_GET_PRESSED_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
171
|
+
#
|
|
172
|
+
# The errors are divided into
|
|
173
|
+
#
|
|
174
|
+
# * ACK checksum errors,
|
|
175
|
+
# * message checksum errors,
|
|
176
|
+
# * framing errors and
|
|
177
|
+
# * overflow errors.
|
|
178
|
+
#
|
|
179
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
180
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
181
|
+
def get_spitfp_error_count
|
|
182
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
186
|
+
# mode change was instigated.
|
|
187
|
+
#
|
|
188
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
189
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
190
|
+
# device identifier and CRC are present and correct.
|
|
191
|
+
#
|
|
192
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
193
|
+
# necessary to call it in a normal user program.
|
|
194
|
+
def set_bootloader_mode(mode)
|
|
195
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Returns the current bootloader mode, see BrickletJoystickV2#set_bootloader_mode.
|
|
199
|
+
def get_bootloader_mode
|
|
200
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Sets the firmware pointer for BrickletJoystickV2#write_firmware. The pointer has
|
|
204
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
205
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
206
|
+
#
|
|
207
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
208
|
+
# necessary to call it in a normal user program.
|
|
209
|
+
def set_write_firmware_pointer(pointer)
|
|
210
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
214
|
+
# BrickletJoystickV2#set_write_firmware_pointer before. The firmware is written
|
|
215
|
+
# to flash every 4 chunks.
|
|
216
|
+
#
|
|
217
|
+
# You can only write firmware in bootloader mode.
|
|
218
|
+
#
|
|
219
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
220
|
+
# necessary to call it in a normal user program.
|
|
221
|
+
def write_firmware(data)
|
|
222
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Sets the status LED configuration. By default the LED shows
|
|
226
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
227
|
+
# for every 10 received data packets.
|
|
228
|
+
#
|
|
229
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
230
|
+
#
|
|
231
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
232
|
+
def set_status_led_config(config)
|
|
233
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# Returns the configuration as set by BrickletJoystickV2#set_status_led_config
|
|
237
|
+
def get_status_led_config
|
|
238
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
242
|
+
# value returned is not the ambient temperature!
|
|
243
|
+
#
|
|
244
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
245
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
246
|
+
# temperature changes.
|
|
247
|
+
def get_chip_temperature
|
|
248
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
252
|
+
# will be lost.
|
|
253
|
+
#
|
|
254
|
+
# After a reset you have to create new device objects,
|
|
255
|
+
# calling functions on the existing ones will result in
|
|
256
|
+
# undefined behavior!
|
|
257
|
+
def reset
|
|
258
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
262
|
+
# you have to decode the Base58 encoded UID string into an
|
|
263
|
+
# integer first.
|
|
264
|
+
#
|
|
265
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
266
|
+
def write_uid(uid)
|
|
267
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Returns the current UID as an integer. Encode as
|
|
271
|
+
# Base58 to get the usual string version.
|
|
272
|
+
def read_uid
|
|
273
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
277
|
+
# the position, the hardware and firmware version as well as the
|
|
278
|
+
# device identifier.
|
|
279
|
+
#
|
|
280
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
281
|
+
#
|
|
282
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
283
|
+
# |device_identifier_constant|
|
|
284
|
+
def get_identity
|
|
285
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
289
|
+
def register_callback(id, &block)
|
|
290
|
+
callback = block
|
|
291
|
+
@registered_callbacks[id] = callback
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
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 #
|
|
@@ -329,7 +329,7 @@ module Tinkerforge
|
|
|
329
329
|
# version 3. Use BrickletLaserRangeFinder#set_mode for hardware version 1. You can check
|
|
330
330
|
# the sensor hardware version using BrickletLaserRangeFinder#get_sensor_hardware_version.
|
|
331
331
|
#
|
|
332
|
-
# The **
|
|
332
|
+
# The **Acquisition Count** defines the number of times the Laser Range Finder Bricklet
|
|
333
333
|
# will integrate acquisitions to find a correlation record peak. With a higher count,
|
|
334
334
|
# the Bricklet can measure longer distances. With a lower count, the rate increases. The
|
|
335
335
|
# allowed values are 1-255.
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
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
|
+
module Tinkerforge
|
|
13
|
+
# Measures distance up to 40m with laser light
|
|
14
|
+
class BrickletLaserRangeFinderV2 < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 2144 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'Laser Range Finder Bricklet 2.0' # :nodoc:
|
|
17
|
+
|
|
18
|
+
# This callback is triggered periodically according to the configuration set by
|
|
19
|
+
# BrickletLaserRangeFinderV2#set_distance_callback_configuration.
|
|
20
|
+
#
|
|
21
|
+
# The parameter is the same as BrickletLaserRangeFinderV2#get_distance.
|
|
22
|
+
CALLBACK_DISTANCE = 4
|
|
23
|
+
|
|
24
|
+
# This callback is triggered periodically according to the configuration set by
|
|
25
|
+
# BrickletLaserRangeFinderV2#set_velocity_callback_configuration.
|
|
26
|
+
#
|
|
27
|
+
# The parameter is the same as BrickletLaserRangeFinderV2#get_velocity.
|
|
28
|
+
CALLBACK_VELOCITY = 8
|
|
29
|
+
|
|
30
|
+
FUNCTION_GET_DISTANCE = 1 # :nodoc:
|
|
31
|
+
FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION = 2 # :nodoc:
|
|
32
|
+
FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION = 3 # :nodoc:
|
|
33
|
+
FUNCTION_GET_VELOCITY = 5 # :nodoc:
|
|
34
|
+
FUNCTION_SET_VELOCITY_CALLBACK_CONFIGURATION = 6 # :nodoc:
|
|
35
|
+
FUNCTION_GET_VELOCITY_CALLBACK_CONFIGURATION = 7 # :nodoc:
|
|
36
|
+
FUNCTION_SET_ENABLE = 9 # :nodoc:
|
|
37
|
+
FUNCTION_GET_ENABLE = 10 # :nodoc:
|
|
38
|
+
FUNCTION_SET_CONFIGURATION = 11 # :nodoc:
|
|
39
|
+
FUNCTION_GET_CONFIGURATION = 12 # :nodoc:
|
|
40
|
+
FUNCTION_SET_MOVING_AVERAGE = 13 # :nodoc:
|
|
41
|
+
FUNCTION_GET_MOVING_AVERAGE = 14 # :nodoc:
|
|
42
|
+
FUNCTION_SET_OFFSET_CALIBRATION = 15 # :nodoc:
|
|
43
|
+
FUNCTION_GET_OFFSET_CALIBRATION = 16 # :nodoc:
|
|
44
|
+
FUNCTION_SET_DISTANCE_LED_CONFIG = 17 # :nodoc:
|
|
45
|
+
FUNCTION_GET_DISTANCE_LED_CONFIG = 18 # :nodoc:
|
|
46
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
47
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
48
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
49
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
50
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
51
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
52
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
53
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
54
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
55
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
56
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
57
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
58
|
+
|
|
59
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
|
60
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
|
61
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
|
62
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
|
63
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
|
64
|
+
DISTANCE_LED_CONFIG_OFF = 0 # :nodoc:
|
|
65
|
+
DISTANCE_LED_CONFIG_ON = 1 # :nodoc:
|
|
66
|
+
DISTANCE_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
67
|
+
DISTANCE_LED_CONFIG_SHOW_DISTANCE = 3 # :nodoc:
|
|
68
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
69
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
70
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
71
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
72
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
73
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
74
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
75
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
76
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
77
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
78
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
79
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
80
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
81
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
82
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
83
|
+
|
|
84
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
85
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
86
|
+
def initialize(uid, ipcon)
|
|
87
|
+
super uid, ipcon
|
|
88
|
+
|
|
89
|
+
@api_version = [2, 0, 0]
|
|
90
|
+
|
|
91
|
+
@response_expected[FUNCTION_GET_DISTANCE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
92
|
+
@response_expected[FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
93
|
+
@response_expected[FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
94
|
+
@response_expected[FUNCTION_GET_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
95
|
+
@response_expected[FUNCTION_SET_VELOCITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
96
|
+
@response_expected[FUNCTION_GET_VELOCITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
97
|
+
@response_expected[FUNCTION_SET_ENABLE] = RESPONSE_EXPECTED_FALSE
|
|
98
|
+
@response_expected[FUNCTION_GET_ENABLE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
99
|
+
@response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
|
100
|
+
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
101
|
+
@response_expected[FUNCTION_SET_MOVING_AVERAGE] = RESPONSE_EXPECTED_FALSE
|
|
102
|
+
@response_expected[FUNCTION_GET_MOVING_AVERAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
103
|
+
@response_expected[FUNCTION_SET_OFFSET_CALIBRATION] = RESPONSE_EXPECTED_FALSE
|
|
104
|
+
@response_expected[FUNCTION_GET_OFFSET_CALIBRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
105
|
+
@response_expected[FUNCTION_SET_DISTANCE_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
106
|
+
@response_expected[FUNCTION_GET_DISTANCE_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
107
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
108
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
109
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
110
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
111
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
112
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
113
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
114
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
115
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
116
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
117
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
118
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
119
|
+
|
|
120
|
+
@callback_formats[CALLBACK_DISTANCE] = 's'
|
|
121
|
+
@callback_formats[CALLBACK_VELOCITY] = 's'
|
|
122
|
+
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Returns the measured distance. The value has a range of 0 to 4000
|
|
126
|
+
# and is given in cm.
|
|
127
|
+
#
|
|
128
|
+
# The laser has to be enabled, see BrickletLaserRangeFinderV2#set_enable.
|
|
129
|
+
#
|
|
130
|
+
#
|
|
131
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
132
|
+
# CALLBACK_DISTANCE callback. You can set the callback configuration
|
|
133
|
+
# with BrickletLaserRangeFinderV2#set_distance_callback_configuration.
|
|
134
|
+
def get_distance
|
|
135
|
+
send_request FUNCTION_GET_DISTANCE, [], '', 2, 's'
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# The period in ms is the period with which the CALLBACK_DISTANCE callback is triggered
|
|
139
|
+
# periodically. A value of 0 turns the callback off.
|
|
140
|
+
#
|
|
141
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
142
|
+
# triggered after the value has changed. If the value didn't change
|
|
143
|
+
# within the period, the callback is triggered immediately on change.
|
|
144
|
+
#
|
|
145
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
146
|
+
# independent of the value.
|
|
147
|
+
#
|
|
148
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
|
149
|
+
#
|
|
150
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_DISTANCE callback.
|
|
151
|
+
#
|
|
152
|
+
# The following options are possible:
|
|
153
|
+
#
|
|
154
|
+
# "Option", "Description"
|
|
155
|
+
#
|
|
156
|
+
# "'x'", "Threshold is turned off"
|
|
157
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
|
158
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
|
159
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
|
160
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
161
|
+
#
|
|
162
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
163
|
+
#
|
|
164
|
+
# The default value is (0, false, 'x', 0, 0).
|
|
165
|
+
def set_distance_callback_configuration(period, value_has_to_change, option, min, max)
|
|
166
|
+
send_request FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 0, ''
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Returns the callback configuration as set by BrickletLaserRangeFinderV2#set_distance_callback_configuration.
|
|
170
|
+
def get_distance_callback_configuration
|
|
171
|
+
send_request FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k s s'
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Returns the measured velocity. The value has a range of -12800 to 12700
|
|
175
|
+
# and is given in 1/100 m/s.
|
|
176
|
+
#
|
|
177
|
+
# The velocity measurement only produces stables results if a fixed
|
|
178
|
+
# measurement rate (see BrickletLaserRangeFinderV2#set_configuration) is configured. Also the laser
|
|
179
|
+
# has to be enabled, see BrickletLaserRangeFinderV2#set_enable.
|
|
180
|
+
#
|
|
181
|
+
#
|
|
182
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
183
|
+
# CALLBACK_VELOCITY callback. You can set the callback configuration
|
|
184
|
+
# with BrickletLaserRangeFinderV2#set_velocity_callback_configuration.
|
|
185
|
+
def get_velocity
|
|
186
|
+
send_request FUNCTION_GET_VELOCITY, [], '', 2, 's'
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# The period in ms is the period with which the CALLBACK_VELOCITY callback is triggered
|
|
190
|
+
# periodically. A value of 0 turns the callback off.
|
|
191
|
+
#
|
|
192
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
193
|
+
# triggered after the value has changed. If the value didn't change
|
|
194
|
+
# within the period, the callback is triggered immediately on change.
|
|
195
|
+
#
|
|
196
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
197
|
+
# independent of the value.
|
|
198
|
+
#
|
|
199
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
|
200
|
+
#
|
|
201
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_VELOCITY callback.
|
|
202
|
+
#
|
|
203
|
+
# The following options are possible:
|
|
204
|
+
#
|
|
205
|
+
# "Option", "Description"
|
|
206
|
+
#
|
|
207
|
+
# "'x'", "Threshold is turned off"
|
|
208
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
|
209
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
|
210
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
|
211
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
212
|
+
#
|
|
213
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
214
|
+
#
|
|
215
|
+
# The default value is (0, false, 'x', 0, 0).
|
|
216
|
+
def set_velocity_callback_configuration(period, value_has_to_change, option, min, max)
|
|
217
|
+
send_request FUNCTION_SET_VELOCITY_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 0, ''
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Returns the callback configuration as set by BrickletLaserRangeFinderV2#set_velocity_callback_configuration.
|
|
221
|
+
def get_velocity_callback_configuration
|
|
222
|
+
send_request FUNCTION_GET_VELOCITY_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k s s'
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Enables the laser of the LIDAR if set to *true*.
|
|
226
|
+
#
|
|
227
|
+
# We recommend that you wait 250ms after enabling the laser before
|
|
228
|
+
# the first call of BrickletLaserRangeFinderV2#get_distance to ensure stable measurements.
|
|
229
|
+
def set_enable(enable)
|
|
230
|
+
send_request FUNCTION_SET_ENABLE, [enable], '?', 0, ''
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Returns the value as set by BrickletLaserRangeFinderV2#set_enable.
|
|
234
|
+
def get_enable
|
|
235
|
+
send_request FUNCTION_GET_ENABLE, [], '', 1, '?'
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# The **Acquisition Count** defines the number of times the Laser Range Finder Bricklet
|
|
239
|
+
# will integrate acquisitions to find a correlation record peak. With a higher count,
|
|
240
|
+
# the Bricklet can measure longer distances. With a lower count, the rate increases. The
|
|
241
|
+
# allowed values are 1-255.
|
|
242
|
+
#
|
|
243
|
+
# If you set **Enable Quick Termination** to true, the distance measurement will be terminated
|
|
244
|
+
# early if a high peak was already detected. This means that a higher measurement rate can be achieved
|
|
245
|
+
# and long distances can be measured at the same time. However, the chance of false-positive
|
|
246
|
+
# distance measurements increases.
|
|
247
|
+
#
|
|
248
|
+
# Normally the distance is calculated with a detection algorithm that uses peak value,
|
|
249
|
+
# signal strength and noise. You can however also define a fixed **Threshold Value**.
|
|
250
|
+
# Set this to a low value if you want to measure the distance to something that has
|
|
251
|
+
# very little reflection (e.g. glass) and set it to a high value if you want to measure
|
|
252
|
+
# the distance to something with a very high reflection (e.g. mirror). Set this to 0 to
|
|
253
|
+
# use the default algorithm. The other allowed values are 1-255.
|
|
254
|
+
#
|
|
255
|
+
# Set the **Measurement Frequency** in Hz to force a fixed measurement rate. If set to 0,
|
|
256
|
+
# the Laser Range Finder Bricklet will use the optimal frequency according to the other
|
|
257
|
+
# configurations and the actual measured distance. Since the rate is not fixed in this case,
|
|
258
|
+
# the velocity measurement is not stable. For a stable velocity measurement you should
|
|
259
|
+
# set a fixed measurement frequency. The lower the frequency, the higher is the resolution
|
|
260
|
+
# of the calculated velocity. The allowed values are 10Hz-500Hz (and 0 to turn the fixed
|
|
261
|
+
# frequency off).
|
|
262
|
+
#
|
|
263
|
+
# The default values for Acquisition Count, Enable Quick Termination, Threshold Value and
|
|
264
|
+
# Measurement Frequency are 128, false, 0 and 0.
|
|
265
|
+
def set_configuration(acquisition_count, enable_quick_termination, threshold_value, measurement_frequency)
|
|
266
|
+
send_request FUNCTION_SET_CONFIGURATION, [acquisition_count, enable_quick_termination, threshold_value, measurement_frequency], 'C ? C S', 0, ''
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# Returns the configuration as set by BrickletLaserRangeFinderV2#set_configuration.
|
|
270
|
+
def get_configuration
|
|
271
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 5, 'C ? C S'
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
|
|
275
|
+
# for the distance and velocity.
|
|
276
|
+
#
|
|
277
|
+
# Setting the length to 0 will turn the averaging completely off. With less
|
|
278
|
+
# averaging, there is more noise on the data.
|
|
279
|
+
#
|
|
280
|
+
# The range for the averaging is 0-255.
|
|
281
|
+
#
|
|
282
|
+
# The default value is 10.
|
|
283
|
+
def set_moving_average(distance_average_length, velocity_average_length)
|
|
284
|
+
send_request FUNCTION_SET_MOVING_AVERAGE, [distance_average_length, velocity_average_length], 'C C', 0, ''
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Returns the length moving average as set by BrickletLaserRangeFinderV2#set_moving_average.
|
|
288
|
+
def get_moving_average
|
|
289
|
+
send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 2, 'C C'
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# The offset is given in cm and added to the measured distance.
|
|
293
|
+
# It is saved in non-volatile memory, you only have to set it once.
|
|
294
|
+
#
|
|
295
|
+
# The Bricklet comes with a per-sensor factory-calibrated offset value,
|
|
296
|
+
# you should not have to call this function.
|
|
297
|
+
#
|
|
298
|
+
# If you want to re-calibrate the offset you first have to set it to 0.
|
|
299
|
+
# Calculate the offset by measuring the distance to a known distance
|
|
300
|
+
# and set it again.
|
|
301
|
+
def set_offset_calibration(offset)
|
|
302
|
+
send_request FUNCTION_SET_OFFSET_CALIBRATION, [offset], 's', 0, ''
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
# Returns the offset value as set by BrickletLaserRangeFinderV2#set_offset_calibration.
|
|
306
|
+
def get_offset_calibration
|
|
307
|
+
send_request FUNCTION_GET_OFFSET_CALIBRATION, [], '', 2, 's'
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
# Configures the distance LED to be either turned off, turned on, blink in
|
|
311
|
+
# heartbeat mode or show the distance (brighter = object is nearer).
|
|
312
|
+
#
|
|
313
|
+
# The default value is 3 (show distance).
|
|
314
|
+
def set_distance_led_config(config)
|
|
315
|
+
send_request FUNCTION_SET_DISTANCE_LED_CONFIG, [config], 'C', 0, ''
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
# Returns the LED configuration as set by BrickletLaserRangeFinderV2#set_distance_led_config
|
|
319
|
+
def get_distance_led_config
|
|
320
|
+
send_request FUNCTION_GET_DISTANCE_LED_CONFIG, [], '', 1, 'C'
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
324
|
+
#
|
|
325
|
+
# The errors are divided into
|
|
326
|
+
#
|
|
327
|
+
# * ACK checksum errors,
|
|
328
|
+
# * message checksum errors,
|
|
329
|
+
# * framing errors and
|
|
330
|
+
# * overflow errors.
|
|
331
|
+
#
|
|
332
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
333
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
334
|
+
def get_spitfp_error_count
|
|
335
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
339
|
+
# mode change was instigated.
|
|
340
|
+
#
|
|
341
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
342
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
343
|
+
# device identifier and CRC are present and correct.
|
|
344
|
+
#
|
|
345
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
346
|
+
# necessary to call it in a normal user program.
|
|
347
|
+
def set_bootloader_mode(mode)
|
|
348
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
# Returns the current bootloader mode, see BrickletLaserRangeFinderV2#set_bootloader_mode.
|
|
352
|
+
def get_bootloader_mode
|
|
353
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
# Sets the firmware pointer for BrickletLaserRangeFinderV2#write_firmware. The pointer has
|
|
357
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
358
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
359
|
+
#
|
|
360
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
361
|
+
# necessary to call it in a normal user program.
|
|
362
|
+
def set_write_firmware_pointer(pointer)
|
|
363
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
367
|
+
# BrickletLaserRangeFinderV2#set_write_firmware_pointer before. The firmware is written
|
|
368
|
+
# to flash every 4 chunks.
|
|
369
|
+
#
|
|
370
|
+
# You can only write firmware in bootloader mode.
|
|
371
|
+
#
|
|
372
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
373
|
+
# necessary to call it in a normal user program.
|
|
374
|
+
def write_firmware(data)
|
|
375
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
# Sets the status LED configuration. By default the LED shows
|
|
379
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
380
|
+
# for every 10 received data packets.
|
|
381
|
+
#
|
|
382
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
383
|
+
#
|
|
384
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
385
|
+
def set_status_led_config(config)
|
|
386
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
# Returns the configuration as set by BrickletLaserRangeFinderV2#set_status_led_config
|
|
390
|
+
def get_status_led_config
|
|
391
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
395
|
+
# value returned is not the ambient temperature!
|
|
396
|
+
#
|
|
397
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
398
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
399
|
+
# temperature changes.
|
|
400
|
+
def get_chip_temperature
|
|
401
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
405
|
+
# will be lost.
|
|
406
|
+
#
|
|
407
|
+
# After a reset you have to create new device objects,
|
|
408
|
+
# calling functions on the existing ones will result in
|
|
409
|
+
# undefined behavior!
|
|
410
|
+
def reset
|
|
411
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
415
|
+
# you have to decode the Base58 encoded UID string into an
|
|
416
|
+
# integer first.
|
|
417
|
+
#
|
|
418
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
419
|
+
def write_uid(uid)
|
|
420
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
# Returns the current UID as an integer. Encode as
|
|
424
|
+
# Base58 to get the usual string version.
|
|
425
|
+
def read_uid
|
|
426
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
430
|
+
# the position, the hardware and firmware version as well as the
|
|
431
|
+
# device identifier.
|
|
432
|
+
#
|
|
433
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
434
|
+
#
|
|
435
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
436
|
+
# |device_identifier_constant|
|
|
437
|
+
def get_identity
|
|
438
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
442
|
+
def register_callback(id, &block)
|
|
443
|
+
callback = block
|
|
444
|
+
@registered_callbacks[id] = callback
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
end
|