tinkerforge 2.1.24 → 2.1.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +156 -75
- data/lib/tinkerforge/brick_hat.rb +69 -31
- data/lib/tinkerforge/brick_hat_zero.rb +55 -23
- data/lib/tinkerforge/brick_imu.rb +185 -78
- data/lib/tinkerforge/brick_imu_v2.rb +209 -106
- data/lib/tinkerforge/brick_master.rb +491 -183
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +186 -102
- data/lib/tinkerforge/brick_silent_stepper.rb +247 -167
- data/lib/tinkerforge/brick_stepper.rb +211 -99
- data/lib/tinkerforge/bricklet_accelerometer.rb +57 -23
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +104 -54
- data/lib/tinkerforge/bricklet_air_quality.rb +116 -59
- data/lib/tinkerforge/bricklet_ambient_light.rb +50 -21
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +44 -24
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +65 -27
- data/lib/tinkerforge/bricklet_analog_in.rb +62 -25
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +56 -23
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +66 -25
- data/lib/tinkerforge/bricklet_analog_out.rb +22 -9
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +19 -8
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +53 -20
- data/lib/tinkerforge/bricklet_barometer.rb +100 -27
- data/lib/tinkerforge/bricklet_barometer_v2.rb +98 -37
- data/lib/tinkerforge/bricklet_can.rb +83 -19
- data/lib/tinkerforge/bricklet_can_v2.rb +171 -38
- data/lib/tinkerforge/bricklet_co2.rb +33 -14
- data/lib/tinkerforge/bricklet_co2_v2.rb +97 -38
- data/lib/tinkerforge/bricklet_color.rb +68 -27
- data/lib/tinkerforge/bricklet_color_v2.rb +86 -33
- data/lib/tinkerforge/bricklet_compass.rb +77 -30
- data/lib/tinkerforge/bricklet_current12.rb +57 -24
- data/lib/tinkerforge/bricklet_current25.rb +57 -24
- data/lib/tinkerforge/bricklet_dc_v2.rb +521 -0
- data/lib/tinkerforge/bricklet_distance_ir.rb +56 -23
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +82 -31
- data/lib/tinkerforge/bricklet_distance_us.rb +39 -16
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +66 -25
- data/lib/tinkerforge/bricklet_dmx.rb +87 -34
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -10
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +63 -24
- data/lib/tinkerforge/bricklet_dual_relay.rb +26 -11
- data/lib/tinkerforge/bricklet_dust_detector.rb +39 -16
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +87 -32
- data/lib/tinkerforge/bricklet_energy_monitor.rb +72 -27
- data/lib/tinkerforge/bricklet_gps.rb +63 -26
- data/lib/tinkerforge/bricklet_gps_v2.rb +116 -47
- data/lib/tinkerforge/bricklet_hall_effect.rb +42 -23
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +70 -27
- data/lib/tinkerforge/bricklet_humidity.rb +50 -21
- data/lib/tinkerforge/bricklet_humidity_v2.rb +82 -31
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +37 -14
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +80 -29
- data/lib/tinkerforge/bricklet_industrial_counter.rb +100 -39
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +44 -17
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +76 -29
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +35 -14
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +72 -27
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +39 -16
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -30
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +48 -19
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +137 -31
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +60 -23
- data/lib/tinkerforge/bricklet_industrial_ptc.rb +475 -0
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +35 -14
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +66 -25
- data/lib/tinkerforge/bricklet_io16.rb +54 -21
- data/lib/tinkerforge/bricklet_io16_v2.rb +89 -34
- data/lib/tinkerforge/bricklet_io4.rb +54 -23
- data/lib/tinkerforge/bricklet_io4_v2.rb +95 -36
- data/lib/tinkerforge/bricklet_isolator.rb +72 -29
- data/lib/tinkerforge/bricklet_joystick.rb +58 -25
- data/lib/tinkerforge/bricklet_joystick_v2.rb +67 -26
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +81 -32
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +95 -36
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +191 -70
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +44 -18
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +57 -23
- data/lib/tinkerforge/bricklet_led_strip.rb +59 -22
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +90 -46
- data/lib/tinkerforge/bricklet_line.rb +33 -14
- data/lib/tinkerforge/bricklet_linear_poti.rb +50 -21
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +54 -21
- data/lib/tinkerforge/bricklet_load_cell.rb +60 -23
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +79 -30
- data/lib/tinkerforge/bricklet_moisture.rb +39 -16
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +61 -27
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +70 -27
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -13
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +75 -28
- data/lib/tinkerforge/bricklet_nfc.rb +126 -62
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +28 -11
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +65 -24
- data/lib/tinkerforge/bricklet_oled_64x48.rb +28 -11
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -28
- data/lib/tinkerforge/bricklet_particulate_matter.rb +74 -30
- data/lib/tinkerforge/bricklet_performance_dc.rb +682 -0
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +18 -9
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +21 -10
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +79 -42
- data/lib/tinkerforge/bricklet_ptc.rb +73 -42
- data/lib/tinkerforge/bricklet_ptc_v2.rb +94 -48
- data/lib/tinkerforge/bricklet_real_time_clock.rb +44 -33
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +77 -44
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +38 -19
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +59 -24
- data/lib/tinkerforge/bricklet_rotary_poti.rb +52 -28
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +56 -23
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +117 -44
- data/lib/tinkerforge/bricklet_rs485.rb +222 -95
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +74 -35
- data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
- data/lib/tinkerforge/bricklet_silent_stepper_v2.rb +1024 -0
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +34 -18
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +71 -31
- data/lib/tinkerforge/bricklet_temperature.rb +39 -16
- data/lib/tinkerforge/bricklet_temperature_ir.rb +56 -23
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +70 -27
- data/lib/tinkerforge/bricklet_temperature_v2.rb +60 -25
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +104 -44
- data/lib/tinkerforge/bricklet_thermocouple.rb +44 -24
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +64 -27
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +35 -18
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +84 -37
- data/lib/tinkerforge/bricklet_voltage.rb +51 -28
- data/lib/tinkerforge/bricklet_voltage_current.rb +90 -73
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +89 -68
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +79 -30
- data/lib/tinkerforge/device_display_names.rb +170 -0
- data/lib/tinkerforge/ip_connection.rb +153 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +11 -3
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2021-05-06. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.29 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
|
+
require_relative './ip_connection'
|
13
|
+
|
12
14
|
module Tinkerforge
|
13
15
|
# Measures acceleration in three axis
|
14
16
|
class BrickletAccelerometer < Device
|
@@ -17,7 +19,8 @@ module Tinkerforge
|
|
17
19
|
|
18
20
|
# This callback is triggered periodically with the period that is set by
|
19
21
|
# BrickletAccelerometer#set_acceleration_callback_period. The parameters are the
|
20
|
-
# X, Y and Z acceleration.
|
22
|
+
# X, Y and Z acceleration. The range is
|
23
|
+
# configured with BrickletAccelerometer#set_configuration.
|
21
24
|
#
|
22
25
|
# The CALLBACK_ACCELERATION callback is only triggered if the acceleration has
|
23
26
|
# changed since the last triggering.
|
@@ -25,7 +28,8 @@ module Tinkerforge
|
|
25
28
|
|
26
29
|
# This callback is triggered when the threshold as set by
|
27
30
|
# BrickletAccelerometer#set_acceleration_callback_threshold is reached.
|
28
|
-
# The parameters are the X, Y and Z acceleration.
|
31
|
+
# The parameters are the X, Y and Z acceleration. The range is
|
32
|
+
# configured with BrickletAccelerometer#set_configuration.
|
29
33
|
#
|
30
34
|
# If the threshold keeps being reached, the callback is triggered periodically
|
31
35
|
# with the period as set by BrickletAccelerometer#set_debounce_period.
|
@@ -74,7 +78,7 @@ module Tinkerforge
|
|
74
78
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
75
79
|
# the IP Connection <tt>ipcon</tt>.
|
76
80
|
def initialize(uid, ipcon)
|
77
|
-
super uid, ipcon
|
81
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
78
82
|
|
79
83
|
@api_version = [2, 0, 1]
|
80
84
|
|
@@ -93,19 +97,23 @@ module Tinkerforge
|
|
93
97
|
@response_expected[FUNCTION_IS_LED_ON] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
94
98
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
95
99
|
|
96
|
-
@callback_formats[CALLBACK_ACCELERATION] = 's s s'
|
97
|
-
@callback_formats[CALLBACK_ACCELERATION_REACHED] = 's s s'
|
100
|
+
@callback_formats[CALLBACK_ACCELERATION] = [14, 's s s']
|
101
|
+
@callback_formats[CALLBACK_ACCELERATION_REACHED] = [14, 's s s']
|
98
102
|
|
103
|
+
@ipcon.add_device self
|
99
104
|
end
|
100
105
|
|
101
106
|
# Returns the acceleration in x, y and z direction. The values
|
102
|
-
# are given in gₙ/1000 (1gₙ = 9.80665m/s²).
|
107
|
+
# are given in gₙ/1000 (1gₙ = 9.80665m/s²). The range is
|
108
|
+
# configured with BrickletAccelerometer#set_configuration.
|
103
109
|
#
|
104
110
|
# If you want to get the acceleration periodically, it is recommended
|
105
111
|
# to use the CALLBACK_ACCELERATION callback and set the period with
|
106
112
|
# BrickletAccelerometer#set_acceleration_callback_period.
|
107
113
|
def get_acceleration
|
108
|
-
|
114
|
+
check_validity
|
115
|
+
|
116
|
+
send_request FUNCTION_GET_ACCELERATION, [], '', 14, 's s s'
|
109
117
|
end
|
110
118
|
|
111
119
|
# Sets the period with which the CALLBACK_ACCELERATION callback is triggered
|
@@ -114,12 +122,16 @@ module Tinkerforge
|
|
114
122
|
# The CALLBACK_ACCELERATION callback is only triggered if the acceleration has
|
115
123
|
# changed since the last triggering.
|
116
124
|
def set_acceleration_callback_period(period)
|
117
|
-
|
125
|
+
check_validity
|
126
|
+
|
127
|
+
send_request FUNCTION_SET_ACCELERATION_CALLBACK_PERIOD, [period], 'L', 8, ''
|
118
128
|
end
|
119
129
|
|
120
130
|
# Returns the period as set by BrickletAccelerometer#set_acceleration_callback_period.
|
121
131
|
def get_acceleration_callback_period
|
122
|
-
|
132
|
+
check_validity
|
133
|
+
|
134
|
+
send_request FUNCTION_GET_ACCELERATION_CALLBACK_PERIOD, [], '', 12, 'L'
|
123
135
|
end
|
124
136
|
|
125
137
|
# Sets the thresholds for the CALLBACK_ACCELERATION_REACHED callback.
|
@@ -134,12 +146,16 @@ module Tinkerforge
|
|
134
146
|
# "'<'", "Callback is triggered when the acceleration is smaller than the min value (max is ignored)"
|
135
147
|
# "'>'", "Callback is triggered when the acceleration is greater than the min value (max is ignored)"
|
136
148
|
def set_acceleration_callback_threshold(option, min_x, max_x, min_y, max_y, min_z, max_z)
|
137
|
-
|
149
|
+
check_validity
|
150
|
+
|
151
|
+
send_request FUNCTION_SET_ACCELERATION_CALLBACK_THRESHOLD, [option, min_x, max_x, min_y, max_y, min_z, max_z], 'k s s s s s s', 8, ''
|
138
152
|
end
|
139
153
|
|
140
154
|
# Returns the threshold as set by BrickletAccelerometer#set_acceleration_callback_threshold.
|
141
155
|
def get_acceleration_callback_threshold
|
142
|
-
|
156
|
+
check_validity
|
157
|
+
|
158
|
+
send_request FUNCTION_GET_ACCELERATION_CALLBACK_THRESHOLD, [], '', 21, 'k s s s s s s'
|
143
159
|
end
|
144
160
|
|
145
161
|
# Sets the period with which the threshold callback
|
@@ -152,17 +168,23 @@ module Tinkerforge
|
|
152
168
|
#
|
153
169
|
# keeps being reached.
|
154
170
|
def set_debounce_period(debounce)
|
155
|
-
|
171
|
+
check_validity
|
172
|
+
|
173
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
156
174
|
end
|
157
175
|
|
158
176
|
# Returns the debounce period as set by BrickletAccelerometer#set_debounce_period.
|
159
177
|
def get_debounce_period
|
160
|
-
|
178
|
+
check_validity
|
179
|
+
|
180
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
161
181
|
end
|
162
182
|
|
163
183
|
# Returns the temperature of the accelerometer.
|
164
184
|
def get_temperature
|
165
|
-
|
185
|
+
check_validity
|
186
|
+
|
187
|
+
send_request FUNCTION_GET_TEMPERATURE, [], '', 10, 's'
|
166
188
|
end
|
167
189
|
|
168
190
|
# Configures the data rate, full scale range and filter bandwidth.
|
@@ -175,39 +197,51 @@ module Tinkerforge
|
|
175
197
|
# Decreasing data rate or full scale range will also decrease the noise on
|
176
198
|
# the data.
|
177
199
|
def set_configuration(data_rate, full_scale, filter_bandwidth)
|
178
|
-
|
200
|
+
check_validity
|
201
|
+
|
202
|
+
send_request FUNCTION_SET_CONFIGURATION, [data_rate, full_scale, filter_bandwidth], 'C C C', 8, ''
|
179
203
|
end
|
180
204
|
|
181
205
|
# Returns the configuration as set by BrickletAccelerometer#set_configuration.
|
182
206
|
def get_configuration
|
183
|
-
|
207
|
+
check_validity
|
208
|
+
|
209
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 11, 'C C C'
|
184
210
|
end
|
185
211
|
|
186
212
|
# Enables the LED on the Bricklet.
|
187
213
|
def led_on
|
188
|
-
|
214
|
+
check_validity
|
215
|
+
|
216
|
+
send_request FUNCTION_LED_ON, [], '', 8, ''
|
189
217
|
end
|
190
218
|
|
191
219
|
# Disables the LED on the Bricklet.
|
192
220
|
def led_off
|
193
|
-
|
221
|
+
check_validity
|
222
|
+
|
223
|
+
send_request FUNCTION_LED_OFF, [], '', 8, ''
|
194
224
|
end
|
195
225
|
|
196
226
|
# Returns *true* if the LED is enabled, *false* otherwise.
|
197
227
|
def is_led_on
|
198
|
-
|
228
|
+
check_validity
|
229
|
+
|
230
|
+
send_request FUNCTION_IS_LED_ON, [], '', 9, '?'
|
199
231
|
end
|
200
232
|
|
201
233
|
# Returns the UID, the UID where the Bricklet is connected to,
|
202
234
|
# the position, the hardware and firmware version as well as the
|
203
235
|
# device identifier.
|
204
236
|
#
|
205
|
-
# The position can be 'a', 'b', 'c' or '
|
237
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
238
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
239
|
+
# position 'z'.
|
206
240
|
#
|
207
241
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
208
242
|
# |device_identifier_constant|
|
209
243
|
def get_identity
|
210
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
244
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
211
245
|
end
|
212
246
|
|
213
247
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2021-05-06. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.29 #
|
6
6
|
# #
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
10
10
|
#############################################################
|
11
11
|
|
12
|
+
require_relative './ip_connection'
|
13
|
+
|
12
14
|
module Tinkerforge
|
13
15
|
# Measures acceleration in three axis
|
14
16
|
class BrickletAccelerometerV2 < Device
|
@@ -33,18 +35,18 @@ module Tinkerforge
|
|
33
35
|
#
|
34
36
|
# Otherwise you have to use the following formulas that depend on the
|
35
37
|
# full scale range (see BrickletAccelerometerV2#set_configuration) to calculate
|
36
|
-
# the data in g
|
38
|
+
# the data in gₙ/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
|
37
39
|
#
|
38
|
-
# * Full scale 2g: acceleration = value*625/1024
|
39
|
-
# * Full scale 4g: acceleration = value*1250/1024
|
40
|
-
# * Full scale 8g: acceleration = value*2500/1024
|
40
|
+
# * Full scale 2g: acceleration = value * 625 / 1024
|
41
|
+
# * Full scale 4g: acceleration = value * 1250 / 1024
|
42
|
+
# * Full scale 8g: acceleration = value * 2500 / 1024
|
41
43
|
#
|
42
44
|
# The data is formated in the sequence "x, y, z, x, y, z, ..." depending on
|
43
45
|
# the enabled axis. Examples:
|
44
46
|
#
|
45
|
-
# * x, y, z enabled: "x, y, z, ... 10x
|
46
|
-
# * x, z enabled: "x, z, ... 15x
|
47
|
-
# * y enabled: "y, ... 30x
|
47
|
+
# * x, y, z enabled: "x, y, z, ..." 10x repeated
|
48
|
+
# * x, z enabled: "x, z, ..." 15x repeated
|
49
|
+
# * y enabled: "y, ..." 30x repeated
|
48
50
|
CALLBACK_CONTINUOUS_ACCELERATION_16_BIT = 11
|
49
51
|
|
50
52
|
# Returns 60 acceleration values with 8 bit resolution. The data rate can
|
@@ -59,18 +61,18 @@ module Tinkerforge
|
|
59
61
|
#
|
60
62
|
# Otherwise you have to use the following formulas that depend on the
|
61
63
|
# full scale range (see BrickletAccelerometerV2#set_configuration) to calculate
|
62
|
-
# the data in g
|
64
|
+
# the data in gₙ/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
|
63
65
|
#
|
64
|
-
# * Full scale 2g: acceleration = value*256*625/1024
|
65
|
-
# * Full scale 4g: acceleration = value*256*1250/1024
|
66
|
-
# * Full scale 8g: acceleration = value*256*2500/1024
|
66
|
+
# * Full scale 2g: acceleration = value * 256 * 625 / 1024
|
67
|
+
# * Full scale 4g: acceleration = value * 256 * 1250 / 1024
|
68
|
+
# * Full scale 8g: acceleration = value * 256 * 2500 / 1024
|
67
69
|
#
|
68
70
|
# The data is formated in the sequence "x, y, z, x, y, z, ..." depending on
|
69
71
|
# the enabled axis. Examples:
|
70
72
|
#
|
71
|
-
# * x, y, z enabled: "x, y, z, ... 20x
|
72
|
-
# * x, z enabled: "x, z, ... 30x
|
73
|
-
# * y enabled: "y, ... 60x
|
73
|
+
# * x, y, z enabled: "x, y, z, ..." 20x repeated
|
74
|
+
# * x, z enabled: "x, z, ..." 30x repeated
|
75
|
+
# * y enabled: "y, ..." 60x repeated
|
74
76
|
CALLBACK_CONTINUOUS_ACCELERATION_8_BIT = 12
|
75
77
|
|
76
78
|
FUNCTION_GET_ACCELERATION = 1 # :nodoc:
|
@@ -144,7 +146,7 @@ module Tinkerforge
|
|
144
146
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
145
147
|
# the IP Connection <tt>ipcon</tt>.
|
146
148
|
def initialize(uid, ipcon)
|
147
|
-
super uid, ipcon
|
149
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
148
150
|
|
149
151
|
@api_version = [2, 0, 1]
|
150
152
|
|
@@ -155,7 +157,7 @@ module Tinkerforge
|
|
155
157
|
@response_expected[FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
156
158
|
@response_expected[FUNCTION_SET_INFO_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
157
159
|
@response_expected[FUNCTION_GET_INFO_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
158
|
-
@response_expected[FUNCTION_SET_CONTINUOUS_ACCELERATION_CONFIGURATION] =
|
160
|
+
@response_expected[FUNCTION_SET_CONTINUOUS_ACCELERATION_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
159
161
|
@response_expected[FUNCTION_GET_CONTINUOUS_ACCELERATION_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
160
162
|
@response_expected[FUNCTION_SET_FILTER_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
161
163
|
@response_expected[FUNCTION_GET_FILTER_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
@@ -172,20 +174,24 @@ module Tinkerforge
|
|
172
174
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
173
175
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
174
176
|
|
175
|
-
@callback_formats[CALLBACK_ACCELERATION] = 'l l l'
|
176
|
-
@callback_formats[CALLBACK_CONTINUOUS_ACCELERATION_16_BIT] = 's30'
|
177
|
-
@callback_formats[CALLBACK_CONTINUOUS_ACCELERATION_8_BIT] = 'c60'
|
177
|
+
@callback_formats[CALLBACK_ACCELERATION] = [20, 'l l l']
|
178
|
+
@callback_formats[CALLBACK_CONTINUOUS_ACCELERATION_16_BIT] = [68, 's30']
|
179
|
+
@callback_formats[CALLBACK_CONTINUOUS_ACCELERATION_8_BIT] = [68, 'c60']
|
178
180
|
|
181
|
+
@ipcon.add_device self
|
179
182
|
end
|
180
183
|
|
181
184
|
# Returns the acceleration in x, y and z direction. The values
|
182
|
-
# are given in gₙ/10000 (1gₙ = 9.80665m/s²).
|
185
|
+
# are given in gₙ/10000 (1gₙ = 9.80665m/s²). The range is
|
186
|
+
# configured with BrickletAccelerometerV2#set_configuration.
|
183
187
|
#
|
184
188
|
# If you want to get the acceleration periodically, it is recommended
|
185
189
|
# to use the CALLBACK_ACCELERATION callback and set the period with
|
186
190
|
# BrickletAccelerometerV2#set_acceleration_callback_configuration.
|
187
191
|
def get_acceleration
|
188
|
-
|
192
|
+
check_validity
|
193
|
+
|
194
|
+
send_request FUNCTION_GET_ACCELERATION, [], '', 20, 'l l l'
|
189
195
|
end
|
190
196
|
|
191
197
|
# Configures the data rate and full scale range.
|
@@ -197,12 +203,16 @@ module Tinkerforge
|
|
197
203
|
# Decreasing data rate or full scale range will also decrease the noise on
|
198
204
|
# the data.
|
199
205
|
def set_configuration(data_rate, full_scale)
|
200
|
-
|
206
|
+
check_validity
|
207
|
+
|
208
|
+
send_request FUNCTION_SET_CONFIGURATION, [data_rate, full_scale], 'C C', 8, ''
|
201
209
|
end
|
202
210
|
|
203
211
|
# Returns the configuration as set by BrickletAccelerometerV2#set_configuration.
|
204
212
|
def get_configuration
|
205
|
-
|
213
|
+
check_validity
|
214
|
+
|
215
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
|
206
216
|
end
|
207
217
|
|
208
218
|
# The period is the period with which the CALLBACK_ACCELERATION
|
@@ -218,24 +228,32 @@ module Tinkerforge
|
|
218
228
|
# If this callback is enabled, the CALLBACK_CONTINUOUS_ACCELERATION_16_BIT callback
|
219
229
|
# and CALLBACK_CONTINUOUS_ACCELERATION_8_BIT callback will automatically be disabled.
|
220
230
|
def set_acceleration_callback_configuration(period, value_has_to_change)
|
221
|
-
|
231
|
+
check_validity
|
232
|
+
|
233
|
+
send_request FUNCTION_SET_ACCELERATION_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
222
234
|
end
|
223
235
|
|
224
236
|
# Returns the callback configuration as set by
|
225
237
|
# BrickletAccelerometerV2#set_acceleration_callback_configuration.
|
226
238
|
def get_acceleration_callback_configuration
|
227
|
-
|
239
|
+
check_validity
|
240
|
+
|
241
|
+
send_request FUNCTION_GET_ACCELERATION_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
228
242
|
end
|
229
243
|
|
230
244
|
# Configures the info LED (marked as "Force" on the Bricklet) to be either turned off,
|
231
245
|
# turned on, or blink in heartbeat mode.
|
232
246
|
def set_info_led_config(config)
|
233
|
-
|
247
|
+
check_validity
|
248
|
+
|
249
|
+
send_request FUNCTION_SET_INFO_LED_CONFIG, [config], 'C', 8, ''
|
234
250
|
end
|
235
251
|
|
236
252
|
# Returns the LED configuration as set by BrickletAccelerometerV2#set_info_led_config
|
237
253
|
def get_info_led_config
|
238
|
-
|
254
|
+
check_validity
|
255
|
+
|
256
|
+
send_request FUNCTION_GET_INFO_LED_CONFIG, [], '', 9, 'C'
|
239
257
|
end
|
240
258
|
|
241
259
|
# For high throughput of acceleration data (> 1000Hz) you have to use the
|
@@ -258,18 +276,18 @@ module Tinkerforge
|
|
258
276
|
#
|
259
277
|
# Otherwise you have to use the following formulas that depend on the configured
|
260
278
|
# resolution (8/16 bit) and the full scale range (see BrickletAccelerometerV2#set_configuration) to calculate
|
261
|
-
# the data in g
|
279
|
+
# the data in gₙ/10000 (same unit that is returned by BrickletAccelerometerV2#get_acceleration):
|
262
280
|
#
|
263
|
-
# * 16 bit, full scale 2g: acceleration = value*625/1024
|
264
|
-
# * 16 bit, full scale 4g: acceleration = value*1250/1024
|
265
|
-
# * 16 bit, full scale 8g: acceleration = value*2500/1024
|
281
|
+
# * 16 bit, full scale 2g: acceleration = value * 625 / 1024
|
282
|
+
# * 16 bit, full scale 4g: acceleration = value * 1250 / 1024
|
283
|
+
# * 16 bit, full scale 8g: acceleration = value * 2500 / 1024
|
266
284
|
#
|
267
285
|
# If a resolution of 8 bit is used, only the 8 most significant bits will be
|
268
286
|
# transferred, so you can use the following formulas:
|
269
287
|
#
|
270
|
-
# * 8 bit, full scale 2g: acceleration = value*256*625/1024
|
271
|
-
# * 8 bit, full scale 4g: acceleration = value*256*1250/1024
|
272
|
-
# * 8 bit, full scale 8g: acceleration = value*256*2500/1024
|
288
|
+
# * 8 bit, full scale 2g: acceleration = value * 256 * 625 / 1024
|
289
|
+
# * 8 bit, full scale 4g: acceleration = value * 256 * 1250 / 1024
|
290
|
+
# * 8 bit, full scale 8g: acceleration = value * 256 * 2500 / 1024
|
273
291
|
#
|
274
292
|
# If no axis is enabled, both callbacks are disabled. If one of the continuous
|
275
293
|
# callbacks is enabled, the CALLBACK_ACCELERATION callback is disabled.
|
@@ -282,13 +300,17 @@ module Tinkerforge
|
|
282
300
|
# "2", "25600Hz", "15000Hz"
|
283
301
|
# "3", "20000Hz", "10000Hz"
|
284
302
|
def set_continuous_acceleration_configuration(enable_x, enable_y, enable_z, resolution)
|
285
|
-
|
303
|
+
check_validity
|
304
|
+
|
305
|
+
send_request FUNCTION_SET_CONTINUOUS_ACCELERATION_CONFIGURATION, [enable_x, enable_y, enable_z, resolution], '? ? ? C', 8, ''
|
286
306
|
end
|
287
307
|
|
288
308
|
# Returns the continuous acceleration configuration as set by
|
289
309
|
# BrickletAccelerometerV2#set_continuous_acceleration_configuration.
|
290
310
|
def get_continuous_acceleration_configuration
|
291
|
-
|
311
|
+
check_validity
|
312
|
+
|
313
|
+
send_request FUNCTION_GET_CONTINUOUS_ACCELERATION_CONFIGURATION, [], '', 12, '? ? ? C'
|
292
314
|
end
|
293
315
|
|
294
316
|
# Configures IIR Bypass filter mode and low pass filter roll off corner frequency.
|
@@ -304,14 +326,18 @@ module Tinkerforge
|
|
304
326
|
#
|
305
327
|
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
306
328
|
def set_filter_configuration(iir_bypass, low_pass_filter)
|
307
|
-
|
329
|
+
check_validity
|
330
|
+
|
331
|
+
send_request FUNCTION_SET_FILTER_CONFIGURATION, [iir_bypass, low_pass_filter], 'C C', 8, ''
|
308
332
|
end
|
309
333
|
|
310
334
|
# Returns the configuration as set by BrickletAccelerometerV2#set_filter_configuration.
|
311
335
|
#
|
312
336
|
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
313
337
|
def get_filter_configuration
|
314
|
-
|
338
|
+
check_validity
|
339
|
+
|
340
|
+
send_request FUNCTION_GET_FILTER_CONFIGURATION, [], '', 10, 'C C'
|
315
341
|
end
|
316
342
|
|
317
343
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -326,7 +352,9 @@ module Tinkerforge
|
|
326
352
|
# The errors counts are for errors that occur on the Bricklet side. All
|
327
353
|
# Bricks have a similar function that returns the errors on the Brick side.
|
328
354
|
def get_spitfp_error_count
|
329
|
-
|
355
|
+
check_validity
|
356
|
+
|
357
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
330
358
|
end
|
331
359
|
|
332
360
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -339,12 +367,16 @@ module Tinkerforge
|
|
339
367
|
# This function is used by Brick Viewer during flashing. It should not be
|
340
368
|
# necessary to call it in a normal user program.
|
341
369
|
def set_bootloader_mode(mode)
|
342
|
-
|
370
|
+
check_validity
|
371
|
+
|
372
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
343
373
|
end
|
344
374
|
|
345
375
|
# Returns the current bootloader mode, see BrickletAccelerometerV2#set_bootloader_mode.
|
346
376
|
def get_bootloader_mode
|
347
|
-
|
377
|
+
check_validity
|
378
|
+
|
379
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
348
380
|
end
|
349
381
|
|
350
382
|
# Sets the firmware pointer for BrickletAccelerometerV2#write_firmware. The pointer has
|
@@ -354,7 +386,9 @@ module Tinkerforge
|
|
354
386
|
# This function is used by Brick Viewer during flashing. It should not be
|
355
387
|
# necessary to call it in a normal user program.
|
356
388
|
def set_write_firmware_pointer(pointer)
|
357
|
-
|
389
|
+
check_validity
|
390
|
+
|
391
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
358
392
|
end
|
359
393
|
|
360
394
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -366,7 +400,9 @@ module Tinkerforge
|
|
366
400
|
# This function is used by Brick Viewer during flashing. It should not be
|
367
401
|
# necessary to call it in a normal user program.
|
368
402
|
def write_firmware(data)
|
369
|
-
|
403
|
+
check_validity
|
404
|
+
|
405
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
370
406
|
end
|
371
407
|
|
372
408
|
# Sets the status LED configuration. By default the LED shows
|
@@ -377,22 +413,28 @@ module Tinkerforge
|
|
377
413
|
#
|
378
414
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
379
415
|
def set_status_led_config(config)
|
380
|
-
|
416
|
+
check_validity
|
417
|
+
|
418
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
381
419
|
end
|
382
420
|
|
383
421
|
# Returns the configuration as set by BrickletAccelerometerV2#set_status_led_config
|
384
422
|
def get_status_led_config
|
385
|
-
|
423
|
+
check_validity
|
424
|
+
|
425
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
386
426
|
end
|
387
427
|
|
388
|
-
# Returns the temperature
|
428
|
+
# Returns the temperature as measured inside the microcontroller. The
|
389
429
|
# value returned is not the ambient temperature!
|
390
430
|
#
|
391
431
|
# The temperature is only proportional to the real temperature and it has bad
|
392
432
|
# accuracy. Practically it is only useful as an indicator for
|
393
433
|
# temperature changes.
|
394
434
|
def get_chip_temperature
|
395
|
-
|
435
|
+
check_validity
|
436
|
+
|
437
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
396
438
|
end
|
397
439
|
|
398
440
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -402,7 +444,9 @@ module Tinkerforge
|
|
402
444
|
# calling functions on the existing ones will result in
|
403
445
|
# undefined behavior!
|
404
446
|
def reset
|
405
|
-
|
447
|
+
check_validity
|
448
|
+
|
449
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
406
450
|
end
|
407
451
|
|
408
452
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -411,25 +455,31 @@ module Tinkerforge
|
|
411
455
|
#
|
412
456
|
# We recommend that you use Brick Viewer to change the UID.
|
413
457
|
def write_uid(uid)
|
414
|
-
|
458
|
+
check_validity
|
459
|
+
|
460
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
415
461
|
end
|
416
462
|
|
417
463
|
# Returns the current UID as an integer. Encode as
|
418
464
|
# Base58 to get the usual string version.
|
419
465
|
def read_uid
|
420
|
-
|
466
|
+
check_validity
|
467
|
+
|
468
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
421
469
|
end
|
422
470
|
|
423
471
|
# Returns the UID, the UID where the Bricklet is connected to,
|
424
472
|
# the position, the hardware and firmware version as well as the
|
425
473
|
# device identifier.
|
426
474
|
#
|
427
|
-
# The position can be 'a', 'b', 'c' or '
|
475
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
476
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
477
|
+
# position 'z'.
|
428
478
|
#
|
429
479
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
430
480
|
# |device_identifier_constant|
|
431
481
|
def get_identity
|
432
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
482
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
433
483
|
end
|
434
484
|
|
435
485
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|