tinkerforge 2.1.22 → 2.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +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
|
@@ -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
|
# 59mm linear potentiometer
|
|
14
16
|
class BrickletLinearPoti < Device
|
|
@@ -70,7 +72,7 @@ module Tinkerforge
|
|
|
70
72
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
71
73
|
# the IP Connection <tt>ipcon</tt>.
|
|
72
74
|
def initialize(uid, ipcon)
|
|
73
|
-
super uid, ipcon
|
|
75
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
74
76
|
|
|
75
77
|
@api_version = [2, 0, 1]
|
|
76
78
|
|
|
@@ -88,11 +90,12 @@ module Tinkerforge
|
|
|
88
90
|
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
89
91
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
90
92
|
|
|
91
|
-
@callback_formats[CALLBACK_POSITION] = 'S'
|
|
92
|
-
@callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
|
|
93
|
-
@callback_formats[CALLBACK_POSITION_REACHED] = 'S'
|
|
94
|
-
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
|
|
93
|
+
@callback_formats[CALLBACK_POSITION] = [10, 'S']
|
|
94
|
+
@callback_formats[CALLBACK_ANALOG_VALUE] = [10, 'S']
|
|
95
|
+
@callback_formats[CALLBACK_POSITION_REACHED] = [10, 'S']
|
|
96
|
+
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [10, 'S']
|
|
95
97
|
|
|
98
|
+
@ipcon.add_device self
|
|
96
99
|
end
|
|
97
100
|
|
|
98
101
|
# Returns the position of the linear potentiometer. The value is
|
|
@@ -102,11 +105,12 @@ module Tinkerforge
|
|
|
102
105
|
# CALLBACK_POSITION callback and set the period with
|
|
103
106
|
# BrickletLinearPoti#set_position_callback_period.
|
|
104
107
|
def get_position
|
|
105
|
-
|
|
108
|
+
check_validity
|
|
109
|
+
|
|
110
|
+
send_request FUNCTION_GET_POSITION, [], '', 10, 'S'
|
|
106
111
|
end
|
|
107
112
|
|
|
108
113
|
# Returns the value as read by a 12-bit analog-to-digital converter.
|
|
109
|
-
# The value is between 0 and 4095.
|
|
110
114
|
#
|
|
111
115
|
# .. note::
|
|
112
116
|
# The value returned by BrickletLinearPoti#get_position is averaged over several samples
|
|
@@ -118,39 +122,45 @@ module Tinkerforge
|
|
|
118
122
|
# CALLBACK_ANALOG_VALUE callback and set the period with
|
|
119
123
|
# BrickletLinearPoti#set_analog_value_callback_period.
|
|
120
124
|
def get_analog_value
|
|
121
|
-
|
|
125
|
+
check_validity
|
|
126
|
+
|
|
127
|
+
send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
|
|
122
128
|
end
|
|
123
129
|
|
|
124
|
-
# Sets the period
|
|
130
|
+
# Sets the period with which the CALLBACK_POSITION callback is triggered
|
|
125
131
|
# periodically. A value of 0 turns the callback off.
|
|
126
132
|
#
|
|
127
133
|
# The CALLBACK_POSITION callback is only triggered if the position has changed
|
|
128
134
|
# since the last triggering.
|
|
129
|
-
#
|
|
130
|
-
# The default value is 0.
|
|
131
135
|
def set_position_callback_period(period)
|
|
132
|
-
|
|
136
|
+
check_validity
|
|
137
|
+
|
|
138
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
133
139
|
end
|
|
134
140
|
|
|
135
141
|
# Returns the period as set by BrickletLinearPoti#set_position_callback_period.
|
|
136
142
|
def get_position_callback_period
|
|
137
|
-
|
|
143
|
+
check_validity
|
|
144
|
+
|
|
145
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
138
146
|
end
|
|
139
147
|
|
|
140
|
-
# Sets the period
|
|
148
|
+
# Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
|
|
141
149
|
# periodically. A value of 0 turns the callback off.
|
|
142
150
|
#
|
|
143
151
|
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
|
144
152
|
# changed since the last triggering.
|
|
145
|
-
#
|
|
146
|
-
# The default value is 0.
|
|
147
153
|
def set_analog_value_callback_period(period)
|
|
148
|
-
|
|
154
|
+
check_validity
|
|
155
|
+
|
|
156
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
149
157
|
end
|
|
150
158
|
|
|
151
159
|
# Returns the period as set by BrickletLinearPoti#set_analog_value_callback_period.
|
|
152
160
|
def get_analog_value_callback_period
|
|
153
|
-
|
|
161
|
+
check_validity
|
|
162
|
+
|
|
163
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
154
164
|
end
|
|
155
165
|
|
|
156
166
|
# Sets the thresholds for the CALLBACK_POSITION_REACHED callback.
|
|
@@ -164,15 +174,17 @@ module Tinkerforge
|
|
|
164
174
|
# "'i'", "Callback is triggered when the position is *inside* the min and max values"
|
|
165
175
|
# "'<'", "Callback is triggered when the position is smaller than the min value (max is ignored)"
|
|
166
176
|
# "'>'", "Callback is triggered when the position is greater than the min value (max is ignored)"
|
|
167
|
-
#
|
|
168
|
-
# The default value is ('x', 0, 0).
|
|
169
177
|
def set_position_callback_threshold(option, min, max)
|
|
170
|
-
|
|
178
|
+
check_validity
|
|
179
|
+
|
|
180
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
|
171
181
|
end
|
|
172
182
|
|
|
173
183
|
# Returns the threshold as set by BrickletLinearPoti#set_position_callback_threshold.
|
|
174
184
|
def get_position_callback_threshold
|
|
175
|
-
|
|
185
|
+
check_validity
|
|
186
|
+
|
|
187
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
|
176
188
|
end
|
|
177
189
|
|
|
178
190
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
|
@@ -186,18 +198,20 @@ module Tinkerforge
|
|
|
186
198
|
# "'i'", "Callback is triggered when the analog value is *inside* the min and max values"
|
|
187
199
|
# "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
|
|
188
200
|
# "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
|
|
189
|
-
#
|
|
190
|
-
# The default value is ('x', 0, 0).
|
|
191
201
|
def set_analog_value_callback_threshold(option, min, max)
|
|
192
|
-
|
|
202
|
+
check_validity
|
|
203
|
+
|
|
204
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
|
193
205
|
end
|
|
194
206
|
|
|
195
207
|
# Returns the threshold as set by BrickletLinearPoti#set_analog_value_callback_threshold.
|
|
196
208
|
def get_analog_value_callback_threshold
|
|
197
|
-
|
|
209
|
+
check_validity
|
|
210
|
+
|
|
211
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
|
198
212
|
end
|
|
199
213
|
|
|
200
|
-
# Sets the period
|
|
214
|
+
# Sets the period with which the threshold callbacks
|
|
201
215
|
#
|
|
202
216
|
# * CALLBACK_POSITION_REACHED,
|
|
203
217
|
# * CALLBACK_ANALOG_VALUE_REACHED
|
|
@@ -208,27 +222,31 @@ module Tinkerforge
|
|
|
208
222
|
# * BrickletLinearPoti#set_analog_value_callback_threshold
|
|
209
223
|
#
|
|
210
224
|
# keep being reached.
|
|
211
|
-
#
|
|
212
|
-
# The default value is 100.
|
|
213
225
|
def set_debounce_period(debounce)
|
|
214
|
-
|
|
226
|
+
check_validity
|
|
227
|
+
|
|
228
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
215
229
|
end
|
|
216
230
|
|
|
217
231
|
# Returns the debounce period as set by BrickletLinearPoti#set_debounce_period.
|
|
218
232
|
def get_debounce_period
|
|
219
|
-
|
|
233
|
+
check_validity
|
|
234
|
+
|
|
235
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
220
236
|
end
|
|
221
237
|
|
|
222
238
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
223
239
|
# the position, the hardware and firmware version as well as the
|
|
224
240
|
# device identifier.
|
|
225
241
|
#
|
|
226
|
-
# The position can be 'a', 'b', 'c' or '
|
|
242
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
243
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
244
|
+
# position 'z'.
|
|
227
245
|
#
|
|
228
246
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
229
247
|
# |device_identifier_constant|
|
|
230
248
|
def get_identity
|
|
231
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
249
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
232
250
|
end
|
|
233
251
|
|
|
234
252
|
# 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 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
|
# 59mm linear potentiometer
|
|
14
16
|
class BrickletLinearPotiV2 < Device
|
|
@@ -61,7 +63,7 @@ module Tinkerforge
|
|
|
61
63
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
62
64
|
# the IP Connection <tt>ipcon</tt>.
|
|
63
65
|
def initialize(uid, ipcon)
|
|
64
|
-
super uid, ipcon
|
|
66
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
65
67
|
|
|
66
68
|
@api_version = [2, 0, 0]
|
|
67
69
|
|
|
@@ -81,8 +83,9 @@ module Tinkerforge
|
|
|
81
83
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
82
84
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
83
85
|
|
|
84
|
-
@callback_formats[CALLBACK_POSITION] = 'C'
|
|
86
|
+
@callback_formats[CALLBACK_POSITION] = [9, 'C']
|
|
85
87
|
|
|
88
|
+
@ipcon.add_device self
|
|
86
89
|
end
|
|
87
90
|
|
|
88
91
|
# Returns the position of the linear potentiometer. The value is
|
|
@@ -93,10 +96,12 @@ module Tinkerforge
|
|
|
93
96
|
# CALLBACK_POSITION callback. You can set the callback configuration
|
|
94
97
|
# with BrickletLinearPotiV2#set_position_callback_configuration.
|
|
95
98
|
def get_position
|
|
96
|
-
|
|
99
|
+
check_validity
|
|
100
|
+
|
|
101
|
+
send_request FUNCTION_GET_POSITION, [], '', 9, 'C'
|
|
97
102
|
end
|
|
98
103
|
|
|
99
|
-
# The period
|
|
104
|
+
# The period is the period with which the CALLBACK_POSITION callback is triggered
|
|
100
105
|
# periodically. A value of 0 turns the callback off.
|
|
101
106
|
#
|
|
102
107
|
# If the `value has to change`-parameter is set to true, the callback is only
|
|
@@ -121,15 +126,17 @@ module Tinkerforge
|
|
|
121
126
|
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
|
122
127
|
#
|
|
123
128
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
124
|
-
#
|
|
125
|
-
# The default value is (0, false, 'x', 0, 0).
|
|
126
129
|
def set_position_callback_configuration(period, value_has_to_change, option, min, max)
|
|
127
|
-
|
|
130
|
+
check_validity
|
|
131
|
+
|
|
132
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k C C', 8, ''
|
|
128
133
|
end
|
|
129
134
|
|
|
130
135
|
# Returns the callback configuration as set by BrickletLinearPotiV2#set_position_callback_configuration.
|
|
131
136
|
def get_position_callback_configuration
|
|
132
|
-
|
|
137
|
+
check_validity
|
|
138
|
+
|
|
139
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 16, 'L ? k C C'
|
|
133
140
|
end
|
|
134
141
|
|
|
135
142
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -144,7 +151,9 @@ module Tinkerforge
|
|
|
144
151
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
145
152
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
146
153
|
def get_spitfp_error_count
|
|
147
|
-
|
|
154
|
+
check_validity
|
|
155
|
+
|
|
156
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
148
157
|
end
|
|
149
158
|
|
|
150
159
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -157,12 +166,16 @@ module Tinkerforge
|
|
|
157
166
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
158
167
|
# necessary to call it in a normal user program.
|
|
159
168
|
def set_bootloader_mode(mode)
|
|
160
|
-
|
|
169
|
+
check_validity
|
|
170
|
+
|
|
171
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
161
172
|
end
|
|
162
173
|
|
|
163
174
|
# Returns the current bootloader mode, see BrickletLinearPotiV2#set_bootloader_mode.
|
|
164
175
|
def get_bootloader_mode
|
|
165
|
-
|
|
176
|
+
check_validity
|
|
177
|
+
|
|
178
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
166
179
|
end
|
|
167
180
|
|
|
168
181
|
# Sets the firmware pointer for BrickletLinearPotiV2#write_firmware. The pointer has
|
|
@@ -172,7 +185,9 @@ module Tinkerforge
|
|
|
172
185
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
173
186
|
# necessary to call it in a normal user program.
|
|
174
187
|
def set_write_firmware_pointer(pointer)
|
|
175
|
-
|
|
188
|
+
check_validity
|
|
189
|
+
|
|
190
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
176
191
|
end
|
|
177
192
|
|
|
178
193
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -184,7 +199,9 @@ module Tinkerforge
|
|
|
184
199
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
185
200
|
# necessary to call it in a normal user program.
|
|
186
201
|
def write_firmware(data)
|
|
187
|
-
|
|
202
|
+
check_validity
|
|
203
|
+
|
|
204
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
188
205
|
end
|
|
189
206
|
|
|
190
207
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -195,22 +212,28 @@ module Tinkerforge
|
|
|
195
212
|
#
|
|
196
213
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
197
214
|
def set_status_led_config(config)
|
|
198
|
-
|
|
215
|
+
check_validity
|
|
216
|
+
|
|
217
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
199
218
|
end
|
|
200
219
|
|
|
201
220
|
# Returns the configuration as set by BrickletLinearPotiV2#set_status_led_config
|
|
202
221
|
def get_status_led_config
|
|
203
|
-
|
|
222
|
+
check_validity
|
|
223
|
+
|
|
224
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
204
225
|
end
|
|
205
226
|
|
|
206
|
-
# Returns the temperature
|
|
227
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
207
228
|
# value returned is not the ambient temperature!
|
|
208
229
|
#
|
|
209
230
|
# The temperature is only proportional to the real temperature and it has bad
|
|
210
231
|
# accuracy. Practically it is only useful as an indicator for
|
|
211
232
|
# temperature changes.
|
|
212
233
|
def get_chip_temperature
|
|
213
|
-
|
|
234
|
+
check_validity
|
|
235
|
+
|
|
236
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
214
237
|
end
|
|
215
238
|
|
|
216
239
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -220,7 +243,9 @@ module Tinkerforge
|
|
|
220
243
|
# calling functions on the existing ones will result in
|
|
221
244
|
# undefined behavior!
|
|
222
245
|
def reset
|
|
223
|
-
|
|
246
|
+
check_validity
|
|
247
|
+
|
|
248
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
224
249
|
end
|
|
225
250
|
|
|
226
251
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -229,25 +254,31 @@ module Tinkerforge
|
|
|
229
254
|
#
|
|
230
255
|
# We recommend that you use Brick Viewer to change the UID.
|
|
231
256
|
def write_uid(uid)
|
|
232
|
-
|
|
257
|
+
check_validity
|
|
258
|
+
|
|
259
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
233
260
|
end
|
|
234
261
|
|
|
235
262
|
# Returns the current UID as an integer. Encode as
|
|
236
263
|
# Base58 to get the usual string version.
|
|
237
264
|
def read_uid
|
|
238
|
-
|
|
265
|
+
check_validity
|
|
266
|
+
|
|
267
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
239
268
|
end
|
|
240
269
|
|
|
241
270
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
242
271
|
# the position, the hardware and firmware version as well as the
|
|
243
272
|
# device identifier.
|
|
244
273
|
#
|
|
245
|
-
# The position can be 'a', 'b', 'c' or '
|
|
274
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
275
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
276
|
+
# position 'z'.
|
|
246
277
|
#
|
|
247
278
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
248
279
|
# |device_identifier_constant|
|
|
249
280
|
def get_identity
|
|
250
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
281
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
251
282
|
end
|
|
252
283
|
|
|
253
284
|
# 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 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 weight with a load cell
|
|
14
16
|
class BrickletLoadCell < Device
|
|
@@ -63,7 +65,7 @@ module Tinkerforge
|
|
|
63
65
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
64
66
|
# the IP Connection <tt>ipcon</tt>.
|
|
65
67
|
def initialize(uid, ipcon)
|
|
66
|
-
super uid, ipcon
|
|
68
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
67
69
|
|
|
68
70
|
@api_version = [2, 0, 0]
|
|
69
71
|
|
|
@@ -85,34 +87,39 @@ module Tinkerforge
|
|
|
85
87
|
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
86
88
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
87
89
|
|
|
88
|
-
@callback_formats[CALLBACK_WEIGHT] = 'l'
|
|
89
|
-
@callback_formats[CALLBACK_WEIGHT_REACHED] = 'l'
|
|
90
|
+
@callback_formats[CALLBACK_WEIGHT] = [12, 'l']
|
|
91
|
+
@callback_formats[CALLBACK_WEIGHT_REACHED] = [12, 'l']
|
|
90
92
|
|
|
93
|
+
@ipcon.add_device self
|
|
91
94
|
end
|
|
92
95
|
|
|
93
|
-
# Returns the currently measured weight
|
|
96
|
+
# Returns the currently measured weight.
|
|
94
97
|
#
|
|
95
98
|
# If you want to get the weight periodically, it is recommended
|
|
96
99
|
# to use the CALLBACK_WEIGHT callback and set the period with
|
|
97
100
|
# BrickletLoadCell#set_weight_callback_period.
|
|
98
101
|
def get_weight
|
|
99
|
-
|
|
102
|
+
check_validity
|
|
103
|
+
|
|
104
|
+
send_request FUNCTION_GET_WEIGHT, [], '', 12, 'l'
|
|
100
105
|
end
|
|
101
106
|
|
|
102
|
-
# Sets the period
|
|
107
|
+
# Sets the period with which the CALLBACK_WEIGHT callback is triggered
|
|
103
108
|
# periodically. A value of 0 turns the callback off.
|
|
104
109
|
#
|
|
105
110
|
# The CALLBACK_WEIGHT callback is only triggered if the weight has changed since the
|
|
106
111
|
# last triggering.
|
|
107
|
-
#
|
|
108
|
-
# The default value is 0.
|
|
109
112
|
def set_weight_callback_period(period)
|
|
110
|
-
|
|
113
|
+
check_validity
|
|
114
|
+
|
|
115
|
+
send_request FUNCTION_SET_WEIGHT_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
111
116
|
end
|
|
112
117
|
|
|
113
118
|
# Returns the period as set by BrickletLoadCell#set_weight_callback_period.
|
|
114
119
|
def get_weight_callback_period
|
|
115
|
-
|
|
120
|
+
check_validity
|
|
121
|
+
|
|
122
|
+
send_request FUNCTION_GET_WEIGHT_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
116
123
|
end
|
|
117
124
|
|
|
118
125
|
# Sets the thresholds for the CALLBACK_WEIGHT_REACHED callback.
|
|
@@ -126,18 +133,20 @@ module Tinkerforge
|
|
|
126
133
|
# "'i'", "Callback is triggered when the weight is *inside* the min and max values"
|
|
127
134
|
# "'<'", "Callback is triggered when the weight is smaller than the min value (max is ignored)"
|
|
128
135
|
# "'>'", "Callback is triggered when the weight is greater than the min value (max is ignored)"
|
|
129
|
-
#
|
|
130
|
-
# The default value is ('x', 0, 0).
|
|
131
136
|
def set_weight_callback_threshold(option, min, max)
|
|
132
|
-
|
|
137
|
+
check_validity
|
|
138
|
+
|
|
139
|
+
send_request FUNCTION_SET_WEIGHT_CALLBACK_THRESHOLD, [option, min, max], 'k l l', 8, ''
|
|
133
140
|
end
|
|
134
141
|
|
|
135
142
|
# Returns the threshold as set by BrickletLoadCell#set_weight_callback_threshold.
|
|
136
143
|
def get_weight_callback_threshold
|
|
137
|
-
|
|
144
|
+
check_validity
|
|
145
|
+
|
|
146
|
+
send_request FUNCTION_GET_WEIGHT_CALLBACK_THRESHOLD, [], '', 17, 'k l l'
|
|
138
147
|
end
|
|
139
148
|
|
|
140
|
-
# Sets the period
|
|
149
|
+
# Sets the period with which the threshold callback
|
|
141
150
|
#
|
|
142
151
|
# * CALLBACK_WEIGHT_REACHED
|
|
143
152
|
#
|
|
@@ -146,15 +155,17 @@ module Tinkerforge
|
|
|
146
155
|
# * BrickletLoadCell#set_weight_callback_threshold
|
|
147
156
|
#
|
|
148
157
|
# keeps being reached.
|
|
149
|
-
#
|
|
150
|
-
# The default value is 100.
|
|
151
158
|
def set_debounce_period(debounce)
|
|
152
|
-
|
|
159
|
+
check_validity
|
|
160
|
+
|
|
161
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
153
162
|
end
|
|
154
163
|
|
|
155
164
|
# Returns the debounce period as set by BrickletLoadCell#set_debounce_period.
|
|
156
165
|
def get_debounce_period
|
|
157
|
-
|
|
166
|
+
check_validity
|
|
167
|
+
|
|
168
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
158
169
|
end
|
|
159
170
|
|
|
160
171
|
# Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
|
|
@@ -162,39 +173,44 @@ module Tinkerforge
|
|
|
162
173
|
#
|
|
163
174
|
# Setting the length to 1 will turn the averaging off. With less
|
|
164
175
|
# averaging, there is more noise on the data.
|
|
165
|
-
#
|
|
166
|
-
# The range for the averaging is 1-40.
|
|
167
|
-
#
|
|
168
|
-
# The default value is 4.
|
|
169
176
|
def set_moving_average(average)
|
|
170
|
-
|
|
177
|
+
check_validity
|
|
178
|
+
|
|
179
|
+
send_request FUNCTION_SET_MOVING_AVERAGE, [average], 'C', 8, ''
|
|
171
180
|
end
|
|
172
181
|
|
|
173
182
|
# Returns the length moving average as set by BrickletLoadCell#set_moving_average.
|
|
174
183
|
def get_moving_average
|
|
175
|
-
|
|
184
|
+
check_validity
|
|
185
|
+
|
|
186
|
+
send_request FUNCTION_GET_MOVING_AVERAGE, [], '', 9, 'C'
|
|
176
187
|
end
|
|
177
188
|
|
|
178
189
|
# Turns the LED on.
|
|
179
190
|
def led_on
|
|
180
|
-
|
|
191
|
+
check_validity
|
|
192
|
+
|
|
193
|
+
send_request FUNCTION_LED_ON, [], '', 8, ''
|
|
181
194
|
end
|
|
182
195
|
|
|
183
196
|
# Turns the LED off.
|
|
184
197
|
def led_off
|
|
185
|
-
|
|
198
|
+
check_validity
|
|
199
|
+
|
|
200
|
+
send_request FUNCTION_LED_OFF, [], '', 8, ''
|
|
186
201
|
end
|
|
187
202
|
|
|
188
203
|
# Returns *true* if the led is on, *false* otherwise.
|
|
189
204
|
def is_led_on
|
|
190
|
-
|
|
205
|
+
check_validity
|
|
206
|
+
|
|
207
|
+
send_request FUNCTION_IS_LED_ON, [], '', 9, '?'
|
|
191
208
|
end
|
|
192
209
|
|
|
193
210
|
# To calibrate your Load Cell Bricklet you have to
|
|
194
211
|
#
|
|
195
212
|
# * empty the scale and call this function with 0 and
|
|
196
|
-
# * add a known weight to the scale and call this function with the weight
|
|
197
|
-
# grams.
|
|
213
|
+
# * add a known weight to the scale and call this function with the weight.
|
|
198
214
|
#
|
|
199
215
|
# The calibration is saved in the EEPROM of the Bricklet and only
|
|
200
216
|
# needs to be done once.
|
|
@@ -202,12 +218,16 @@ module Tinkerforge
|
|
|
202
218
|
# We recommend to use the Brick Viewer for calibration, you don't need
|
|
203
219
|
# to call this function in your source code.
|
|
204
220
|
def calibrate(weight)
|
|
205
|
-
|
|
221
|
+
check_validity
|
|
222
|
+
|
|
223
|
+
send_request FUNCTION_CALIBRATE, [weight], 'L', 8, ''
|
|
206
224
|
end
|
|
207
225
|
|
|
208
226
|
# Sets the currently measured weight as tare weight.
|
|
209
227
|
def tare
|
|
210
|
-
|
|
228
|
+
check_validity
|
|
229
|
+
|
|
230
|
+
send_request FUNCTION_TARE, [], '', 8, ''
|
|
211
231
|
end
|
|
212
232
|
|
|
213
233
|
# The measurement rate and gain are configurable.
|
|
@@ -228,27 +248,31 @@ module Tinkerforge
|
|
|
228
248
|
#
|
|
229
249
|
# We recommend to use the Brick Viewer for configuration, you don't need
|
|
230
250
|
# to call this function in your source code.
|
|
231
|
-
#
|
|
232
|
-
# The default rate is 10Hz and the default gain is 128x.
|
|
233
251
|
def set_configuration(rate, gain)
|
|
234
|
-
|
|
252
|
+
check_validity
|
|
253
|
+
|
|
254
|
+
send_request FUNCTION_SET_CONFIGURATION, [rate, gain], 'C C', 8, ''
|
|
235
255
|
end
|
|
236
256
|
|
|
237
257
|
# Returns the configuration as set by BrickletLoadCell#set_configuration.
|
|
238
258
|
def get_configuration
|
|
239
|
-
|
|
259
|
+
check_validity
|
|
260
|
+
|
|
261
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
|
|
240
262
|
end
|
|
241
263
|
|
|
242
264
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
243
265
|
# the position, the hardware and firmware version as well as the
|
|
244
266
|
# device identifier.
|
|
245
267
|
#
|
|
246
|
-
# The position can be 'a', 'b', 'c' or '
|
|
268
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
269
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
270
|
+
# position 'z'.
|
|
247
271
|
#
|
|
248
272
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
249
273
|
# |device_identifier_constant|
|
|
250
274
|
def get_identity
|
|
251
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
275
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
252
276
|
end
|
|
253
277
|
|
|
254
278
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|