tinkerforge 2.1.22 → 2.1.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
@@ -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
|
# 16-channel digital input/output
|
14
16
|
class BrickletIO16 < Device
|
@@ -60,7 +62,7 @@ module Tinkerforge
|
|
60
62
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
61
63
|
# the IP Connection <tt>ipcon</tt>.
|
62
64
|
def initialize(uid, ipcon)
|
63
|
-
super uid, ipcon
|
65
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
64
66
|
|
65
67
|
@api_version = [2, 0, 1]
|
66
68
|
|
@@ -80,9 +82,10 @@ module Tinkerforge
|
|
80
82
|
@response_expected[FUNCTION_GET_EDGE_COUNT_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
81
83
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
82
84
|
|
83
|
-
@callback_formats[CALLBACK_INTERRUPT] = 'k C C'
|
84
|
-
@callback_formats[CALLBACK_MONOFLOP_DONE] = 'k C C'
|
85
|
+
@callback_formats[CALLBACK_INTERRUPT] = [11, 'k C C']
|
86
|
+
@callback_formats[CALLBACK_MONOFLOP_DONE] = [11, 'k C C']
|
85
87
|
|
88
|
+
@ipcon.add_device self
|
86
89
|
end
|
87
90
|
|
88
91
|
# Sets the output value (high or low) for a port ("a" or "b") with a bitmask
|
@@ -98,14 +101,18 @@ module Tinkerforge
|
|
98
101
|
# This function does nothing for pins that are configured as input.
|
99
102
|
# Pull-up resistors can be switched on with BrickletIO16#set_port_configuration.
|
100
103
|
def set_port(port, value_mask)
|
101
|
-
|
104
|
+
check_validity
|
105
|
+
|
106
|
+
send_request FUNCTION_SET_PORT, [port, value_mask], 'k C', 8, ''
|
102
107
|
end
|
103
108
|
|
104
109
|
# Returns a bitmask of the values that are currently measured on the
|
105
110
|
# specified port. This function works if the pin is configured to input
|
106
111
|
# as well as if it is configured to output.
|
107
112
|
def get_port(port)
|
108
|
-
|
113
|
+
check_validity
|
114
|
+
|
115
|
+
send_request FUNCTION_GET_PORT, [port], 'k', 9, 'C'
|
109
116
|
end
|
110
117
|
|
111
118
|
# Configures the value and direction of a specified port. Possible directions
|
@@ -126,10 +133,10 @@ module Tinkerforge
|
|
126
133
|
#
|
127
134
|
# Running monoflop timers for the selected pins will be aborted if this
|
128
135
|
# function is called.
|
129
|
-
#
|
130
|
-
# The default configuration is input with pull-up.
|
131
136
|
def set_port_configuration(port, selection_mask, direction, value)
|
132
|
-
|
137
|
+
check_validity
|
138
|
+
|
139
|
+
send_request FUNCTION_SET_PORT_CONFIGURATION, [port, selection_mask, direction, value], 'k C k ?', 8, ''
|
133
140
|
end
|
134
141
|
|
135
142
|
# Returns a direction bitmask and a value bitmask for the specified port. A 1 in
|
@@ -143,23 +150,27 @@ module Tinkerforge
|
|
143
150
|
# * pins 4 and 5 are configured as output high
|
144
151
|
# * and pins 6 and 7 are configured as output low.
|
145
152
|
def get_port_configuration(port)
|
146
|
-
|
153
|
+
check_validity
|
154
|
+
|
155
|
+
send_request FUNCTION_GET_PORT_CONFIGURATION, [port], 'k', 10, 'C C'
|
147
156
|
end
|
148
157
|
|
149
|
-
# Sets the debounce period of the CALLBACK_INTERRUPT callback
|
158
|
+
# Sets the debounce period of the CALLBACK_INTERRUPT callback.
|
150
159
|
#
|
151
160
|
# For example: If you set this value to 100, you will get the interrupt
|
152
161
|
# maximal every 100ms. This is necessary if something that bounces is
|
153
162
|
# connected to the IO-16 Bricklet, such as a button.
|
154
|
-
#
|
155
|
-
# The default value is 100.
|
156
163
|
def set_debounce_period(debounce)
|
157
|
-
|
164
|
+
check_validity
|
165
|
+
|
166
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
158
167
|
end
|
159
168
|
|
160
169
|
# Returns the debounce period as set by BrickletIO16#set_debounce_period.
|
161
170
|
def get_debounce_period
|
162
|
-
|
171
|
+
check_validity
|
172
|
+
|
173
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
163
174
|
end
|
164
175
|
|
165
176
|
# Sets the pins on which an interrupt is activated with a bitmask.
|
@@ -171,13 +182,17 @@ module Tinkerforge
|
|
171
182
|
#
|
172
183
|
# The interrupt is delivered with the CALLBACK_INTERRUPT callback.
|
173
184
|
def set_port_interrupt(port, interrupt_mask)
|
174
|
-
|
185
|
+
check_validity
|
186
|
+
|
187
|
+
send_request FUNCTION_SET_PORT_INTERRUPT, [port, interrupt_mask], 'k C', 8, ''
|
175
188
|
end
|
176
189
|
|
177
190
|
# Returns the interrupt bitmask for the specified port as set by
|
178
191
|
# BrickletIO16#set_port_interrupt.
|
179
192
|
def get_port_interrupt(port)
|
180
|
-
|
193
|
+
check_validity
|
194
|
+
|
195
|
+
send_request FUNCTION_GET_PORT_INTERRUPT, [port], 'k', 9, 'C'
|
181
196
|
end
|
182
197
|
|
183
198
|
# Configures a monoflop of the pins specified by the second parameter as 8 bit
|
@@ -187,7 +202,7 @@ module Tinkerforge
|
|
187
202
|
# The third parameter is a bitmask with the desired value of the specified
|
188
203
|
# output pins. A 1 in the bitmask means high and a 0 in the bitmask means low.
|
189
204
|
#
|
190
|
-
# The forth parameter indicates the time
|
205
|
+
# The forth parameter indicates the time that the pins should hold
|
191
206
|
# the value.
|
192
207
|
#
|
193
208
|
# If this function is called with the parameters ('a', 9, 1, 1500) or
|
@@ -200,7 +215,9 @@ module Tinkerforge
|
|
200
215
|
# of two seconds and pin 0 set to high. Pin 0 will be high all the time. If now
|
201
216
|
# the RS485 connection is lost, then pin 0 will get low in at most two seconds.
|
202
217
|
def set_port_monoflop(port, selection_mask, value_mask, time)
|
203
|
-
|
218
|
+
check_validity
|
219
|
+
|
220
|
+
send_request FUNCTION_SET_PORT_MONOFLOP, [port, selection_mask, value_mask, time], 'k C C L', 8, ''
|
204
221
|
end
|
205
222
|
|
206
223
|
# Returns (for the given pin) the current value and the time as set by
|
@@ -209,7 +226,9 @@ module Tinkerforge
|
|
209
226
|
# If the timer is not running currently, the remaining time will be returned
|
210
227
|
# as 0.
|
211
228
|
def get_port_monoflop(port, pin)
|
212
|
-
|
229
|
+
check_validity
|
230
|
+
|
231
|
+
send_request FUNCTION_GET_PORT_MONOFLOP, [port, pin], 'k C', 17, 'C L L'
|
213
232
|
end
|
214
233
|
|
215
234
|
# Sets the output value (high or low) for a port ("a" or "b" with a bitmask,
|
@@ -226,7 +245,9 @@ module Tinkerforge
|
|
226
245
|
# This function does nothing for pins that are configured as input.
|
227
246
|
# Pull-up resistors can be switched on with BrickletIO16#set_port_configuration.
|
228
247
|
def set_selected_values(port, selection_mask, value_mask)
|
229
|
-
|
248
|
+
check_validity
|
249
|
+
|
250
|
+
send_request FUNCTION_SET_SELECTED_VALUES, [port, selection_mask, value_mask], 'k C C', 8, ''
|
230
251
|
end
|
231
252
|
|
232
253
|
# Returns the current value of the edge counter for the selected pin on port A.
|
@@ -237,7 +258,9 @@ module Tinkerforge
|
|
237
258
|
#
|
238
259
|
# .. versionadded:: 2.0.3$nbsp;(Plugin)
|
239
260
|
def get_edge_count(pin, reset_counter)
|
240
|
-
|
261
|
+
check_validity
|
262
|
+
|
263
|
+
send_request FUNCTION_GET_EDGE_COUNT, [pin, reset_counter], 'C ?', 12, 'L'
|
241
264
|
end
|
242
265
|
|
243
266
|
# Configures the edge counter for the selected pin of port A. Pins 0 and 1
|
@@ -246,22 +269,20 @@ module Tinkerforge
|
|
246
269
|
# The edge type parameter configures if rising edges, falling edges or
|
247
270
|
# both are counted if the pin is configured for input. Possible edge types are:
|
248
271
|
#
|
249
|
-
# * 0 = rising
|
272
|
+
# * 0 = rising
|
250
273
|
# * 1 = falling
|
251
274
|
# * 2 = both
|
252
275
|
#
|
253
|
-
# The debounce time is given in ms.
|
254
|
-
#
|
255
276
|
# Configuring an edge counter resets its value to 0.
|
256
277
|
#
|
257
278
|
# If you don't know what any of this means, just leave it at default. The
|
258
279
|
# default configuration is very likely OK for you.
|
259
280
|
#
|
260
|
-
# Default values: 0 (edge type) and 100ms (debounce time)
|
261
|
-
#
|
262
281
|
# .. versionadded:: 2.0.3$nbsp;(Plugin)
|
263
282
|
def set_edge_count_config(pin, edge_type, debounce)
|
264
|
-
|
283
|
+
check_validity
|
284
|
+
|
285
|
+
send_request FUNCTION_SET_EDGE_COUNT_CONFIG, [pin, edge_type, debounce], 'C C C', 8, ''
|
265
286
|
end
|
266
287
|
|
267
288
|
# Returns the edge type and debounce time for the selected pin of port A as set by
|
@@ -269,19 +290,23 @@ module Tinkerforge
|
|
269
290
|
#
|
270
291
|
# .. versionadded:: 2.0.3$nbsp;(Plugin)
|
271
292
|
def get_edge_count_config(pin)
|
272
|
-
|
293
|
+
check_validity
|
294
|
+
|
295
|
+
send_request FUNCTION_GET_EDGE_COUNT_CONFIG, [pin], 'C', 10, 'C C'
|
273
296
|
end
|
274
297
|
|
275
298
|
# Returns the UID, the UID where the Bricklet is connected to,
|
276
299
|
# the position, the hardware and firmware version as well as the
|
277
300
|
# device identifier.
|
278
301
|
#
|
279
|
-
# The position can be 'a', 'b', 'c' or '
|
302
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
303
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
304
|
+
# position 'z'.
|
280
305
|
#
|
281
306
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
282
307
|
# |device_identifier_constant|
|
283
308
|
def get_identity
|
284
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
309
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
285
310
|
end
|
286
311
|
|
287
312
|
# 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
|
# 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
|
@@ -178,20 +187,22 @@ module Tinkerforge
|
|
178
187
|
#
|
179
188
|
# A running monoflop timer for the specific channel will be aborted if this
|
180
189
|
# function is called.
|
181
|
-
#
|
182
|
-
# The default configuration is input with pull-up.
|
183
190
|
def set_configuration(channel, direction, value)
|
184
|
-
|
191
|
+
check_validity
|
192
|
+
|
193
|
+
send_request FUNCTION_SET_CONFIGURATION, [channel, direction, value], 'C k ?', 8, ''
|
185
194
|
end
|
186
195
|
|
187
196
|
# Returns the channel configuration as set by BrickletIO16V2#set_configuration.
|
188
197
|
def get_configuration(channel)
|
189
|
-
|
198
|
+
check_validity
|
199
|
+
|
200
|
+
send_request FUNCTION_GET_CONFIGURATION, [channel], 'C', 10, 'k ?'
|
190
201
|
end
|
191
202
|
|
192
203
|
# This callback can be configured per channel.
|
193
204
|
#
|
194
|
-
# The period
|
205
|
+
# The period is the period with which the CALLBACK_INPUT_VALUE
|
195
206
|
# callback is triggered periodically. A value of 0 turns the callback off.
|
196
207
|
#
|
197
208
|
# If the `value has to change`-parameter is set to true, the callback is only
|
@@ -200,19 +211,21 @@ module Tinkerforge
|
|
200
211
|
#
|
201
212
|
# If it is set to false, the callback is continuously triggered with the period,
|
202
213
|
# independent of the value.
|
203
|
-
#
|
204
|
-
# The default value is (0, false).
|
205
214
|
def set_input_value_callback_configuration(channel, period, value_has_to_change)
|
206
|
-
|
215
|
+
check_validity
|
216
|
+
|
217
|
+
send_request FUNCTION_SET_INPUT_VALUE_CALLBACK_CONFIGURATION, [channel, period, value_has_to_change], 'C L ?', 8, ''
|
207
218
|
end
|
208
219
|
|
209
220
|
# Returns the callback configuration as set by
|
210
221
|
# BrickletIO16V2#set_input_value_callback_configuration.
|
211
222
|
def get_input_value_callback_configuration(channel)
|
212
|
-
|
223
|
+
check_validity
|
224
|
+
|
225
|
+
send_request FUNCTION_GET_INPUT_VALUE_CALLBACK_CONFIGURATION, [channel], 'C', 13, 'L ?'
|
213
226
|
end
|
214
227
|
|
215
|
-
# The period
|
228
|
+
# The period is the period with which the CALLBACK_ALL_INPUT_VALUE
|
216
229
|
# callback is triggered periodically. A value of 0 turns the callback off.
|
217
230
|
#
|
218
231
|
# If the `value has to change`-parameter is set to true, the callback is only
|
@@ -221,16 +234,18 @@ module Tinkerforge
|
|
221
234
|
#
|
222
235
|
# If it is set to false, the callback is continuously triggered with the period,
|
223
236
|
# independent of the value.
|
224
|
-
#
|
225
|
-
# The default value is (0, false).
|
226
237
|
def set_all_input_value_callback_configuration(period, value_has_to_change)
|
227
|
-
|
238
|
+
check_validity
|
239
|
+
|
240
|
+
send_request FUNCTION_SET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
228
241
|
end
|
229
242
|
|
230
243
|
# Returns the callback configuration as set by
|
231
244
|
# BrickletIO16V2#set_all_input_value_callback_configuration.
|
232
245
|
def get_all_input_value_callback_configuration
|
233
|
-
|
246
|
+
check_validity
|
247
|
+
|
248
|
+
send_request FUNCTION_GET_ALL_INPUT_VALUE_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
234
249
|
end
|
235
250
|
|
236
251
|
# Configures a monoflop of the specified channel.
|
@@ -238,7 +253,7 @@ module Tinkerforge
|
|
238
253
|
# The second parameter is the desired value of the specified
|
239
254
|
# channel. A *true* means relay closed and a *false* means relay open.
|
240
255
|
#
|
241
|
-
# The third parameter indicates the time
|
256
|
+
# The third parameter indicates the time that the channels should hold
|
242
257
|
# the value.
|
243
258
|
#
|
244
259
|
# If this function is called with the parameters (0, 1, 1500) channel 0 will
|
@@ -251,7 +266,9 @@ module Tinkerforge
|
|
251
266
|
# time. If now the RS485 connection is lost, then channel 0 will be opened in at
|
252
267
|
# most two seconds.
|
253
268
|
def set_monoflop(channel, value, time)
|
254
|
-
|
269
|
+
check_validity
|
270
|
+
|
271
|
+
send_request FUNCTION_SET_MONOFLOP, [channel, value, time], 'C ? L', 8, ''
|
255
272
|
end
|
256
273
|
|
257
274
|
# Returns (for the given channel) the current value and the time as set by
|
@@ -260,7 +277,9 @@ module Tinkerforge
|
|
260
277
|
# If the timer is not running currently, the remaining time will be returned
|
261
278
|
# as 0.
|
262
279
|
def get_monoflop(channel)
|
263
|
-
|
280
|
+
check_validity
|
281
|
+
|
282
|
+
send_request FUNCTION_GET_MONOFLOP, [channel], 'C', 17, '? L L'
|
264
283
|
end
|
265
284
|
|
266
285
|
# Returns the current value of the edge counter for the selected channel. You can
|
@@ -269,7 +288,9 @@ module Tinkerforge
|
|
269
288
|
# If you set the reset counter to *true*, the count is set back to 0
|
270
289
|
# directly after it is read.
|
271
290
|
def get_edge_count(channel, reset_counter)
|
272
|
-
|
291
|
+
check_validity
|
292
|
+
|
293
|
+
send_request FUNCTION_GET_EDGE_COUNT, [channel, reset_counter], 'C ?', 12, 'L'
|
273
294
|
end
|
274
295
|
|
275
296
|
# Configures the edge counter for a specific channel.
|
@@ -277,26 +298,26 @@ module Tinkerforge
|
|
277
298
|
# The edge type parameter configures if rising edges, falling edges or
|
278
299
|
# both are counted if the channel is configured for input. Possible edge types are:
|
279
300
|
#
|
280
|
-
# * 0 = rising
|
301
|
+
# * 0 = rising
|
281
302
|
# * 1 = falling
|
282
303
|
# * 2 = both
|
283
304
|
#
|
284
|
-
# The debounce time is given in ms.
|
285
|
-
#
|
286
305
|
# Configuring an edge counter resets its value to 0.
|
287
306
|
#
|
288
307
|
# If you don't know what any of this means, just leave it at default. The
|
289
308
|
# default configuration is very likely OK for you.
|
290
|
-
#
|
291
|
-
# Default values: 0 (edge type) and 100ms (debounce time)
|
292
309
|
def set_edge_count_configuration(channel, edge_type, debounce)
|
293
|
-
|
310
|
+
check_validity
|
311
|
+
|
312
|
+
send_request FUNCTION_SET_EDGE_COUNT_CONFIGURATION, [channel, edge_type, debounce], 'C C C', 8, ''
|
294
313
|
end
|
295
314
|
|
296
315
|
# Returns the edge type and debounce time for the selected channel as set by
|
297
316
|
# BrickletIO16V2#set_edge_count_configuration.
|
298
317
|
def get_edge_count_configuration(channel)
|
299
|
-
|
318
|
+
check_validity
|
319
|
+
|
320
|
+
send_request FUNCTION_GET_EDGE_COUNT_CONFIGURATION, [channel], 'C', 10, 'C C'
|
300
321
|
end
|
301
322
|
|
302
323
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -311,7 +332,9 @@ module Tinkerforge
|
|
311
332
|
# The errors counts are for errors that occur on the Bricklet side. All
|
312
333
|
# Bricks have a similar function that returns the errors on the Brick side.
|
313
334
|
def get_spitfp_error_count
|
314
|
-
|
335
|
+
check_validity
|
336
|
+
|
337
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
315
338
|
end
|
316
339
|
|
317
340
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -324,12 +347,16 @@ module Tinkerforge
|
|
324
347
|
# This function is used by Brick Viewer during flashing. It should not be
|
325
348
|
# necessary to call it in a normal user program.
|
326
349
|
def set_bootloader_mode(mode)
|
327
|
-
|
350
|
+
check_validity
|
351
|
+
|
352
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
328
353
|
end
|
329
354
|
|
330
355
|
# Returns the current bootloader mode, see BrickletIO16V2#set_bootloader_mode.
|
331
356
|
def get_bootloader_mode
|
332
|
-
|
357
|
+
check_validity
|
358
|
+
|
359
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
333
360
|
end
|
334
361
|
|
335
362
|
# Sets the firmware pointer for BrickletIO16V2#write_firmware. The pointer has
|
@@ -339,7 +366,9 @@ module Tinkerforge
|
|
339
366
|
# This function is used by Brick Viewer during flashing. It should not be
|
340
367
|
# necessary to call it in a normal user program.
|
341
368
|
def set_write_firmware_pointer(pointer)
|
342
|
-
|
369
|
+
check_validity
|
370
|
+
|
371
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
343
372
|
end
|
344
373
|
|
345
374
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -351,7 +380,9 @@ module Tinkerforge
|
|
351
380
|
# This function is used by Brick Viewer during flashing. It should not be
|
352
381
|
# necessary to call it in a normal user program.
|
353
382
|
def write_firmware(data)
|
354
|
-
|
383
|
+
check_validity
|
384
|
+
|
385
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
355
386
|
end
|
356
387
|
|
357
388
|
# Sets the status LED configuration. By default the LED shows
|
@@ -362,22 +393,28 @@ module Tinkerforge
|
|
362
393
|
#
|
363
394
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
364
395
|
def set_status_led_config(config)
|
365
|
-
|
396
|
+
check_validity
|
397
|
+
|
398
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
366
399
|
end
|
367
400
|
|
368
401
|
# Returns the configuration as set by BrickletIO16V2#set_status_led_config
|
369
402
|
def get_status_led_config
|
370
|
-
|
403
|
+
check_validity
|
404
|
+
|
405
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
371
406
|
end
|
372
407
|
|
373
|
-
# Returns the temperature
|
408
|
+
# Returns the temperature as measured inside the microcontroller. The
|
374
409
|
# value returned is not the ambient temperature!
|
375
410
|
#
|
376
411
|
# The temperature is only proportional to the real temperature and it has bad
|
377
412
|
# accuracy. Practically it is only useful as an indicator for
|
378
413
|
# temperature changes.
|
379
414
|
def get_chip_temperature
|
380
|
-
|
415
|
+
check_validity
|
416
|
+
|
417
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
381
418
|
end
|
382
419
|
|
383
420
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -387,7 +424,9 @@ module Tinkerforge
|
|
387
424
|
# calling functions on the existing ones will result in
|
388
425
|
# undefined behavior!
|
389
426
|
def reset
|
390
|
-
|
427
|
+
check_validity
|
428
|
+
|
429
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
391
430
|
end
|
392
431
|
|
393
432
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -396,25 +435,31 @@ module Tinkerforge
|
|
396
435
|
#
|
397
436
|
# We recommend that you use Brick Viewer to change the UID.
|
398
437
|
def write_uid(uid)
|
399
|
-
|
438
|
+
check_validity
|
439
|
+
|
440
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
400
441
|
end
|
401
442
|
|
402
443
|
# Returns the current UID as an integer. Encode as
|
403
444
|
# Base58 to get the usual string version.
|
404
445
|
def read_uid
|
405
|
-
|
446
|
+
check_validity
|
447
|
+
|
448
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
406
449
|
end
|
407
450
|
|
408
451
|
# Returns the UID, the UID where the Bricklet is connected to,
|
409
452
|
# the position, the hardware and firmware version as well as the
|
410
453
|
# device identifier.
|
411
454
|
#
|
412
|
-
# 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
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
457
|
+
# position 'z'.
|
413
458
|
#
|
414
459
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
415
460
|
# |device_identifier_constant|
|
416
461
|
def get_identity
|
417
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
462
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
418
463
|
end
|
419
464
|
|
420
465
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|