tinkerforge 2.1.22 → 2.1.23
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 +4 -4
- data/lib/tinkerforge/brick_dc.rb +3 -3
- data/lib/tinkerforge/brick_hat.rb +11 -7
- data/lib/tinkerforge/brick_hat_zero.rb +2 -2
- data/lib/tinkerforge/brick_imu.rb +3 -3
- data/lib/tinkerforge/brick_imu_v2.rb +3 -3
- data/lib/tinkerforge/brick_master.rb +5 -5
- data/lib/tinkerforge/brick_red.rb +2 -2
- data/lib/tinkerforge/brick_servo.rb +3 -3
- data/lib/tinkerforge/brick_silent_stepper.rb +3 -3
- data/lib/tinkerforge/brick_stepper.rb +4 -4
- data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +81 -6
- data/lib/tinkerforge/bricklet_air_quality.rb +2 -2
- 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 +2 -2
- 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 +2 -2
- data/lib/tinkerforge/bricklet_color.rb +4 -4
- data/lib/tinkerforge/bricklet_color_v2.rb +449 -0
- data/lib/tinkerforge/bricklet_compass.rb +356 -0
- 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 +2 -2
- data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +300 -0
- 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 +2 -2
- data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +2 -2
- data/lib/tinkerforge/bricklet_energy_monitor.rb +375 -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 +2 -2
- 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 +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +2 -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 +2 -2
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_io16.rb +2 -2
- data/lib/tinkerforge/bricklet_io16_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_io4.rb +2 -2
- data/lib/tinkerforge/bricklet_io4_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_isolator.rb +2 -2
- data/lib/tinkerforge/bricklet_joystick.rb +2 -2
- data/lib/tinkerforge/bricklet_joystick_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +5 -5
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +24 -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 +2 -2
- 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 +2 -2
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +334 -0
- 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 +24 -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 +2 -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 +2 -2
- 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 +2 -2
- data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
- 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 +2 -2
- 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_rotary_poti_v2.rb +259 -0
- data/lib/tinkerforge/bricklet_rs232.rb +2 -2
- data/lib/tinkerforge/bricklet_rs232_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_rs485.rb +70 -60
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +2 -2
- 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 +5 -3
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +3 -11
- data/lib/tinkerforge/bricklet_temperature_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +2 -2
- 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 +13 -2
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +365 -0
- data/lib/tinkerforge/ip_connection.rb +1 -1
- data/lib/tinkerforge/version.rb +1 -1
- metadata +10 -3
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2019-08-23. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.23 #
|
|
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
|
+
# 3-axis compass with 0.1mG (milli Gauss) and 0.1° resolution
|
|
14
|
+
class BrickletCompass < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 2153 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'Compass Bricklet' # :nodoc:
|
|
17
|
+
|
|
18
|
+
# This callback is triggered periodically according to the configuration set by
|
|
19
|
+
# BrickletCompass#set_heading_callback_configuration.
|
|
20
|
+
#
|
|
21
|
+
# The parameter is the same as BrickletCompass#get_heading.
|
|
22
|
+
CALLBACK_HEADING = 4
|
|
23
|
+
|
|
24
|
+
# This callback is triggered periodically according to the configuration set by
|
|
25
|
+
# BrickletCompass#set_magnetic_flux_density_callback_configuration.
|
|
26
|
+
#
|
|
27
|
+
# The parameters are the same as BrickletCompass#get_magnetic_flux_density.
|
|
28
|
+
CALLBACK_MAGNETIC_FLUX_DENSITY = 8
|
|
29
|
+
|
|
30
|
+
FUNCTION_GET_HEADING = 1 # :nodoc:
|
|
31
|
+
FUNCTION_SET_HEADING_CALLBACK_CONFIGURATION = 2 # :nodoc:
|
|
32
|
+
FUNCTION_GET_HEADING_CALLBACK_CONFIGURATION = 3 # :nodoc:
|
|
33
|
+
FUNCTION_GET_MAGNETIC_FLUX_DENSITY = 5 # :nodoc:
|
|
34
|
+
FUNCTION_SET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION = 6 # :nodoc:
|
|
35
|
+
FUNCTION_GET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION = 7 # :nodoc:
|
|
36
|
+
FUNCTION_SET_CONFIGURATION = 9 # :nodoc:
|
|
37
|
+
FUNCTION_GET_CONFIGURATION = 10 # :nodoc:
|
|
38
|
+
FUNCTION_SET_CALIBRATION = 11 # :nodoc:
|
|
39
|
+
FUNCTION_GET_CALIBRATION = 12 # :nodoc:
|
|
40
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
41
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
42
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
43
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
44
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
45
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
46
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
47
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
48
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
49
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
50
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
51
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
52
|
+
|
|
53
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
|
54
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
|
55
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
|
56
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
|
57
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
|
58
|
+
DATA_RATE_100HZ = 0 # :nodoc:
|
|
59
|
+
DATA_RATE_200HZ = 1 # :nodoc:
|
|
60
|
+
DATA_RATE_400HZ = 2 # :nodoc:
|
|
61
|
+
DATA_RATE_600HZ = 3 # :nodoc:
|
|
62
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
63
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
64
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
65
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
66
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
67
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
68
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
69
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
70
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
71
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
72
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
73
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
74
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
75
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
76
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
77
|
+
|
|
78
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
79
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
80
|
+
def initialize(uid, ipcon)
|
|
81
|
+
super uid, ipcon
|
|
82
|
+
|
|
83
|
+
@api_version = [2, 0, 0]
|
|
84
|
+
|
|
85
|
+
@response_expected[FUNCTION_GET_HEADING] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
86
|
+
@response_expected[FUNCTION_SET_HEADING_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
87
|
+
@response_expected[FUNCTION_GET_HEADING_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
88
|
+
@response_expected[FUNCTION_GET_MAGNETIC_FLUX_DENSITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
89
|
+
@response_expected[FUNCTION_SET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
90
|
+
@response_expected[FUNCTION_GET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
91
|
+
@response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
|
92
|
+
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
93
|
+
@response_expected[FUNCTION_SET_CALIBRATION] = RESPONSE_EXPECTED_FALSE
|
|
94
|
+
@response_expected[FUNCTION_GET_CALIBRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
95
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
96
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
97
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
98
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
99
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
100
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
101
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
102
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
103
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
104
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
105
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
106
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
107
|
+
|
|
108
|
+
@callback_formats[CALLBACK_HEADING] = 's'
|
|
109
|
+
@callback_formats[CALLBACK_MAGNETIC_FLUX_DENSITY] = 'l l l'
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Returns the heading in 1/10 degree (north = 0 degree, east = 90 degree).
|
|
114
|
+
#
|
|
115
|
+
# Alternatively you can use BrickletCompass#get_magnetic_flux_density and calculate the
|
|
116
|
+
# heading with ``heading = atan2(y, x) * 180 / PI``.
|
|
117
|
+
#
|
|
118
|
+
#
|
|
119
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
120
|
+
# CALLBACK_HEADING callback. You can set the callback configuration
|
|
121
|
+
# with BrickletCompass#set_heading_callback_configuration.
|
|
122
|
+
def get_heading
|
|
123
|
+
send_request FUNCTION_GET_HEADING, [], '', 2, 's'
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# The period in ms is the period with which the CALLBACK_HEADING callback is triggered
|
|
127
|
+
# periodically. A value of 0 turns the callback off.
|
|
128
|
+
#
|
|
129
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
130
|
+
# triggered after the value has changed. If the value didn't change
|
|
131
|
+
# within the period, the callback is triggered immediately on change.
|
|
132
|
+
#
|
|
133
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
134
|
+
# independent of the value.
|
|
135
|
+
#
|
|
136
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
|
137
|
+
#
|
|
138
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_HEADING callback.
|
|
139
|
+
#
|
|
140
|
+
# The following options are possible:
|
|
141
|
+
#
|
|
142
|
+
# "Option", "Description"
|
|
143
|
+
#
|
|
144
|
+
# "'x'", "Threshold is turned off"
|
|
145
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
|
146
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
|
147
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
|
148
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
149
|
+
#
|
|
150
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
151
|
+
#
|
|
152
|
+
# The default value is (0, false, 'x', 0, 0).
|
|
153
|
+
def set_heading_callback_configuration(period, value_has_to_change, option, min, max)
|
|
154
|
+
send_request FUNCTION_SET_HEADING_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 0, ''
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Returns the callback configuration as set by BrickletCompass#set_heading_callback_configuration.
|
|
158
|
+
def get_heading_callback_configuration
|
|
159
|
+
send_request FUNCTION_GET_HEADING_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k s s'
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Returns the `magnetic flux density (magnetic induction) <https://en.wikipedia.org/wiki/Magnetic_flux>`__
|
|
163
|
+
# for all three axis in 1/10 `mG (milli Gauss) <https://en.wikipedia.org/wiki/Gauss_(unit)>`__.
|
|
164
|
+
#
|
|
165
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
166
|
+
# CALLBACK_MAGNETIC_FLUX_DENSITY callback. You can set the callback configuration
|
|
167
|
+
# with BrickletCompass#set_magnetic_flux_density_callback_configuration.
|
|
168
|
+
def get_magnetic_flux_density
|
|
169
|
+
send_request FUNCTION_GET_MAGNETIC_FLUX_DENSITY, [], '', 12, 'l l l'
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# The period in ms is the period with which the CALLBACK_MAGNETIC_FLUX_DENSITY callback
|
|
173
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
|
174
|
+
#
|
|
175
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
176
|
+
# triggered after the value has changed. If the value didn't change within the
|
|
177
|
+
# period, the callback is triggered immediately on change.
|
|
178
|
+
#
|
|
179
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
180
|
+
# independent of the value.
|
|
181
|
+
#
|
|
182
|
+
# The default value is (0, false).
|
|
183
|
+
def set_magnetic_flux_density_callback_configuration(period, value_has_to_change)
|
|
184
|
+
send_request FUNCTION_SET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 0, ''
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Returns the callback configuration as set by
|
|
188
|
+
# BrickletCompass#set_magnetic_flux_density_callback_configuration.
|
|
189
|
+
def get_magnetic_flux_density_callback_configuration
|
|
190
|
+
send_request FUNCTION_GET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION, [], '', 5, 'L ?'
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Configures the data rate and background calibration.
|
|
194
|
+
#
|
|
195
|
+
# * Data Rate: Sets the data rate that is used by the magnetometer.
|
|
196
|
+
# The lower the data rate, the lower is the noise on the data.
|
|
197
|
+
# * Background Calibration: Set to *true* to enable the background
|
|
198
|
+
# calibration and *false* to turn it off. If the background calibration
|
|
199
|
+
# is enabled the sensing polarity is flipped once per second to automatically
|
|
200
|
+
# calculate and remove offset that is caused by temperature changes.
|
|
201
|
+
# This polarity flipping takes about 20ms. This means that once a second
|
|
202
|
+
# you will not get new data for a period of 20ms. We highly recommend that
|
|
203
|
+
# you keep the background calibration enabled and only disable it if the 20ms
|
|
204
|
+
# off-time is a problem in your application.
|
|
205
|
+
#
|
|
206
|
+
# Default values: Data rate of 100Hz and background calibration enabled.
|
|
207
|
+
def set_configuration(data_rate, background_calibration)
|
|
208
|
+
send_request FUNCTION_SET_CONFIGURATION, [data_rate, background_calibration], 'C ?', 0, ''
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Returns the configuration as set by BrickletCompass#set_configuration.
|
|
212
|
+
def get_configuration
|
|
213
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 2, 'C ?'
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Sets offset and gain for each of the three axes.
|
|
217
|
+
#
|
|
218
|
+
# The Bricklet is factory calibrated. If you want to re-calibrate the
|
|
219
|
+
# Bricklet we recommend that you do the calibration through Brick Viewer.
|
|
220
|
+
#
|
|
221
|
+
# The calibration is saved in non-volatile memory and only has to be
|
|
222
|
+
# done once.
|
|
223
|
+
def set_calibration(offset, gain)
|
|
224
|
+
send_request FUNCTION_SET_CALIBRATION, [offset, gain], 's3 s3', 0, ''
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# Returns the calibration parameters as set by BrickletCompass#set_calibration.
|
|
228
|
+
def get_calibration
|
|
229
|
+
send_request FUNCTION_GET_CALIBRATION, [], '', 12, 's3 s3'
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
233
|
+
#
|
|
234
|
+
# The errors are divided into
|
|
235
|
+
#
|
|
236
|
+
# * ACK checksum errors,
|
|
237
|
+
# * message checksum errors,
|
|
238
|
+
# * framing errors and
|
|
239
|
+
# * overflow errors.
|
|
240
|
+
#
|
|
241
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
242
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
243
|
+
def get_spitfp_error_count
|
|
244
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
248
|
+
# mode change was instigated.
|
|
249
|
+
#
|
|
250
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
251
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
252
|
+
# device identifier and CRC are present and correct.
|
|
253
|
+
#
|
|
254
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
255
|
+
# necessary to call it in a normal user program.
|
|
256
|
+
def set_bootloader_mode(mode)
|
|
257
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
# Returns the current bootloader mode, see BrickletCompass#set_bootloader_mode.
|
|
261
|
+
def get_bootloader_mode
|
|
262
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# Sets the firmware pointer for BrickletCompass#write_firmware. The pointer has
|
|
266
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
267
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
268
|
+
#
|
|
269
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
270
|
+
# necessary to call it in a normal user program.
|
|
271
|
+
def set_write_firmware_pointer(pointer)
|
|
272
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
276
|
+
# BrickletCompass#set_write_firmware_pointer before. The firmware is written
|
|
277
|
+
# to flash every 4 chunks.
|
|
278
|
+
#
|
|
279
|
+
# You can only write firmware in bootloader mode.
|
|
280
|
+
#
|
|
281
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
282
|
+
# necessary to call it in a normal user program.
|
|
283
|
+
def write_firmware(data)
|
|
284
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Sets the status LED configuration. By default the LED shows
|
|
288
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
289
|
+
# for every 10 received data packets.
|
|
290
|
+
#
|
|
291
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
292
|
+
#
|
|
293
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
294
|
+
def set_status_led_config(config)
|
|
295
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# Returns the configuration as set by BrickletCompass#set_status_led_config
|
|
299
|
+
def get_status_led_config
|
|
300
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
304
|
+
# value returned is not the ambient temperature!
|
|
305
|
+
#
|
|
306
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
307
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
308
|
+
# temperature changes.
|
|
309
|
+
def get_chip_temperature
|
|
310
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
314
|
+
# will be lost.
|
|
315
|
+
#
|
|
316
|
+
# After a reset you have to create new device objects,
|
|
317
|
+
# calling functions on the existing ones will result in
|
|
318
|
+
# undefined behavior!
|
|
319
|
+
def reset
|
|
320
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
324
|
+
# you have to decode the Base58 encoded UID string into an
|
|
325
|
+
# integer first.
|
|
326
|
+
#
|
|
327
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
328
|
+
def write_uid(uid)
|
|
329
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
# Returns the current UID as an integer. Encode as
|
|
333
|
+
# Base58 to get the usual string version.
|
|
334
|
+
def read_uid
|
|
335
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
339
|
+
# the position, the hardware and firmware version as well as the
|
|
340
|
+
# device identifier.
|
|
341
|
+
#
|
|
342
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
343
|
+
#
|
|
344
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
345
|
+
# |device_identifier_constant|
|
|
346
|
+
def get_identity
|
|
347
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
351
|
+
def register_callback(id, &block)
|
|
352
|
+
callback = block
|
|
353
|
+
@registered_callbacks[id] = callback
|
|
354
|
+
end
|
|
355
|
+
end
|
|
356
|
+
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-08-23. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.23 #
|
|
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 #
|
|
@@ -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-08-23. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.23 #
|
|
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 #
|
|
@@ -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-08-23. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.23 #
|
|
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 #
|
|
@@ -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-08-23. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.23 #
|
|
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 #
|
|
@@ -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-08-23. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.23 #
|
|
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 #
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2019-08-23. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.23 #
|
|
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 between 30cm and 500cm with ultrasound
|
|
14
|
+
class BrickletDistanceUSV2 < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 299 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'Distance US Bricklet 2.0' # :nodoc:
|
|
17
|
+
|
|
18
|
+
# This callback is triggered periodically according to the configuration set by
|
|
19
|
+
# BrickletDistanceUSV2#set_distance_callback_configuration.
|
|
20
|
+
#
|
|
21
|
+
# The parameter is the same as BrickletDistanceUSV2#get_distance.
|
|
22
|
+
CALLBACK_DISTANCE = 4
|
|
23
|
+
|
|
24
|
+
FUNCTION_GET_DISTANCE = 1 # :nodoc:
|
|
25
|
+
FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION = 2 # :nodoc:
|
|
26
|
+
FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION = 3 # :nodoc:
|
|
27
|
+
FUNCTION_SET_UPDATE_RATE = 5 # :nodoc:
|
|
28
|
+
FUNCTION_GET_UPDATE_RATE = 6 # :nodoc:
|
|
29
|
+
FUNCTION_SET_DISTANCE_LED_CONFIG = 7 # :nodoc:
|
|
30
|
+
FUNCTION_GET_DISTANCE_LED_CONFIG = 8 # :nodoc:
|
|
31
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
32
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
33
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
34
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
35
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
36
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
37
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
38
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
39
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
40
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
41
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
42
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
43
|
+
|
|
44
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
|
45
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
|
46
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
|
47
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
|
48
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
|
49
|
+
UPDATE_RATE_2_HZ = 0 # :nodoc:
|
|
50
|
+
UPDATE_RATE_10_HZ = 1 # :nodoc:
|
|
51
|
+
DISTANCE_LED_CONFIG_OFF = 0 # :nodoc:
|
|
52
|
+
DISTANCE_LED_CONFIG_ON = 1 # :nodoc:
|
|
53
|
+
DISTANCE_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
54
|
+
DISTANCE_LED_CONFIG_SHOW_DISTANCE = 3 # :nodoc:
|
|
55
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
56
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
57
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
58
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
59
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
60
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
61
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
62
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
63
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
64
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
65
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
66
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
67
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
68
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
69
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
70
|
+
|
|
71
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
72
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
73
|
+
def initialize(uid, ipcon)
|
|
74
|
+
super uid, ipcon
|
|
75
|
+
|
|
76
|
+
@api_version = [2, 0, 0]
|
|
77
|
+
|
|
78
|
+
@response_expected[FUNCTION_GET_DISTANCE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
79
|
+
@response_expected[FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
80
|
+
@response_expected[FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
81
|
+
@response_expected[FUNCTION_SET_UPDATE_RATE] = RESPONSE_EXPECTED_FALSE
|
|
82
|
+
@response_expected[FUNCTION_GET_UPDATE_RATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
83
|
+
@response_expected[FUNCTION_SET_DISTANCE_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
84
|
+
@response_expected[FUNCTION_GET_DISTANCE_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
85
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
86
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
87
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
88
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
89
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
90
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
91
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
92
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
93
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
94
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
95
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
96
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
97
|
+
|
|
98
|
+
@callback_formats[CALLBACK_DISTANCE] = 'S'
|
|
99
|
+
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Returns the distance in mm.
|
|
103
|
+
#
|
|
104
|
+
#
|
|
105
|
+
# If you want to get the value periodically, it is recommended to use the
|
|
106
|
+
# CALLBACK_DISTANCE callback. You can set the callback configuration
|
|
107
|
+
# with BrickletDistanceUSV2#set_distance_callback_configuration.
|
|
108
|
+
def get_distance
|
|
109
|
+
send_request FUNCTION_GET_DISTANCE, [], '', 2, 'S'
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# The period in ms is the period with which the CALLBACK_DISTANCE callback is triggered
|
|
113
|
+
# periodically. A value of 0 turns the callback off.
|
|
114
|
+
#
|
|
115
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
|
116
|
+
# triggered after the value has changed. If the value didn't change
|
|
117
|
+
# within the period, the callback is triggered immediately on change.
|
|
118
|
+
#
|
|
119
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
|
120
|
+
# independent of the value.
|
|
121
|
+
#
|
|
122
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
|
123
|
+
#
|
|
124
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_DISTANCE callback.
|
|
125
|
+
#
|
|
126
|
+
# The following options are possible:
|
|
127
|
+
#
|
|
128
|
+
# "Option", "Description"
|
|
129
|
+
#
|
|
130
|
+
# "'x'", "Threshold is turned off"
|
|
131
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
|
132
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
|
133
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
|
134
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
135
|
+
#
|
|
136
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
137
|
+
#
|
|
138
|
+
# The default value is (0, false, 'x', 0, 0).
|
|
139
|
+
def set_distance_callback_configuration(period, value_has_to_change, option, min, max)
|
|
140
|
+
send_request FUNCTION_SET_DISTANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k S S', 0, ''
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Returns the callback configuration as set by BrickletDistanceUSV2#set_distance_callback_configuration.
|
|
144
|
+
def get_distance_callback_configuration
|
|
145
|
+
send_request FUNCTION_GET_DISTANCE_CALLBACK_CONFIGURATION, [], '', 10, 'L ? k S S'
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Sets the update rate to 2 Hz or 10 Hz.
|
|
149
|
+
#
|
|
150
|
+
# With 2 Hz update rate the noise is about ±1mm, while with 10 Hz update rate the noise
|
|
151
|
+
# increases to about ±5mm.
|
|
152
|
+
#
|
|
153
|
+
# The default update rate is 2 Hz.
|
|
154
|
+
def set_update_rate(update_rate)
|
|
155
|
+
send_request FUNCTION_SET_UPDATE_RATE, [update_rate], 'C', 0, ''
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Returns the update rate as set by BrickletDistanceUSV2#set_update_rate.
|
|
159
|
+
def get_update_rate
|
|
160
|
+
send_request FUNCTION_GET_UPDATE_RATE, [], '', 1, 'C'
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Configures the distance LED to be either turned off, turned on, blink in
|
|
164
|
+
# heartbeat mode or show the distance (brighter = object is nearer).
|
|
165
|
+
#
|
|
166
|
+
# The default value is 3 (show distance).
|
|
167
|
+
def set_distance_led_config(config)
|
|
168
|
+
send_request FUNCTION_SET_DISTANCE_LED_CONFIG, [config], 'C', 0, ''
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# Returns the LED configuration as set by BrickletDistanceUSV2#set_distance_led_config
|
|
172
|
+
def get_distance_led_config
|
|
173
|
+
send_request FUNCTION_GET_DISTANCE_LED_CONFIG, [], '', 1, 'C'
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
177
|
+
#
|
|
178
|
+
# The errors are divided into
|
|
179
|
+
#
|
|
180
|
+
# * ACK checksum errors,
|
|
181
|
+
# * message checksum errors,
|
|
182
|
+
# * framing errors and
|
|
183
|
+
# * overflow errors.
|
|
184
|
+
#
|
|
185
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
186
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
187
|
+
def get_spitfp_error_count
|
|
188
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
192
|
+
# mode change was instigated.
|
|
193
|
+
#
|
|
194
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
195
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
196
|
+
# device identifier and CRC are present and correct.
|
|
197
|
+
#
|
|
198
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
199
|
+
# necessary to call it in a normal user program.
|
|
200
|
+
def set_bootloader_mode(mode)
|
|
201
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Returns the current bootloader mode, see BrickletDistanceUSV2#set_bootloader_mode.
|
|
205
|
+
def get_bootloader_mode
|
|
206
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Sets the firmware pointer for BrickletDistanceUSV2#write_firmware. The pointer has
|
|
210
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
211
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
212
|
+
#
|
|
213
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
214
|
+
# necessary to call it in a normal user program.
|
|
215
|
+
def set_write_firmware_pointer(pointer)
|
|
216
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
220
|
+
# BrickletDistanceUSV2#set_write_firmware_pointer before. The firmware is written
|
|
221
|
+
# to flash every 4 chunks.
|
|
222
|
+
#
|
|
223
|
+
# You can only write firmware in bootloader mode.
|
|
224
|
+
#
|
|
225
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
226
|
+
# necessary to call it in a normal user program.
|
|
227
|
+
def write_firmware(data)
|
|
228
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
# Sets the status LED configuration. By default the LED shows
|
|
232
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
233
|
+
# for every 10 received data packets.
|
|
234
|
+
#
|
|
235
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
236
|
+
#
|
|
237
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
238
|
+
def set_status_led_config(config)
|
|
239
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# Returns the configuration as set by BrickletDistanceUSV2#set_status_led_config
|
|
243
|
+
def get_status_led_config
|
|
244
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
248
|
+
# value returned is not the ambient temperature!
|
|
249
|
+
#
|
|
250
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
251
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
252
|
+
# temperature changes.
|
|
253
|
+
def get_chip_temperature
|
|
254
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
258
|
+
# will be lost.
|
|
259
|
+
#
|
|
260
|
+
# After a reset you have to create new device objects,
|
|
261
|
+
# calling functions on the existing ones will result in
|
|
262
|
+
# undefined behavior!
|
|
263
|
+
def reset
|
|
264
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
268
|
+
# you have to decode the Base58 encoded UID string into an
|
|
269
|
+
# integer first.
|
|
270
|
+
#
|
|
271
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
272
|
+
def write_uid(uid)
|
|
273
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Returns the current UID as an integer. Encode as
|
|
277
|
+
# Base58 to get the usual string version.
|
|
278
|
+
def read_uid
|
|
279
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
283
|
+
# the position, the hardware and firmware version as well as the
|
|
284
|
+
# device identifier.
|
|
285
|
+
#
|
|
286
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
287
|
+
#
|
|
288
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
289
|
+
# |device_identifier_constant|
|
|
290
|
+
def get_identity
|
|
291
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
295
|
+
def register_callback(id, &block)
|
|
296
|
+
callback = block
|
|
297
|
+
@registered_callbacks[id] = callback
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
end
|