tinkerforge 2.1.24 → 2.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tinkerforge/brick_dc.rb +155 -74
- data/lib/tinkerforge/brick_hat.rb +70 -30
- data/lib/tinkerforge/brick_hat_zero.rb +56 -22
- data/lib/tinkerforge/brick_imu.rb +184 -77
- data/lib/tinkerforge/brick_imu_v2.rb +208 -105
- data/lib/tinkerforge/brick_master.rb +484 -182
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +185 -101
- data/lib/tinkerforge/brick_silent_stepper.rb +246 -166
- data/lib/tinkerforge/brick_stepper.rb +210 -98
- data/lib/tinkerforge/bricklet_accelerometer.rb +58 -23
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +105 -54
- data/lib/tinkerforge/bricklet_air_quality.rb +117 -59
- data/lib/tinkerforge/bricklet_ambient_light.rb +51 -21
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +40 -22
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -25
- data/lib/tinkerforge/bricklet_analog_in.rb +63 -25
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +57 -23
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +67 -25
- data/lib/tinkerforge/bricklet_analog_out.rb +23 -9
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +20 -8
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +54 -20
- data/lib/tinkerforge/bricklet_barometer.rb +66 -26
- data/lib/tinkerforge/bricklet_barometer_v2.rb +99 -37
- data/lib/tinkerforge/bricklet_can.rb +83 -18
- data/lib/tinkerforge/bricklet_can_v2.rb +172 -38
- data/lib/tinkerforge/bricklet_co2.rb +34 -14
- data/lib/tinkerforge/bricklet_co2_v2.rb +97 -37
- data/lib/tinkerforge/bricklet_color.rb +69 -27
- data/lib/tinkerforge/bricklet_color_v2.rb +87 -33
- data/lib/tinkerforge/bricklet_compass.rb +78 -30
- data/lib/tinkerforge/bricklet_current12.rb +58 -24
- data/lib/tinkerforge/bricklet_current25.rb +58 -24
- data/lib/tinkerforge/bricklet_distance_ir.rb +57 -23
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +83 -31
- data/lib/tinkerforge/bricklet_distance_us.rb +40 -16
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +67 -25
- data/lib/tinkerforge/bricklet_dmx.rb +88 -34
- data/lib/tinkerforge/bricklet_dual_button.rb +24 -10
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -24
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -11
- data/lib/tinkerforge/bricklet_dust_detector.rb +40 -16
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +88 -32
- data/lib/tinkerforge/bricklet_energy_monitor.rb +73 -27
- data/lib/tinkerforge/bricklet_gps.rb +64 -26
- data/lib/tinkerforge/bricklet_gps_v2.rb +117 -47
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -23
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +71 -27
- data/lib/tinkerforge/bricklet_humidity.rb +51 -21
- data/lib/tinkerforge/bricklet_humidity_v2.rb +83 -31
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +38 -14
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +81 -29
- data/lib/tinkerforge/bricklet_industrial_counter.rb +101 -39
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +45 -17
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +77 -29
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -14
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +73 -27
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +40 -16
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -29
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +49 -19
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +82 -30
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +61 -23
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -14
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -25
- data/lib/tinkerforge/bricklet_io16.rb +55 -21
- data/lib/tinkerforge/bricklet_io16_v2.rb +90 -34
- data/lib/tinkerforge/bricklet_io4.rb +55 -23
- data/lib/tinkerforge/bricklet_io4_v2.rb +96 -36
- data/lib/tinkerforge/bricklet_isolator.rb +72 -28
- data/lib/tinkerforge/bricklet_joystick.rb +59 -25
- data/lib/tinkerforge/bricklet_joystick_v2.rb +68 -26
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +82 -32
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +96 -36
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +192 -70
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +45 -18
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +58 -23
- data/lib/tinkerforge/bricklet_led_strip.rb +60 -22
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +91 -46
- data/lib/tinkerforge/bricklet_line.rb +34 -14
- data/lib/tinkerforge/bricklet_linear_poti.rb +51 -21
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -21
- data/lib/tinkerforge/bricklet_load_cell.rb +61 -23
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +80 -30
- data/lib/tinkerforge/bricklet_moisture.rb +40 -16
- data/lib/tinkerforge/bricklet_motion_detector.rb +22 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -24
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -27
- data/lib/tinkerforge/bricklet_multi_touch.rb +31 -13
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -28
- data/lib/tinkerforge/bricklet_nfc.rb +123 -58
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +33 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +29 -11
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +66 -24
- data/lib/tinkerforge/bricklet_oled_64x48.rb +29 -11
- data/lib/tinkerforge/bricklet_one_wire.rb +66 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -27
- data/lib/tinkerforge/bricklet_particulate_matter.rb +75 -30
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -9
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -10
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +80 -42
- data/lib/tinkerforge/bricklet_ptc.rb +74 -42
- data/lib/tinkerforge/bricklet_ptc_v2.rb +95 -48
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -33
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -44
- data/lib/tinkerforge/bricklet_remote_switch.rb +39 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +87 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +18 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +62 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +79 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +52 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +39 -19
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -24
- data/lib/tinkerforge/bricklet_rotary_poti.rb +53 -28
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -23
- data/lib/tinkerforge/bricklet_rs232.rb +90 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +118 -44
- data/lib/tinkerforge/bricklet_rs485.rb +223 -95
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +25 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -35
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +25 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +59 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +35 -18
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +72 -31
- data/lib/tinkerforge/bricklet_temperature.rb +40 -16
- data/lib/tinkerforge/bricklet_temperature_ir.rb +57 -23
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +71 -27
- data/lib/tinkerforge/bricklet_temperature_v2.rb +61 -25
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +105 -44
- data/lib/tinkerforge/bricklet_thermocouple.rb +45 -24
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -27
- data/lib/tinkerforge/bricklet_tilt.rb +24 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +36 -18
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +85 -37
- data/lib/tinkerforge/bricklet_voltage.rb +52 -28
- data/lib/tinkerforge/bricklet_voltage_current.rb +91 -73
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +90 -68
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +80 -30
- data/lib/tinkerforge/device_display_names.rb +163 -0
- data/lib/tinkerforge/ip_connection.rb +151 -32
- data/lib/tinkerforge/version.rb +1 -1
- metadata +3 -2
|
@@ -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-04-07. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
|
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,12 +98,13 @@ 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
110
|
# Returns the current of the sensor.
|
|
@@ -110,7 +113,9 @@ module Tinkerforge
|
|
|
110
113
|
# CALLBACK_CURRENT callback and set the period with
|
|
111
114
|
# BrickletCurrent12#set_current_callback_period.
|
|
112
115
|
def get_current
|
|
113
|
-
|
|
116
|
+
check_validity
|
|
117
|
+
|
|
118
|
+
send_request FUNCTION_GET_CURRENT, [], '', 10, 's'
|
|
114
119
|
end
|
|
115
120
|
|
|
116
121
|
# Calibrates the 0 value of the sensor. You have to call this function
|
|
@@ -125,7 +130,9 @@ module Tinkerforge
|
|
|
125
130
|
# The resulting calibration will be saved on the EEPROM of the Current
|
|
126
131
|
# Bricklet.
|
|
127
132
|
def calibrate
|
|
128
|
-
|
|
133
|
+
check_validity
|
|
134
|
+
|
|
135
|
+
send_request FUNCTION_CALIBRATE, [], '', 8, ''
|
|
129
136
|
end
|
|
130
137
|
|
|
131
138
|
# Returns *true* if more than 12.5A were measured.
|
|
@@ -133,7 +140,9 @@ module Tinkerforge
|
|
|
133
140
|
# .. note::
|
|
134
141
|
# To reset this value you have to power cycle the Bricklet.
|
|
135
142
|
def is_over_current
|
|
136
|
-
|
|
143
|
+
check_validity
|
|
144
|
+
|
|
145
|
+
send_request FUNCTION_IS_OVER_CURRENT, [], '', 9, '?'
|
|
137
146
|
end
|
|
138
147
|
|
|
139
148
|
# Returns the value as read by a 12-bit analog-to-digital converter.
|
|
@@ -148,7 +157,9 @@ module Tinkerforge
|
|
|
148
157
|
# CALLBACK_ANALOG_VALUE callback and set the period with
|
|
149
158
|
# BrickletCurrent12#set_analog_value_callback_period.
|
|
150
159
|
def get_analog_value
|
|
151
|
-
|
|
160
|
+
check_validity
|
|
161
|
+
|
|
162
|
+
send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
|
|
152
163
|
end
|
|
153
164
|
|
|
154
165
|
# Sets the period with which the CALLBACK_CURRENT callback is triggered
|
|
@@ -157,12 +168,16 @@ module Tinkerforge
|
|
|
157
168
|
# The CALLBACK_CURRENT callback is only triggered if the current has changed since
|
|
158
169
|
# the last triggering.
|
|
159
170
|
def set_current_callback_period(period)
|
|
160
|
-
|
|
171
|
+
check_validity
|
|
172
|
+
|
|
173
|
+
send_request FUNCTION_SET_CURRENT_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
161
174
|
end
|
|
162
175
|
|
|
163
176
|
# Returns the period as set by BrickletCurrent12#set_current_callback_period.
|
|
164
177
|
def get_current_callback_period
|
|
165
|
-
|
|
178
|
+
check_validity
|
|
179
|
+
|
|
180
|
+
send_request FUNCTION_GET_CURRENT_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
166
181
|
end
|
|
167
182
|
|
|
168
183
|
# Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
|
|
@@ -171,12 +186,16 @@ module Tinkerforge
|
|
|
171
186
|
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
|
172
187
|
# changed since the last triggering.
|
|
173
188
|
def set_analog_value_callback_period(period)
|
|
174
|
-
|
|
189
|
+
check_validity
|
|
190
|
+
|
|
191
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
175
192
|
end
|
|
176
193
|
|
|
177
194
|
# Returns the period as set by BrickletCurrent12#set_analog_value_callback_period.
|
|
178
195
|
def get_analog_value_callback_period
|
|
179
|
-
|
|
196
|
+
check_validity
|
|
197
|
+
|
|
198
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
180
199
|
end
|
|
181
200
|
|
|
182
201
|
# Sets the thresholds for the CALLBACK_CURRENT_REACHED callback.
|
|
@@ -191,12 +210,16 @@ module Tinkerforge
|
|
|
191
210
|
# "'<'", "Callback is triggered when the current is smaller than the min value (max is ignored)"
|
|
192
211
|
# "'>'", "Callback is triggered when the current is greater than the min value (max is ignored)"
|
|
193
212
|
def set_current_callback_threshold(option, min, max)
|
|
194
|
-
|
|
213
|
+
check_validity
|
|
214
|
+
|
|
215
|
+
send_request FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 8, ''
|
|
195
216
|
end
|
|
196
217
|
|
|
197
218
|
# Returns the threshold as set by BrickletCurrent12#set_current_callback_threshold.
|
|
198
219
|
def get_current_callback_threshold
|
|
199
|
-
|
|
220
|
+
check_validity
|
|
221
|
+
|
|
222
|
+
send_request FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD, [], '', 13, 'k s s'
|
|
200
223
|
end
|
|
201
224
|
|
|
202
225
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
|
@@ -211,12 +234,16 @@ module Tinkerforge
|
|
|
211
234
|
# "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
|
|
212
235
|
# "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
|
|
213
236
|
def set_analog_value_callback_threshold(option, min, max)
|
|
214
|
-
|
|
237
|
+
check_validity
|
|
238
|
+
|
|
239
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
|
215
240
|
end
|
|
216
241
|
|
|
217
242
|
# Returns the threshold as set by BrickletCurrent12#set_analog_value_callback_threshold.
|
|
218
243
|
def get_analog_value_callback_threshold
|
|
219
|
-
|
|
244
|
+
check_validity
|
|
245
|
+
|
|
246
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
|
220
247
|
end
|
|
221
248
|
|
|
222
249
|
# Sets the period with which the threshold callbacks
|
|
@@ -231,24 +258,31 @@ module Tinkerforge
|
|
|
231
258
|
#
|
|
232
259
|
# keep being reached.
|
|
233
260
|
def set_debounce_period(debounce)
|
|
234
|
-
|
|
261
|
+
check_validity
|
|
262
|
+
|
|
263
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
235
264
|
end
|
|
236
265
|
|
|
237
266
|
# Returns the debounce period as set by BrickletCurrent12#set_debounce_period.
|
|
238
267
|
def get_debounce_period
|
|
239
|
-
|
|
268
|
+
check_validity
|
|
269
|
+
|
|
270
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
240
271
|
end
|
|
241
272
|
|
|
242
273
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
243
274
|
# the position, the hardware and firmware version as well as the
|
|
244
275
|
# device identifier.
|
|
245
276
|
#
|
|
246
|
-
# 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
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
279
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
280
|
+
# position 'z'.
|
|
247
281
|
#
|
|
248
282
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
249
283
|
# |device_identifier_constant|
|
|
250
284
|
def get_identity
|
|
251
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
285
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
252
286
|
end
|
|
253
287
|
|
|
254
288
|
# 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-04-07. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
|
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 -25A and +25A
|
|
14
16
|
class BrickletCurrent25 < 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,12 +98,13 @@ 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
110
|
# Returns the current of the sensor.
|
|
@@ -110,7 +113,9 @@ module Tinkerforge
|
|
|
110
113
|
# CALLBACK_CURRENT callback and set the period with
|
|
111
114
|
# BrickletCurrent25#set_current_callback_period.
|
|
112
115
|
def get_current
|
|
113
|
-
|
|
116
|
+
check_validity
|
|
117
|
+
|
|
118
|
+
send_request FUNCTION_GET_CURRENT, [], '', 10, 's'
|
|
114
119
|
end
|
|
115
120
|
|
|
116
121
|
# Calibrates the 0 value of the sensor. You have to call this function
|
|
@@ -125,7 +130,9 @@ module Tinkerforge
|
|
|
125
130
|
# The resulting calibration will be saved on the EEPROM of the Current
|
|
126
131
|
# Bricklet.
|
|
127
132
|
def calibrate
|
|
128
|
-
|
|
133
|
+
check_validity
|
|
134
|
+
|
|
135
|
+
send_request FUNCTION_CALIBRATE, [], '', 8, ''
|
|
129
136
|
end
|
|
130
137
|
|
|
131
138
|
# Returns *true* if more than 25A were measured.
|
|
@@ -133,7 +140,9 @@ module Tinkerforge
|
|
|
133
140
|
# .. note::
|
|
134
141
|
# To reset this value you have to power cycle the Bricklet.
|
|
135
142
|
def is_over_current
|
|
136
|
-
|
|
143
|
+
check_validity
|
|
144
|
+
|
|
145
|
+
send_request FUNCTION_IS_OVER_CURRENT, [], '', 9, '?'
|
|
137
146
|
end
|
|
138
147
|
|
|
139
148
|
# Returns the value as read by a 12-bit analog-to-digital converter.
|
|
@@ -148,7 +157,9 @@ module Tinkerforge
|
|
|
148
157
|
# CALLBACK_ANALOG_VALUE callback and set the period with
|
|
149
158
|
# BrickletCurrent25#set_analog_value_callback_period.
|
|
150
159
|
def get_analog_value
|
|
151
|
-
|
|
160
|
+
check_validity
|
|
161
|
+
|
|
162
|
+
send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
|
|
152
163
|
end
|
|
153
164
|
|
|
154
165
|
# Sets the period with which the CALLBACK_CURRENT callback is triggered
|
|
@@ -157,12 +168,16 @@ module Tinkerforge
|
|
|
157
168
|
# The CALLBACK_CURRENT callback is only triggered if the current has changed since
|
|
158
169
|
# the last triggering.
|
|
159
170
|
def set_current_callback_period(period)
|
|
160
|
-
|
|
171
|
+
check_validity
|
|
172
|
+
|
|
173
|
+
send_request FUNCTION_SET_CURRENT_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
161
174
|
end
|
|
162
175
|
|
|
163
176
|
# Returns the period as set by BrickletCurrent25#set_current_callback_period.
|
|
164
177
|
def get_current_callback_period
|
|
165
|
-
|
|
178
|
+
check_validity
|
|
179
|
+
|
|
180
|
+
send_request FUNCTION_GET_CURRENT_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
166
181
|
end
|
|
167
182
|
|
|
168
183
|
# Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
|
|
@@ -171,12 +186,16 @@ module Tinkerforge
|
|
|
171
186
|
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
|
172
187
|
# changed since the last triggering.
|
|
173
188
|
def set_analog_value_callback_period(period)
|
|
174
|
-
|
|
189
|
+
check_validity
|
|
190
|
+
|
|
191
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
175
192
|
end
|
|
176
193
|
|
|
177
194
|
# Returns the period as set by BrickletCurrent25#set_analog_value_callback_period.
|
|
178
195
|
def get_analog_value_callback_period
|
|
179
|
-
|
|
196
|
+
check_validity
|
|
197
|
+
|
|
198
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
180
199
|
end
|
|
181
200
|
|
|
182
201
|
# Sets the thresholds for the CALLBACK_CURRENT_REACHED callback.
|
|
@@ -191,12 +210,16 @@ module Tinkerforge
|
|
|
191
210
|
# "'<'", "Callback is triggered when the current is smaller than the min value (max is ignored)"
|
|
192
211
|
# "'>'", "Callback is triggered when the current is greater than the min value (max is ignored)"
|
|
193
212
|
def set_current_callback_threshold(option, min, max)
|
|
194
|
-
|
|
213
|
+
check_validity
|
|
214
|
+
|
|
215
|
+
send_request FUNCTION_SET_CURRENT_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 8, ''
|
|
195
216
|
end
|
|
196
217
|
|
|
197
218
|
# Returns the threshold as set by BrickletCurrent25#set_current_callback_threshold.
|
|
198
219
|
def get_current_callback_threshold
|
|
199
|
-
|
|
220
|
+
check_validity
|
|
221
|
+
|
|
222
|
+
send_request FUNCTION_GET_CURRENT_CALLBACK_THRESHOLD, [], '', 13, 'k s s'
|
|
200
223
|
end
|
|
201
224
|
|
|
202
225
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
|
@@ -211,12 +234,16 @@ module Tinkerforge
|
|
|
211
234
|
# "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
|
|
212
235
|
# "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
|
|
213
236
|
def set_analog_value_callback_threshold(option, min, max)
|
|
214
|
-
|
|
237
|
+
check_validity
|
|
238
|
+
|
|
239
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
|
215
240
|
end
|
|
216
241
|
|
|
217
242
|
# Returns the threshold as set by BrickletCurrent25#set_analog_value_callback_threshold.
|
|
218
243
|
def get_analog_value_callback_threshold
|
|
219
|
-
|
|
244
|
+
check_validity
|
|
245
|
+
|
|
246
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
|
220
247
|
end
|
|
221
248
|
|
|
222
249
|
# Sets the period with which the threshold callbacks
|
|
@@ -231,24 +258,31 @@ module Tinkerforge
|
|
|
231
258
|
#
|
|
232
259
|
# keep being reached.
|
|
233
260
|
def set_debounce_period(debounce)
|
|
234
|
-
|
|
261
|
+
check_validity
|
|
262
|
+
|
|
263
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
235
264
|
end
|
|
236
265
|
|
|
237
266
|
# Returns the debounce period as set by BrickletCurrent25#set_debounce_period.
|
|
238
267
|
def get_debounce_period
|
|
239
|
-
|
|
268
|
+
check_validity
|
|
269
|
+
|
|
270
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
240
271
|
end
|
|
241
272
|
|
|
242
273
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
243
274
|
# the position, the hardware and firmware version as well as the
|
|
244
275
|
# device identifier.
|
|
245
276
|
#
|
|
246
|
-
# 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
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
279
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
280
|
+
# position 'z'.
|
|
247
281
|
#
|
|
248
282
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
249
283
|
# |device_identifier_constant|
|
|
250
284
|
def get_identity
|
|
251
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
285
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
252
286
|
end
|
|
253
287
|
|
|
254
288
|
# 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-04-07. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
|
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 distance up to 150cm with infrared light
|
|
14
16
|
class BrickletDistanceIR < Device
|
|
@@ -72,7 +74,7 @@ module Tinkerforge
|
|
|
72
74
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
73
75
|
# the IP Connection <tt>ipcon</tt>.
|
|
74
76
|
def initialize(uid, ipcon)
|
|
75
|
-
super uid, ipcon
|
|
77
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
76
78
|
|
|
77
79
|
@api_version = [2, 0, 1]
|
|
78
80
|
|
|
@@ -92,11 +94,12 @@ module Tinkerforge
|
|
|
92
94
|
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
93
95
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
94
96
|
|
|
95
|
-
@callback_formats[CALLBACK_DISTANCE] = 'S'
|
|
96
|
-
@callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
|
|
97
|
-
@callback_formats[CALLBACK_DISTANCE_REACHED] = 'S'
|
|
98
|
-
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
|
|
97
|
+
@callback_formats[CALLBACK_DISTANCE] = [10, 'S']
|
|
98
|
+
@callback_formats[CALLBACK_ANALOG_VALUE] = [10, 'S']
|
|
99
|
+
@callback_formats[CALLBACK_DISTANCE_REACHED] = [10, 'S']
|
|
100
|
+
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [10, 'S']
|
|
99
101
|
|
|
102
|
+
@ipcon.add_device self
|
|
100
103
|
end
|
|
101
104
|
|
|
102
105
|
# Returns the distance measured by the sensor. Possible
|
|
@@ -107,7 +110,9 @@ module Tinkerforge
|
|
|
107
110
|
# CALLBACK_DISTANCE callback and set the period with
|
|
108
111
|
# BrickletDistanceIR#set_distance_callback_period.
|
|
109
112
|
def get_distance
|
|
110
|
-
|
|
113
|
+
check_validity
|
|
114
|
+
|
|
115
|
+
send_request FUNCTION_GET_DISTANCE, [], '', 10, 'S'
|
|
111
116
|
end
|
|
112
117
|
|
|
113
118
|
# Returns the value as read by a 12-bit analog-to-digital converter.
|
|
@@ -122,7 +127,9 @@ module Tinkerforge
|
|
|
122
127
|
# CALLBACK_ANALOG_VALUE callback and set the period with
|
|
123
128
|
# BrickletDistanceIR#set_analog_value_callback_period.
|
|
124
129
|
def get_analog_value
|
|
125
|
-
|
|
130
|
+
check_validity
|
|
131
|
+
|
|
132
|
+
send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
|
|
126
133
|
end
|
|
127
134
|
|
|
128
135
|
# Sets a sampling point value to a specific position of the lookup table.
|
|
@@ -144,13 +151,17 @@ module Tinkerforge
|
|
|
144
151
|
# implemented in the Brick Viewer. If you want to calibrate your Bricklet it is
|
|
145
152
|
# highly recommended to use this implementation.
|
|
146
153
|
def set_sampling_point(position, distance)
|
|
147
|
-
|
|
154
|
+
check_validity
|
|
155
|
+
|
|
156
|
+
send_request FUNCTION_SET_SAMPLING_POINT, [position, distance], 'C S', 8, ''
|
|
148
157
|
end
|
|
149
158
|
|
|
150
159
|
# Returns the distance to a sampling point position as set by
|
|
151
160
|
# BrickletDistanceIR#set_sampling_point.
|
|
152
161
|
def get_sampling_point(position)
|
|
153
|
-
|
|
162
|
+
check_validity
|
|
163
|
+
|
|
164
|
+
send_request FUNCTION_GET_SAMPLING_POINT, [position], 'C', 10, 'S'
|
|
154
165
|
end
|
|
155
166
|
|
|
156
167
|
# Sets the period with which the CALLBACK_DISTANCE callback is triggered
|
|
@@ -159,12 +170,16 @@ module Tinkerforge
|
|
|
159
170
|
# The CALLBACK_DISTANCE callback is only triggered if the distance has changed since the
|
|
160
171
|
# last triggering.
|
|
161
172
|
def set_distance_callback_period(period)
|
|
162
|
-
|
|
173
|
+
check_validity
|
|
174
|
+
|
|
175
|
+
send_request FUNCTION_SET_DISTANCE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
163
176
|
end
|
|
164
177
|
|
|
165
178
|
# Returns the period as set by BrickletDistanceIR#set_distance_callback_period.
|
|
166
179
|
def get_distance_callback_period
|
|
167
|
-
|
|
180
|
+
check_validity
|
|
181
|
+
|
|
182
|
+
send_request FUNCTION_GET_DISTANCE_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
168
183
|
end
|
|
169
184
|
|
|
170
185
|
# Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
|
|
@@ -173,12 +188,16 @@ module Tinkerforge
|
|
|
173
188
|
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
|
174
189
|
# changed since the last triggering.
|
|
175
190
|
def set_analog_value_callback_period(period)
|
|
176
|
-
|
|
191
|
+
check_validity
|
|
192
|
+
|
|
193
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
177
194
|
end
|
|
178
195
|
|
|
179
196
|
# Returns the period as set by BrickletDistanceIR#set_analog_value_callback_period.
|
|
180
197
|
def get_analog_value_callback_period
|
|
181
|
-
|
|
198
|
+
check_validity
|
|
199
|
+
|
|
200
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
182
201
|
end
|
|
183
202
|
|
|
184
203
|
# Sets the thresholds for the CALLBACK_DISTANCE_REACHED callback.
|
|
@@ -193,12 +212,16 @@ module Tinkerforge
|
|
|
193
212
|
# "'<'", "Callback is triggered when the distance is smaller than the min value (max is ignored)"
|
|
194
213
|
# "'>'", "Callback is triggered when the distance is greater than the min value (max is ignored)"
|
|
195
214
|
def set_distance_callback_threshold(option, min, max)
|
|
196
|
-
|
|
215
|
+
check_validity
|
|
216
|
+
|
|
217
|
+
send_request FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
|
197
218
|
end
|
|
198
219
|
|
|
199
220
|
# Returns the threshold as set by BrickletDistanceIR#set_distance_callback_threshold.
|
|
200
221
|
def get_distance_callback_threshold
|
|
201
|
-
|
|
222
|
+
check_validity
|
|
223
|
+
|
|
224
|
+
send_request FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
|
202
225
|
end
|
|
203
226
|
|
|
204
227
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
|
@@ -213,12 +236,16 @@ module Tinkerforge
|
|
|
213
236
|
# "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
|
|
214
237
|
# "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
|
|
215
238
|
def set_analog_value_callback_threshold(option, min, max)
|
|
216
|
-
|
|
239
|
+
check_validity
|
|
240
|
+
|
|
241
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
|
217
242
|
end
|
|
218
243
|
|
|
219
244
|
# Returns the threshold as set by BrickletDistanceIR#set_analog_value_callback_threshold.
|
|
220
245
|
def get_analog_value_callback_threshold
|
|
221
|
-
|
|
246
|
+
check_validity
|
|
247
|
+
|
|
248
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
|
222
249
|
end
|
|
223
250
|
|
|
224
251
|
# Sets the period with which the threshold callbacks
|
|
@@ -233,24 +260,31 @@ module Tinkerforge
|
|
|
233
260
|
#
|
|
234
261
|
# keep being reached.
|
|
235
262
|
def set_debounce_period(debounce)
|
|
236
|
-
|
|
263
|
+
check_validity
|
|
264
|
+
|
|
265
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
237
266
|
end
|
|
238
267
|
|
|
239
268
|
# Returns the debounce period as set by BrickletDistanceIR#set_debounce_period.
|
|
240
269
|
def get_debounce_period
|
|
241
|
-
|
|
270
|
+
check_validity
|
|
271
|
+
|
|
272
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
242
273
|
end
|
|
243
274
|
|
|
244
275
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
245
276
|
# the position, the hardware and firmware version as well as the
|
|
246
277
|
# device identifier.
|
|
247
278
|
#
|
|
248
|
-
# The position can be 'a', 'b', 'c' or '
|
|
279
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
280
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
281
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
282
|
+
# position 'z'.
|
|
249
283
|
#
|
|
250
284
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
251
285
|
# |device_identifier_constant|
|
|
252
286
|
def get_identity
|
|
253
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
287
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
254
288
|
end
|
|
255
289
|
|
|
256
290
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|