tinkerforge 2.1.22 → 2.1.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
@@ -0,0 +1,397 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
#############################################################
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
4
|
+
# #
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
6
|
+
# #
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
10
|
+
#############################################################
|
11
|
+
|
12
|
+
require_relative './ip_connection'
|
13
|
+
|
14
|
+
module Tinkerforge
|
15
|
+
# 3-axis compass with 10 nanotesla and 0.1° resolution
|
16
|
+
class BrickletCompass < Device
|
17
|
+
DEVICE_IDENTIFIER = 2153 # :nodoc:
|
18
|
+
DEVICE_DISPLAY_NAME = 'Compass Bricklet' # :nodoc:
|
19
|
+
|
20
|
+
# This callback is triggered periodically according to the configuration set by
|
21
|
+
# BrickletCompass#set_heading_callback_configuration.
|
22
|
+
#
|
23
|
+
# The parameter is the same as BrickletCompass#get_heading.
|
24
|
+
CALLBACK_HEADING = 4
|
25
|
+
|
26
|
+
# This callback is triggered periodically according to the configuration set by
|
27
|
+
# BrickletCompass#set_magnetic_flux_density_callback_configuration.
|
28
|
+
#
|
29
|
+
# The parameters are the same as BrickletCompass#get_magnetic_flux_density.
|
30
|
+
CALLBACK_MAGNETIC_FLUX_DENSITY = 8
|
31
|
+
|
32
|
+
FUNCTION_GET_HEADING = 1 # :nodoc:
|
33
|
+
FUNCTION_SET_HEADING_CALLBACK_CONFIGURATION = 2 # :nodoc:
|
34
|
+
FUNCTION_GET_HEADING_CALLBACK_CONFIGURATION = 3 # :nodoc:
|
35
|
+
FUNCTION_GET_MAGNETIC_FLUX_DENSITY = 5 # :nodoc:
|
36
|
+
FUNCTION_SET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION = 6 # :nodoc:
|
37
|
+
FUNCTION_GET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION = 7 # :nodoc:
|
38
|
+
FUNCTION_SET_CONFIGURATION = 9 # :nodoc:
|
39
|
+
FUNCTION_GET_CONFIGURATION = 10 # :nodoc:
|
40
|
+
FUNCTION_SET_CALIBRATION = 11 # :nodoc:
|
41
|
+
FUNCTION_GET_CALIBRATION = 12 # :nodoc:
|
42
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
43
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
44
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
45
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
46
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
47
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
48
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
49
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
50
|
+
FUNCTION_RESET = 243 # :nodoc:
|
51
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
52
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
53
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
54
|
+
|
55
|
+
THRESHOLD_OPTION_OFF = 'x' # :nodoc:
|
56
|
+
THRESHOLD_OPTION_OUTSIDE = 'o' # :nodoc:
|
57
|
+
THRESHOLD_OPTION_INSIDE = 'i' # :nodoc:
|
58
|
+
THRESHOLD_OPTION_SMALLER = '<' # :nodoc:
|
59
|
+
THRESHOLD_OPTION_GREATER = '>' # :nodoc:
|
60
|
+
DATA_RATE_100HZ = 0 # :nodoc:
|
61
|
+
DATA_RATE_200HZ = 1 # :nodoc:
|
62
|
+
DATA_RATE_400HZ = 2 # :nodoc:
|
63
|
+
DATA_RATE_600HZ = 3 # :nodoc:
|
64
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
65
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
66
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
67
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
68
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
69
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
70
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
71
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
72
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
73
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
74
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
75
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
76
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
77
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
78
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
79
|
+
|
80
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
81
|
+
# the IP Connection <tt>ipcon</tt>.
|
82
|
+
def initialize(uid, ipcon)
|
83
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
84
|
+
|
85
|
+
@api_version = [2, 0, 0]
|
86
|
+
|
87
|
+
@response_expected[FUNCTION_GET_HEADING] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
88
|
+
@response_expected[FUNCTION_SET_HEADING_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
89
|
+
@response_expected[FUNCTION_GET_HEADING_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
90
|
+
@response_expected[FUNCTION_GET_MAGNETIC_FLUX_DENSITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
91
|
+
@response_expected[FUNCTION_SET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
92
|
+
@response_expected[FUNCTION_GET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
93
|
+
@response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
94
|
+
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
95
|
+
@response_expected[FUNCTION_SET_CALIBRATION] = RESPONSE_EXPECTED_FALSE
|
96
|
+
@response_expected[FUNCTION_GET_CALIBRATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
97
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
98
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
99
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
100
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
101
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
102
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
103
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
104
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
105
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
106
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
107
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
108
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
109
|
+
|
110
|
+
@callback_formats[CALLBACK_HEADING] = [10, 's']
|
111
|
+
@callback_formats[CALLBACK_MAGNETIC_FLUX_DENSITY] = [20, 'l l l']
|
112
|
+
|
113
|
+
@ipcon.add_device self
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns the heading (north = 0 degree, east = 90 degree).
|
117
|
+
#
|
118
|
+
# Alternatively you can use BrickletCompass#get_magnetic_flux_density and calculate the
|
119
|
+
# heading with ``heading = atan2(y, x) * 180 / PI``.
|
120
|
+
#
|
121
|
+
#
|
122
|
+
# If you want to get the value periodically, it is recommended to use the
|
123
|
+
# CALLBACK_HEADING callback. You can set the callback configuration
|
124
|
+
# with BrickletCompass#set_heading_callback_configuration.
|
125
|
+
def get_heading
|
126
|
+
check_validity
|
127
|
+
|
128
|
+
send_request FUNCTION_GET_HEADING, [], '', 10, 's'
|
129
|
+
end
|
130
|
+
|
131
|
+
# The period is the period with which the CALLBACK_HEADING callback is triggered
|
132
|
+
# periodically. A value of 0 turns the callback off.
|
133
|
+
#
|
134
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
135
|
+
# triggered after the value has changed. If the value didn't change
|
136
|
+
# within the period, the callback is triggered immediately on change.
|
137
|
+
#
|
138
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
139
|
+
# independent of the value.
|
140
|
+
#
|
141
|
+
# It is furthermore possible to constrain the callback with thresholds.
|
142
|
+
#
|
143
|
+
# The `option`-parameter together with min/max sets a threshold for the CALLBACK_HEADING callback.
|
144
|
+
#
|
145
|
+
# The following options are possible:
|
146
|
+
#
|
147
|
+
# "Option", "Description"
|
148
|
+
#
|
149
|
+
# "'x'", "Threshold is turned off"
|
150
|
+
# "'o'", "Threshold is triggered when the value is *outside* the min and max values"
|
151
|
+
# "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
|
152
|
+
# "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
|
153
|
+
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
154
|
+
#
|
155
|
+
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
156
|
+
def set_heading_callback_configuration(period, value_has_to_change, option, min, max)
|
157
|
+
check_validity
|
158
|
+
|
159
|
+
send_request FUNCTION_SET_HEADING_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 8, ''
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns the callback configuration as set by BrickletCompass#set_heading_callback_configuration.
|
163
|
+
def get_heading_callback_configuration
|
164
|
+
check_validity
|
165
|
+
|
166
|
+
send_request FUNCTION_GET_HEADING_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k s s'
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns the `magnetic flux density (magnetic induction) <https://en.wikipedia.org/wiki/Magnetic_flux>`__
|
170
|
+
# for all three axis.
|
171
|
+
#
|
172
|
+
# If you want to get the value periodically, it is recommended to use the
|
173
|
+
# CALLBACK_MAGNETIC_FLUX_DENSITY callback. You can set the callback configuration
|
174
|
+
# with BrickletCompass#set_magnetic_flux_density_callback_configuration.
|
175
|
+
def get_magnetic_flux_density
|
176
|
+
check_validity
|
177
|
+
|
178
|
+
send_request FUNCTION_GET_MAGNETIC_FLUX_DENSITY, [], '', 20, 'l l l'
|
179
|
+
end
|
180
|
+
|
181
|
+
# The period is the period with which the CALLBACK_MAGNETIC_FLUX_DENSITY callback
|
182
|
+
# is triggered periodically. A value of 0 turns the callback off.
|
183
|
+
#
|
184
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
185
|
+
# triggered after the value has changed. If the value didn't change within the
|
186
|
+
# period, the callback is triggered immediately on change.
|
187
|
+
#
|
188
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
189
|
+
# independent of the value.
|
190
|
+
def set_magnetic_flux_density_callback_configuration(period, value_has_to_change)
|
191
|
+
check_validity
|
192
|
+
|
193
|
+
send_request FUNCTION_SET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the callback configuration as set by
|
197
|
+
# BrickletCompass#set_magnetic_flux_density_callback_configuration.
|
198
|
+
def get_magnetic_flux_density_callback_configuration
|
199
|
+
check_validity
|
200
|
+
|
201
|
+
send_request FUNCTION_GET_MAGNETIC_FLUX_DENSITY_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
202
|
+
end
|
203
|
+
|
204
|
+
# Configures the data rate and background calibration.
|
205
|
+
#
|
206
|
+
# * Data Rate: Sets the data rate that is used by the magnetometer.
|
207
|
+
# The lower the data rate, the lower is the noise on the data.
|
208
|
+
# * Background Calibration: Set to *true* to enable the background
|
209
|
+
# calibration and *false* to turn it off. If the background calibration
|
210
|
+
# is enabled the sensing polarity is flipped once per second to automatically
|
211
|
+
# calculate and remove offset that is caused by temperature changes.
|
212
|
+
# This polarity flipping takes about 20ms. This means that once a second
|
213
|
+
# you will not get new data for a period of 20ms. We highly recommend that
|
214
|
+
# you keep the background calibration enabled and only disable it if the 20ms
|
215
|
+
# off-time is a problem in your application.
|
216
|
+
def set_configuration(data_rate, background_calibration)
|
217
|
+
check_validity
|
218
|
+
|
219
|
+
send_request FUNCTION_SET_CONFIGURATION, [data_rate, background_calibration], 'C ?', 8, ''
|
220
|
+
end
|
221
|
+
|
222
|
+
# Returns the configuration as set by BrickletCompass#set_configuration.
|
223
|
+
def get_configuration
|
224
|
+
check_validity
|
225
|
+
|
226
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C ?'
|
227
|
+
end
|
228
|
+
|
229
|
+
# Sets offset and gain for each of the three axes.
|
230
|
+
#
|
231
|
+
# The Bricklet is factory calibrated. If you want to re-calibrate the
|
232
|
+
# Bricklet we recommend that you do the calibration through Brick Viewer.
|
233
|
+
#
|
234
|
+
# The calibration is saved in non-volatile memory and only has to be
|
235
|
+
# done once.
|
236
|
+
def set_calibration(offset, gain)
|
237
|
+
check_validity
|
238
|
+
|
239
|
+
send_request FUNCTION_SET_CALIBRATION, [offset, gain], 's3 s3', 8, ''
|
240
|
+
end
|
241
|
+
|
242
|
+
# Returns the calibration parameters as set by BrickletCompass#set_calibration.
|
243
|
+
def get_calibration
|
244
|
+
check_validity
|
245
|
+
|
246
|
+
send_request FUNCTION_GET_CALIBRATION, [], '', 20, 's3 s3'
|
247
|
+
end
|
248
|
+
|
249
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
250
|
+
#
|
251
|
+
# The errors are divided into
|
252
|
+
#
|
253
|
+
# * ACK checksum errors,
|
254
|
+
# * message checksum errors,
|
255
|
+
# * framing errors and
|
256
|
+
# * overflow errors.
|
257
|
+
#
|
258
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
259
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
260
|
+
def get_spitfp_error_count
|
261
|
+
check_validity
|
262
|
+
|
263
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
264
|
+
end
|
265
|
+
|
266
|
+
# Sets the bootloader mode and returns the status after the requested
|
267
|
+
# mode change was instigated.
|
268
|
+
#
|
269
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
270
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
271
|
+
# device identifier and CRC are present and correct.
|
272
|
+
#
|
273
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
274
|
+
# necessary to call it in a normal user program.
|
275
|
+
def set_bootloader_mode(mode)
|
276
|
+
check_validity
|
277
|
+
|
278
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
279
|
+
end
|
280
|
+
|
281
|
+
# Returns the current bootloader mode, see BrickletCompass#set_bootloader_mode.
|
282
|
+
def get_bootloader_mode
|
283
|
+
check_validity
|
284
|
+
|
285
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
286
|
+
end
|
287
|
+
|
288
|
+
# Sets the firmware pointer for BrickletCompass#write_firmware. The pointer has
|
289
|
+
# to be increased by chunks of size 64. The data is written to flash
|
290
|
+
# every 4 chunks (which equals to one page of size 256).
|
291
|
+
#
|
292
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
293
|
+
# necessary to call it in a normal user program.
|
294
|
+
def set_write_firmware_pointer(pointer)
|
295
|
+
check_validity
|
296
|
+
|
297
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
298
|
+
end
|
299
|
+
|
300
|
+
# Writes 64 Bytes of firmware at the position as written by
|
301
|
+
# BrickletCompass#set_write_firmware_pointer before. The firmware is written
|
302
|
+
# to flash every 4 chunks.
|
303
|
+
#
|
304
|
+
# You can only write firmware in bootloader mode.
|
305
|
+
#
|
306
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
307
|
+
# necessary to call it in a normal user program.
|
308
|
+
def write_firmware(data)
|
309
|
+
check_validity
|
310
|
+
|
311
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
312
|
+
end
|
313
|
+
|
314
|
+
# Sets the status LED configuration. By default the LED shows
|
315
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
316
|
+
# for every 10 received data packets.
|
317
|
+
#
|
318
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
319
|
+
#
|
320
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
321
|
+
def set_status_led_config(config)
|
322
|
+
check_validity
|
323
|
+
|
324
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
325
|
+
end
|
326
|
+
|
327
|
+
# Returns the configuration as set by BrickletCompass#set_status_led_config
|
328
|
+
def get_status_led_config
|
329
|
+
check_validity
|
330
|
+
|
331
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
332
|
+
end
|
333
|
+
|
334
|
+
# Returns the temperature as measured inside the microcontroller. The
|
335
|
+
# value returned is not the ambient temperature!
|
336
|
+
#
|
337
|
+
# The temperature is only proportional to the real temperature and it has bad
|
338
|
+
# accuracy. Practically it is only useful as an indicator for
|
339
|
+
# temperature changes.
|
340
|
+
def get_chip_temperature
|
341
|
+
check_validity
|
342
|
+
|
343
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
344
|
+
end
|
345
|
+
|
346
|
+
# Calling this function will reset the Bricklet. All configurations
|
347
|
+
# will be lost.
|
348
|
+
#
|
349
|
+
# After a reset you have to create new device objects,
|
350
|
+
# calling functions on the existing ones will result in
|
351
|
+
# undefined behavior!
|
352
|
+
def reset
|
353
|
+
check_validity
|
354
|
+
|
355
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
356
|
+
end
|
357
|
+
|
358
|
+
# Writes a new UID into flash. If you want to set a new UID
|
359
|
+
# you have to decode the Base58 encoded UID string into an
|
360
|
+
# integer first.
|
361
|
+
#
|
362
|
+
# We recommend that you use Brick Viewer to change the UID.
|
363
|
+
def write_uid(uid)
|
364
|
+
check_validity
|
365
|
+
|
366
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
367
|
+
end
|
368
|
+
|
369
|
+
# Returns the current UID as an integer. Encode as
|
370
|
+
# Base58 to get the usual string version.
|
371
|
+
def read_uid
|
372
|
+
check_validity
|
373
|
+
|
374
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
375
|
+
end
|
376
|
+
|
377
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
378
|
+
# the position, the hardware and firmware version as well as the
|
379
|
+
# device identifier.
|
380
|
+
#
|
381
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
382
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
383
|
+
# position 'z'.
|
384
|
+
#
|
385
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
386
|
+
# |device_identifier_constant|
|
387
|
+
def get_identity
|
388
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
389
|
+
end
|
390
|
+
|
391
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
392
|
+
def register_callback(id, &block)
|
393
|
+
callback = block
|
394
|
+
@registered_callbacks[id] = callback
|
395
|
+
end
|
396
|
+
end
|
397
|
+
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
|
+
require_relative './ip_connection'
|
13
|
+
|
12
14
|
module Tinkerforge
|
13
15
|
# Measures AC/DC current between -12.5A and +12.5A
|
14
16
|
class BrickletCurrent12 < Device
|
@@ -76,7 +78,7 @@ module Tinkerforge
|
|
76
78
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
77
79
|
# the IP Connection <tt>ipcon</tt>.
|
78
80
|
def initialize(uid, ipcon)
|
79
|
-
super uid, ipcon
|
81
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
80
82
|
|
81
83
|
@api_version = [2, 0, 0]
|
82
84
|
|
@@ -96,22 +98,24 @@ module Tinkerforge
|
|
96
98
|
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
97
99
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
98
100
|
|
99
|
-
@callback_formats[CALLBACK_CURRENT] = 's'
|
100
|
-
@callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
|
101
|
-
@callback_formats[CALLBACK_CURRENT_REACHED] = 's'
|
102
|
-
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
|
103
|
-
@callback_formats[CALLBACK_OVER_CURRENT] = ''
|
101
|
+
@callback_formats[CALLBACK_CURRENT] = [10, 's']
|
102
|
+
@callback_formats[CALLBACK_ANALOG_VALUE] = [10, 'S']
|
103
|
+
@callback_formats[CALLBACK_CURRENT_REACHED] = [10, 's']
|
104
|
+
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [10, 'S']
|
105
|
+
@callback_formats[CALLBACK_OVER_CURRENT] = [8, '']
|
104
106
|
|
107
|
+
@ipcon.add_device self
|
105
108
|
end
|
106
109
|
|
107
|
-
# Returns the current of the sensor.
|
108
|
-
# and between -12500mA and 12500mA.
|
110
|
+
# Returns the current of the sensor.
|
109
111
|
#
|
110
112
|
# If you want to get the current periodically, it is recommended to use the
|
111
113
|
# CALLBACK_CURRENT callback and set the period with
|
112
114
|
# BrickletCurrent12#set_current_callback_period.
|
113
115
|
def get_current
|
114
|
-
|
116
|
+
check_validity
|
117
|
+
|
118
|
+
send_request FUNCTION_GET_CURRENT, [], '', 10, 's'
|
115
119
|
end
|
116
120
|
|
117
121
|
# Calibrates the 0 value of the sensor. You have to call this function
|
@@ -126,7 +130,9 @@ module Tinkerforge
|
|
126
130
|
# The resulting calibration will be saved on the EEPROM of the Current
|
127
131
|
# Bricklet.
|
128
132
|
def calibrate
|
129
|
-
|
133
|
+
check_validity
|
134
|
+
|
135
|
+
send_request FUNCTION_CALIBRATE, [], '', 8, ''
|
130
136
|
end
|
131
137
|
|
132
138
|
# Returns *true* if more than 12.5A were measured.
|
@@ -134,11 +140,12 @@ module Tinkerforge
|
|
134
140
|
# .. note::
|
135
141
|
# To reset this value you have to power cycle the Bricklet.
|
136
142
|
def is_over_current
|
137
|
-
|
143
|
+
check_validity
|
144
|
+
|
145
|
+
send_request FUNCTION_IS_OVER_CURRENT, [], '', 9, '?'
|
138
146
|
end
|
139
147
|
|
140
148
|
# Returns the value as read by a 12-bit analog-to-digital converter.
|
141
|
-
# The value is between 0 and 4095.
|
142
149
|
#
|
143
150
|
# .. note::
|
144
151
|
# The value returned by BrickletCurrent12#get_current is averaged over several samples
|
@@ -150,39 +157,45 @@ module Tinkerforge
|
|
150
157
|
# CALLBACK_ANALOG_VALUE callback and set the period with
|
151
158
|
# BrickletCurrent12#set_analog_value_callback_period.
|
152
159
|
def get_analog_value
|
153
|
-
|
160
|
+
check_validity
|
161
|
+
|
162
|
+
send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
|
154
163
|
end
|
155
164
|
|
156
|
-
# Sets the period
|
165
|
+
# Sets the period with which the CALLBACK_CURRENT callback is triggered
|
157
166
|
# periodically. A value of 0 turns the callback off.
|
158
167
|
#
|
159
168
|
# The CALLBACK_CURRENT callback is only triggered if the current has changed since
|
160
169
|
# the last triggering.
|
161
|
-
#
|
162
|
-
# The default value is 0.
|
163
170
|
def set_current_callback_period(period)
|
164
|
-
|
171
|
+
check_validity
|
172
|
+
|
173
|
+
send_request FUNCTION_SET_CURRENT_CALLBACK_PERIOD, [period], 'L', 8, ''
|
165
174
|
end
|
166
175
|
|
167
176
|
# Returns the period as set by BrickletCurrent12#set_current_callback_period.
|
168
177
|
def get_current_callback_period
|
169
|
-
|
178
|
+
check_validity
|
179
|
+
|
180
|
+
send_request FUNCTION_GET_CURRENT_CALLBACK_PERIOD, [], '', 12, 'L'
|
170
181
|
end
|
171
182
|
|
172
|
-
# Sets the period
|
183
|
+
# Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
|
173
184
|
# periodically. A value of 0 turns the callback off.
|
174
185
|
#
|
175
186
|
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
176
187
|
# changed since the last triggering.
|
177
|
-
#
|
178
|
-
# The default value is 0.
|
179
188
|
def set_analog_value_callback_period(period)
|
180
|
-
|
189
|
+
check_validity
|
190
|
+
|
191
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
181
192
|
end
|
182
193
|
|
183
194
|
# Returns the period as set by BrickletCurrent12#set_analog_value_callback_period.
|
184
195
|
def get_analog_value_callback_period
|
185
|
-
|
196
|
+
check_validity
|
197
|
+
|
198
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
|
186
199
|
end
|
187
200
|
|
188
201
|
# Sets the thresholds for the CALLBACK_CURRENT_REACHED callback.
|
@@ -196,15 +209,17 @@ module Tinkerforge
|
|
196
209
|
# "'i'", "Callback is triggered when the current is *inside* the min and max values"
|
197
210
|
# "'<'", "Callback is triggered when the current is smaller than the min value (max is ignored)"
|
198
211
|
# "'>'", "Callback is triggered when the current is greater than the min value (max is ignored)"
|
199
|
-
#
|
200
|
-
# The default value is ('x', 0, 0).
|
201
212
|
def set_current_callback_threshold(option, min, max)
|
202
|
-
|
213
|
+
check_validity
|
214
|
+
|
215
|
+
send_request FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 8, ''
|
203
216
|
end
|
204
217
|
|
205
218
|
# Returns the threshold as set by BrickletCurrent12#set_current_callback_threshold.
|
206
219
|
def get_current_callback_threshold
|
207
|
-
|
220
|
+
check_validity
|
221
|
+
|
222
|
+
send_request FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD, [], '', 13, 'k s s'
|
208
223
|
end
|
209
224
|
|
210
225
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
@@ -218,18 +233,20 @@ module Tinkerforge
|
|
218
233
|
# "'i'", "Callback is triggered when the analog value is *inside* the min and max values"
|
219
234
|
# "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
|
220
235
|
# "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
|
221
|
-
#
|
222
|
-
# The default value is ('x', 0, 0).
|
223
236
|
def set_analog_value_callback_threshold(option, min, max)
|
224
|
-
|
237
|
+
check_validity
|
238
|
+
|
239
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
225
240
|
end
|
226
241
|
|
227
242
|
# Returns the threshold as set by BrickletCurrent12#set_analog_value_callback_threshold.
|
228
243
|
def get_analog_value_callback_threshold
|
229
|
-
|
244
|
+
check_validity
|
245
|
+
|
246
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
230
247
|
end
|
231
248
|
|
232
|
-
# Sets the period
|
249
|
+
# Sets the period with which the threshold callbacks
|
233
250
|
#
|
234
251
|
# * CALLBACK_CURRENT_REACHED,
|
235
252
|
# * CALLBACK_ANALOG_VALUE_REACHED
|
@@ -240,27 +257,31 @@ module Tinkerforge
|
|
240
257
|
# * BrickletCurrent12#set_analog_value_callback_threshold
|
241
258
|
#
|
242
259
|
# keep being reached.
|
243
|
-
#
|
244
|
-
# The default value is 100.
|
245
260
|
def set_debounce_period(debounce)
|
246
|
-
|
261
|
+
check_validity
|
262
|
+
|
263
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
247
264
|
end
|
248
265
|
|
249
266
|
# Returns the debounce period as set by BrickletCurrent12#set_debounce_period.
|
250
267
|
def get_debounce_period
|
251
|
-
|
268
|
+
check_validity
|
269
|
+
|
270
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
252
271
|
end
|
253
272
|
|
254
273
|
# Returns the UID, the UID where the Bricklet is connected to,
|
255
274
|
# the position, the hardware and firmware version as well as the
|
256
275
|
# device identifier.
|
257
276
|
#
|
258
|
-
# The position can be 'a', 'b', 'c' or '
|
277
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
278
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
279
|
+
# position 'z'.
|
259
280
|
#
|
260
281
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
261
282
|
# |device_identifier_constant|
|
262
283
|
def get_identity
|
263
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
284
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
264
285
|
end
|
265
286
|
|
266
287
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|