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
|
# 16-channel digital input/output
|
|
14
16
|
class BrickletIO16V2 < Device
|
|
@@ -87,7 +89,7 @@ module Tinkerforge
|
|
|
87
89
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
88
90
|
# the IP Connection <tt>ipcon</tt>.
|
|
89
91
|
def initialize(uid, ipcon)
|
|
90
|
-
super uid, ipcon
|
|
92
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
91
93
|
|
|
92
94
|
@api_version = [2, 0, 0]
|
|
93
95
|
|
|
@@ -118,10 +120,11 @@ module Tinkerforge
|
|
|
118
120
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
119
121
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
120
122
|
|
|
121
|
-
@callback_formats[CALLBACK_INPUT_VALUE] = 'C ? ?'
|
|
122
|
-
@callback_formats[CALLBACK_ALL_INPUT_VALUE] = '?16 ?16'
|
|
123
|
-
@callback_formats[CALLBACK_MONOFLOP_DONE] = 'C ?'
|
|
123
|
+
@callback_formats[CALLBACK_INPUT_VALUE] = [11, 'C ? ?']
|
|
124
|
+
@callback_formats[CALLBACK_ALL_INPUT_VALUE] = [12, '?16 ?16']
|
|
125
|
+
@callback_formats[CALLBACK_MONOFLOP_DONE] = [10, 'C ?']
|
|
124
126
|
|
|
127
|
+
@ipcon.add_device self
|
|
125
128
|
end
|
|
126
129
|
|
|
127
130
|
# Sets the output value of all sixteen channels. A value of *true* or *false* outputs
|
|
@@ -138,14 +141,18 @@ module Tinkerforge
|
|
|
138
141
|
# This function does nothing for channels that are configured as input. Pull-up
|
|
139
142
|
# resistors can be switched on with BrickletIO16V2#set_configuration.
|
|
140
143
|
def set_value(value)
|
|
141
|
-
|
|
144
|
+
check_validity
|
|
145
|
+
|
|
146
|
+
send_request FUNCTION_SET_VALUE, [value], '?16', 8, ''
|
|
142
147
|
end
|
|
143
148
|
|
|
144
149
|
# Returns the logic levels that are currently measured on the channels.
|
|
145
150
|
# This function works if the channel is configured as input as well as if it is
|
|
146
151
|
# configured as output.
|
|
147
152
|
def get_value
|
|
148
|
-
|
|
153
|
+
check_validity
|
|
154
|
+
|
|
155
|
+
send_request FUNCTION_GET_VALUE, [], '', 10, '?16'
|
|
149
156
|
end
|
|
150
157
|
|
|
151
158
|
# Sets the output value of a specific channel without affecting the other channels.
|
|
@@ -157,7 +164,9 @@ module Tinkerforge
|
|
|
157
164
|
# This function does nothing for channels that are configured as input. Pull-up
|
|
158
165
|
# resistors can be switched on with BrickletIO16V2#set_configuration.
|
|
159
166
|
def set_selected_value(channel, value)
|
|
160
|
-
|
|
167
|
+
check_validity
|
|
168
|
+
|
|
169
|
+
send_request FUNCTION_SET_SELECTED_VALUE, [channel, value], 'C ?', 8, ''
|
|
161
170
|
end
|
|
162
171
|
|
|
163
172
|
# Configures the value and direction of a specific channel. Possible directions
|
|
@@ -179,12 +188,16 @@ module Tinkerforge
|
|
|
179
188
|
# A running monoflop timer for the specific channel will be aborted if this
|
|
180
189
|
# function is called.
|
|
181
190
|
def set_configuration(channel, direction, value)
|
|
182
|
-
|
|
191
|
+
check_validity
|
|
192
|
+
|
|
193
|
+
send_request FUNCTION_SET_CONFIGURATION, [channel, direction, value], 'C k ?', 8, ''
|
|
183
194
|
end
|
|
184
195
|
|
|
185
196
|
# Returns the channel configuration as set by BrickletIO16V2#set_configuration.
|
|
186
197
|
def get_configuration(channel)
|
|
187
|
-
|
|
198
|
+
check_validity
|
|
199
|
+
|
|
200
|
+
send_request FUNCTION_GET_CONFIGURATION, [channel], 'C', 10, 'k ?'
|
|
188
201
|
end
|
|
189
202
|
|
|
190
203
|
# This callback can be configured per channel.
|
|
@@ -199,13 +212,17 @@ module Tinkerforge
|
|
|
199
212
|
# If it is set to false, the callback is continuously triggered with the period,
|
|
200
213
|
# independent of the value.
|
|
201
214
|
def set_input_value_callback_configuration(channel, period, value_has_to_change)
|
|
202
|
-
|
|
215
|
+
check_validity
|
|
216
|
+
|
|
217
|
+
send_request FUNCTION_SET_INPUT_VALUE_CALLBACK_CONFIGURATION, [channel, period, value_has_to_change], 'C L ?', 8, ''
|
|
203
218
|
end
|
|
204
219
|
|
|
205
220
|
# Returns the callback configuration as set by
|
|
206
221
|
# BrickletIO16V2#set_input_value_callback_configuration.
|
|
207
222
|
def get_input_value_callback_configuration(channel)
|
|
208
|
-
|
|
223
|
+
check_validity
|
|
224
|
+
|
|
225
|
+
send_request FUNCTION_GET_INPUT_VALUE_CALLBACK_CONFIGURATION, [channel], 'C', 13, 'L ?'
|
|
209
226
|
end
|
|
210
227
|
|
|
211
228
|
# The period is the period with which the CALLBACK_ALL_INPUT_VALUE
|
|
@@ -218,13 +235,17 @@ module Tinkerforge
|
|
|
218
235
|
# If it is set to false, the callback is continuously triggered with the period,
|
|
219
236
|
# independent of the value.
|
|
220
237
|
def set_all_input_value_callback_configuration(period, value_has_to_change)
|
|
221
|
-
|
|
238
|
+
check_validity
|
|
239
|
+
|
|
240
|
+
send_request FUNCTION_SET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
222
241
|
end
|
|
223
242
|
|
|
224
243
|
# Returns the callback configuration as set by
|
|
225
244
|
# BrickletIO16V2#set_all_input_value_callback_configuration.
|
|
226
245
|
def get_all_input_value_callback_configuration
|
|
227
|
-
|
|
246
|
+
check_validity
|
|
247
|
+
|
|
248
|
+
send_request FUNCTION_GET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
228
249
|
end
|
|
229
250
|
|
|
230
251
|
# Configures a monoflop of the specified channel.
|
|
@@ -245,7 +266,9 @@ module Tinkerforge
|
|
|
245
266
|
# time. If now the RS485 connection is lost, then channel 0 will be opened in at
|
|
246
267
|
# most two seconds.
|
|
247
268
|
def set_monoflop(channel, value, time)
|
|
248
|
-
|
|
269
|
+
check_validity
|
|
270
|
+
|
|
271
|
+
send_request FUNCTION_SET_MONOFLOP, [channel, value, time], 'C ? L', 8, ''
|
|
249
272
|
end
|
|
250
273
|
|
|
251
274
|
# Returns (for the given channel) the current value and the time as set by
|
|
@@ -254,7 +277,9 @@ module Tinkerforge
|
|
|
254
277
|
# If the timer is not running currently, the remaining time will be returned
|
|
255
278
|
# as 0.
|
|
256
279
|
def get_monoflop(channel)
|
|
257
|
-
|
|
280
|
+
check_validity
|
|
281
|
+
|
|
282
|
+
send_request FUNCTION_GET_MONOFLOP, [channel], 'C', 17, '? L L'
|
|
258
283
|
end
|
|
259
284
|
|
|
260
285
|
# Returns the current value of the edge counter for the selected channel. You can
|
|
@@ -263,7 +288,9 @@ module Tinkerforge
|
|
|
263
288
|
# If you set the reset counter to *true*, the count is set back to 0
|
|
264
289
|
# directly after it is read.
|
|
265
290
|
def get_edge_count(channel, reset_counter)
|
|
266
|
-
|
|
291
|
+
check_validity
|
|
292
|
+
|
|
293
|
+
send_request FUNCTION_GET_EDGE_COUNT, [channel, reset_counter], 'C ?', 12, 'L'
|
|
267
294
|
end
|
|
268
295
|
|
|
269
296
|
# Configures the edge counter for a specific channel.
|
|
@@ -280,13 +307,17 @@ module Tinkerforge
|
|
|
280
307
|
# If you don't know what any of this means, just leave it at default. The
|
|
281
308
|
# default configuration is very likely OK for you.
|
|
282
309
|
def set_edge_count_configuration(channel, edge_type, debounce)
|
|
283
|
-
|
|
310
|
+
check_validity
|
|
311
|
+
|
|
312
|
+
send_request FUNCTION_SET_EDGE_COUNT_CONFIGURATION, [channel, edge_type, debounce], 'C C C', 8, ''
|
|
284
313
|
end
|
|
285
314
|
|
|
286
315
|
# Returns the edge type and debounce time for the selected channel as set by
|
|
287
316
|
# BrickletIO16V2#set_edge_count_configuration.
|
|
288
317
|
def get_edge_count_configuration(channel)
|
|
289
|
-
|
|
318
|
+
check_validity
|
|
319
|
+
|
|
320
|
+
send_request FUNCTION_GET_EDGE_COUNT_CONFIGURATION, [channel], 'C', 10, 'C C'
|
|
290
321
|
end
|
|
291
322
|
|
|
292
323
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -301,7 +332,9 @@ module Tinkerforge
|
|
|
301
332
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
302
333
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
303
334
|
def get_spitfp_error_count
|
|
304
|
-
|
|
335
|
+
check_validity
|
|
336
|
+
|
|
337
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
305
338
|
end
|
|
306
339
|
|
|
307
340
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -314,12 +347,16 @@ module Tinkerforge
|
|
|
314
347
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
315
348
|
# necessary to call it in a normal user program.
|
|
316
349
|
def set_bootloader_mode(mode)
|
|
317
|
-
|
|
350
|
+
check_validity
|
|
351
|
+
|
|
352
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
318
353
|
end
|
|
319
354
|
|
|
320
355
|
# Returns the current bootloader mode, see BrickletIO16V2#set_bootloader_mode.
|
|
321
356
|
def get_bootloader_mode
|
|
322
|
-
|
|
357
|
+
check_validity
|
|
358
|
+
|
|
359
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
323
360
|
end
|
|
324
361
|
|
|
325
362
|
# Sets the firmware pointer for BrickletIO16V2#write_firmware. The pointer has
|
|
@@ -329,7 +366,9 @@ module Tinkerforge
|
|
|
329
366
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
330
367
|
# necessary to call it in a normal user program.
|
|
331
368
|
def set_write_firmware_pointer(pointer)
|
|
332
|
-
|
|
369
|
+
check_validity
|
|
370
|
+
|
|
371
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
333
372
|
end
|
|
334
373
|
|
|
335
374
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -341,7 +380,9 @@ module Tinkerforge
|
|
|
341
380
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
342
381
|
# necessary to call it in a normal user program.
|
|
343
382
|
def write_firmware(data)
|
|
344
|
-
|
|
383
|
+
check_validity
|
|
384
|
+
|
|
385
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
345
386
|
end
|
|
346
387
|
|
|
347
388
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -352,22 +393,28 @@ module Tinkerforge
|
|
|
352
393
|
#
|
|
353
394
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
354
395
|
def set_status_led_config(config)
|
|
355
|
-
|
|
396
|
+
check_validity
|
|
397
|
+
|
|
398
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
356
399
|
end
|
|
357
400
|
|
|
358
401
|
# Returns the configuration as set by BrickletIO16V2#set_status_led_config
|
|
359
402
|
def get_status_led_config
|
|
360
|
-
|
|
403
|
+
check_validity
|
|
404
|
+
|
|
405
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
361
406
|
end
|
|
362
407
|
|
|
363
|
-
# Returns the temperature
|
|
408
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
364
409
|
# value returned is not the ambient temperature!
|
|
365
410
|
#
|
|
366
411
|
# The temperature is only proportional to the real temperature and it has bad
|
|
367
412
|
# accuracy. Practically it is only useful as an indicator for
|
|
368
413
|
# temperature changes.
|
|
369
414
|
def get_chip_temperature
|
|
370
|
-
|
|
415
|
+
check_validity
|
|
416
|
+
|
|
417
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
371
418
|
end
|
|
372
419
|
|
|
373
420
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -377,7 +424,9 @@ module Tinkerforge
|
|
|
377
424
|
# calling functions on the existing ones will result in
|
|
378
425
|
# undefined behavior!
|
|
379
426
|
def reset
|
|
380
|
-
|
|
427
|
+
check_validity
|
|
428
|
+
|
|
429
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
381
430
|
end
|
|
382
431
|
|
|
383
432
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -386,25 +435,32 @@ module Tinkerforge
|
|
|
386
435
|
#
|
|
387
436
|
# We recommend that you use Brick Viewer to change the UID.
|
|
388
437
|
def write_uid(uid)
|
|
389
|
-
|
|
438
|
+
check_validity
|
|
439
|
+
|
|
440
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
390
441
|
end
|
|
391
442
|
|
|
392
443
|
# Returns the current UID as an integer. Encode as
|
|
393
444
|
# Base58 to get the usual string version.
|
|
394
445
|
def read_uid
|
|
395
|
-
|
|
446
|
+
check_validity
|
|
447
|
+
|
|
448
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
396
449
|
end
|
|
397
450
|
|
|
398
451
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
399
452
|
# the position, the hardware and firmware version as well as the
|
|
400
453
|
# device identifier.
|
|
401
454
|
#
|
|
402
|
-
# The position can be 'a', 'b', 'c' or '
|
|
455
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
456
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
457
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
458
|
+
# position 'z'.
|
|
403
459
|
#
|
|
404
460
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
405
461
|
# |device_identifier_constant|
|
|
406
462
|
def get_identity
|
|
407
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
463
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
408
464
|
end
|
|
409
465
|
|
|
410
466
|
# 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
|
# 4-channel digital input/output
|
|
14
16
|
class BrickletIO4 < Device
|
|
@@ -59,7 +61,7 @@ module Tinkerforge
|
|
|
59
61
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
60
62
|
# the IP Connection <tt>ipcon</tt>.
|
|
61
63
|
def initialize(uid, ipcon)
|
|
62
|
-
super uid, ipcon
|
|
64
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
63
65
|
|
|
64
66
|
@api_version = [2, 0, 1]
|
|
65
67
|
|
|
@@ -79,9 +81,10 @@ module Tinkerforge
|
|
|
79
81
|
@response_expected[FUNCTION_GET_EDGE_COUNT_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
80
82
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
81
83
|
|
|
82
|
-
@callback_formats[CALLBACK_INTERRUPT] = 'C C'
|
|
83
|
-
@callback_formats[CALLBACK_MONOFLOP_DONE] = 'C C'
|
|
84
|
+
@callback_formats[CALLBACK_INTERRUPT] = [10, 'C C']
|
|
85
|
+
@callback_formats[CALLBACK_MONOFLOP_DONE] = [10, 'C C']
|
|
84
86
|
|
|
87
|
+
@ipcon.add_device self
|
|
85
88
|
end
|
|
86
89
|
|
|
87
90
|
# Sets the output value (high or low) with a bitmask (4bit). A 1 in the bitmask
|
|
@@ -96,14 +99,18 @@ module Tinkerforge
|
|
|
96
99
|
# This function does nothing for pins that are configured as input.
|
|
97
100
|
# Pull-up resistors can be switched on with BrickletIO4#set_configuration.
|
|
98
101
|
def set_value(value_mask)
|
|
99
|
-
|
|
102
|
+
check_validity
|
|
103
|
+
|
|
104
|
+
send_request FUNCTION_SET_VALUE, [value_mask], 'C', 8, ''
|
|
100
105
|
end
|
|
101
106
|
|
|
102
107
|
# Returns a bitmask of the values that are currently measured.
|
|
103
108
|
# This function works if the pin is configured to input
|
|
104
109
|
# as well as if it is configured to output.
|
|
105
110
|
def get_value
|
|
106
|
-
|
|
111
|
+
check_validity
|
|
112
|
+
|
|
113
|
+
send_request FUNCTION_GET_VALUE, [], '', 9, 'C'
|
|
107
114
|
end
|
|
108
115
|
|
|
109
116
|
# Configures the value and direction of the specified pins. Possible directions
|
|
@@ -125,7 +132,9 @@ module Tinkerforge
|
|
|
125
132
|
# Running monoflop timers for the specified pins will be aborted if this
|
|
126
133
|
# function is called.
|
|
127
134
|
def set_configuration(selection_mask, direction, value)
|
|
128
|
-
|
|
135
|
+
check_validity
|
|
136
|
+
|
|
137
|
+
send_request FUNCTION_SET_CONFIGURATION, [selection_mask, direction, value], 'C k ?', 8, ''
|
|
129
138
|
end
|
|
130
139
|
|
|
131
140
|
# Returns a value bitmask and a direction bitmask. A 1 in the direction bitmask
|
|
@@ -139,7 +148,9 @@ module Tinkerforge
|
|
|
139
148
|
# * pin 2 is configured as output high and
|
|
140
149
|
# * pin 3 is are configured as output low.
|
|
141
150
|
def get_configuration
|
|
142
|
-
|
|
151
|
+
check_validity
|
|
152
|
+
|
|
153
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
|
|
143
154
|
end
|
|
144
155
|
|
|
145
156
|
# Sets the debounce period of the CALLBACK_INTERRUPT callback.
|
|
@@ -148,12 +159,16 @@ module Tinkerforge
|
|
|
148
159
|
# maximal every 100ms. This is necessary if something that bounces is
|
|
149
160
|
# connected to the IO-4 Bricklet, such as a button.
|
|
150
161
|
def set_debounce_period(debounce)
|
|
151
|
-
|
|
162
|
+
check_validity
|
|
163
|
+
|
|
164
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
152
165
|
end
|
|
153
166
|
|
|
154
167
|
# Returns the debounce period as set by BrickletIO4#set_debounce_period.
|
|
155
168
|
def get_debounce_period
|
|
156
|
-
|
|
169
|
+
check_validity
|
|
170
|
+
|
|
171
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
157
172
|
end
|
|
158
173
|
|
|
159
174
|
# Sets the pins on which an interrupt is activated with a bitmask.
|
|
@@ -165,12 +180,16 @@ module Tinkerforge
|
|
|
165
180
|
#
|
|
166
181
|
# The interrupt is delivered with the CALLBACK_INTERRUPT callback.
|
|
167
182
|
def set_interrupt(interrupt_mask)
|
|
168
|
-
|
|
183
|
+
check_validity
|
|
184
|
+
|
|
185
|
+
send_request FUNCTION_SET_INTERRUPT, [interrupt_mask], 'C', 8, ''
|
|
169
186
|
end
|
|
170
187
|
|
|
171
188
|
# Returns the interrupt bitmask as set by BrickletIO4#set_interrupt.
|
|
172
189
|
def get_interrupt
|
|
173
|
-
|
|
190
|
+
check_validity
|
|
191
|
+
|
|
192
|
+
send_request FUNCTION_GET_INTERRUPT, [], '', 9, 'C'
|
|
174
193
|
end
|
|
175
194
|
|
|
176
195
|
# Configures a monoflop of the pins specified by the first parameter as 4 bit
|
|
@@ -193,7 +212,9 @@ module Tinkerforge
|
|
|
193
212
|
# of two seconds and pin 0 set to high. Pin 0 will be high all the time. If now
|
|
194
213
|
# the RS485 connection is lost, then pin 0 will get low in at most two seconds.
|
|
195
214
|
def set_monoflop(selection_mask, value_mask, time)
|
|
196
|
-
|
|
215
|
+
check_validity
|
|
216
|
+
|
|
217
|
+
send_request FUNCTION_SET_MONOFLOP, [selection_mask, value_mask, time], 'C C L', 8, ''
|
|
197
218
|
end
|
|
198
219
|
|
|
199
220
|
# Returns (for the given pin) the current value and the time as set by
|
|
@@ -202,7 +223,9 @@ module Tinkerforge
|
|
|
202
223
|
# If the timer is not running currently, the remaining time will be returned
|
|
203
224
|
# as 0.
|
|
204
225
|
def get_monoflop(pin)
|
|
205
|
-
|
|
226
|
+
check_validity
|
|
227
|
+
|
|
228
|
+
send_request FUNCTION_GET_MONOFLOP, [pin], 'C', 17, 'C L L'
|
|
206
229
|
end
|
|
207
230
|
|
|
208
231
|
# Sets the output value (high or low) with a bitmask, according to
|
|
@@ -219,7 +242,9 @@ module Tinkerforge
|
|
|
219
242
|
# This function does nothing for pins that are configured as input.
|
|
220
243
|
# Pull-up resistors can be switched on with BrickletIO4#set_configuration.
|
|
221
244
|
def set_selected_values(selection_mask, value_mask)
|
|
222
|
-
|
|
245
|
+
check_validity
|
|
246
|
+
|
|
247
|
+
send_request FUNCTION_SET_SELECTED_VALUES, [selection_mask, value_mask], 'C C', 8, ''
|
|
223
248
|
end
|
|
224
249
|
|
|
225
250
|
# Returns the current value of the edge counter for the selected pin. You can
|
|
@@ -230,7 +255,9 @@ module Tinkerforge
|
|
|
230
255
|
#
|
|
231
256
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
232
257
|
def get_edge_count(pin, reset_counter)
|
|
233
|
-
|
|
258
|
+
check_validity
|
|
259
|
+
|
|
260
|
+
send_request FUNCTION_GET_EDGE_COUNT, [pin, reset_counter], 'C ?', 12, 'L'
|
|
234
261
|
end
|
|
235
262
|
|
|
236
263
|
# Configures the edge counter for the selected pins.
|
|
@@ -242,8 +269,6 @@ module Tinkerforge
|
|
|
242
269
|
# * 1 = falling
|
|
243
270
|
# * 2 = both
|
|
244
271
|
#
|
|
245
|
-
# The debounce time is given in ms.
|
|
246
|
-
#
|
|
247
272
|
# Configuring an edge counter resets its value to 0.
|
|
248
273
|
#
|
|
249
274
|
# If you don't know what any of this means, just leave it at default. The
|
|
@@ -251,7 +276,9 @@ module Tinkerforge
|
|
|
251
276
|
#
|
|
252
277
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
253
278
|
def set_edge_count_config(selection_mask, edge_type, debounce)
|
|
254
|
-
|
|
279
|
+
check_validity
|
|
280
|
+
|
|
281
|
+
send_request FUNCTION_SET_EDGE_COUNT_CONFIG, [selection_mask, edge_type, debounce], 'C C C', 8, ''
|
|
255
282
|
end
|
|
256
283
|
|
|
257
284
|
# Returns the edge type and debounce time for the selected pin as set by
|
|
@@ -259,19 +286,24 @@ module Tinkerforge
|
|
|
259
286
|
#
|
|
260
287
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
261
288
|
def get_edge_count_config(pin)
|
|
262
|
-
|
|
289
|
+
check_validity
|
|
290
|
+
|
|
291
|
+
send_request FUNCTION_GET_EDGE_COUNT_CONFIG, [pin], 'C', 10, 'C C'
|
|
263
292
|
end
|
|
264
293
|
|
|
265
294
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
266
295
|
# the position, the hardware and firmware version as well as the
|
|
267
296
|
# device identifier.
|
|
268
297
|
#
|
|
269
|
-
# The position can be 'a', 'b', 'c' or '
|
|
298
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
299
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
300
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
301
|
+
# position 'z'.
|
|
270
302
|
#
|
|
271
303
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
272
304
|
# |device_identifier_constant|
|
|
273
305
|
def get_identity
|
|
274
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
306
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
275
307
|
end
|
|
276
308
|
|
|
277
309
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|