tinkerforge 2.1.22 → 2.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# 4 galvanically isolated digital inputs
|
|
14
16
|
class BrickletIndustrialDigitalIn4 < Device
|
|
@@ -27,6 +29,8 @@ module Tinkerforge
|
|
|
27
29
|
# currently pin 0 is high and pins 1-3 are low.
|
|
28
30
|
# * (9, 14) or (0b1001, 0b1110) means that interrupts on pins 0 and 3
|
|
29
31
|
# occurred and currently pin 0 is low and pins 1-3 are high.
|
|
32
|
+
#
|
|
33
|
+
# The interrupts use the grouping as set by BrickletIndustrialDigitalIn4#set_group.
|
|
30
34
|
CALLBACK_INTERRUPT = 9
|
|
31
35
|
|
|
32
36
|
FUNCTION_GET_VALUE = 1 # :nodoc:
|
|
@@ -49,7 +53,7 @@ module Tinkerforge
|
|
|
49
53
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
50
54
|
# the IP Connection <tt>ipcon</tt>.
|
|
51
55
|
def initialize(uid, ipcon)
|
|
52
|
-
super uid, ipcon
|
|
56
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
53
57
|
|
|
54
58
|
@api_version = [2, 0, 1]
|
|
55
59
|
|
|
@@ -66,8 +70,9 @@ module Tinkerforge
|
|
|
66
70
|
@response_expected[FUNCTION_GET_EDGE_COUNT_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
67
71
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
68
72
|
|
|
69
|
-
@callback_formats[CALLBACK_INTERRUPT] = 'S S'
|
|
73
|
+
@callback_formats[CALLBACK_INTERRUPT] = [12, 'S S']
|
|
70
74
|
|
|
75
|
+
@ipcon.add_device self
|
|
71
76
|
end
|
|
72
77
|
|
|
73
78
|
# Returns the input value with a bitmask. The bitmask is 16bit long, *true*
|
|
@@ -83,7 +88,9 @@ module Tinkerforge
|
|
|
83
88
|
# Element 1 in the group will get pins 0-3, element 2 pins 4-7, element 3
|
|
84
89
|
# pins 8-11 and element 4 pins 12-15.
|
|
85
90
|
def get_value
|
|
86
|
-
|
|
91
|
+
check_validity
|
|
92
|
+
|
|
93
|
+
send_request FUNCTION_GET_VALUE, [], '', 10, 'S'
|
|
87
94
|
end
|
|
88
95
|
|
|
89
96
|
# Sets a group of Digital In 4 Bricklets that should work together. You can
|
|
@@ -105,35 +112,43 @@ module Tinkerforge
|
|
|
105
112
|
# Changing the group configuration resets all edge counter configurations
|
|
106
113
|
# and values.
|
|
107
114
|
def set_group(group)
|
|
108
|
-
|
|
115
|
+
check_validity
|
|
116
|
+
|
|
117
|
+
send_request FUNCTION_SET_GROUP, [group], 'k4', 8, ''
|
|
109
118
|
end
|
|
110
119
|
|
|
111
120
|
# Returns the group as set by BrickletIndustrialDigitalIn4#set_group
|
|
112
121
|
def get_group
|
|
113
|
-
|
|
122
|
+
check_validity
|
|
123
|
+
|
|
124
|
+
send_request FUNCTION_GET_GROUP, [], '', 12, 'k4'
|
|
114
125
|
end
|
|
115
126
|
|
|
116
127
|
# Returns a bitmask of ports that are available for grouping. For example the
|
|
117
128
|
# value 5 or 0b0101 means: Port A and port C are connected to Bricklets that
|
|
118
129
|
# can be grouped together.
|
|
119
130
|
def get_available_for_group
|
|
120
|
-
|
|
131
|
+
check_validity
|
|
132
|
+
|
|
133
|
+
send_request FUNCTION_GET_AVAILABLE_FOR_GROUP, [], '', 9, 'C'
|
|
121
134
|
end
|
|
122
135
|
|
|
123
|
-
# Sets the debounce period of the CALLBACK_INTERRUPT callback
|
|
136
|
+
# Sets the debounce period of the CALLBACK_INTERRUPT callback.
|
|
124
137
|
#
|
|
125
138
|
# For example: If you set this value to 100, you will get the interrupt
|
|
126
139
|
# maximal every 100ms. This is necessary if something that bounces is
|
|
127
140
|
# connected to the Digital In 4 Bricklet, such as a button.
|
|
128
|
-
#
|
|
129
|
-
# The default value is 100.
|
|
130
141
|
def set_debounce_period(debounce)
|
|
131
|
-
|
|
142
|
+
check_validity
|
|
143
|
+
|
|
144
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
132
145
|
end
|
|
133
146
|
|
|
134
147
|
# Returns the debounce period as set by BrickletIndustrialDigitalIn4#set_debounce_period.
|
|
135
148
|
def get_debounce_period
|
|
136
|
-
|
|
149
|
+
check_validity
|
|
150
|
+
|
|
151
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
137
152
|
end
|
|
138
153
|
|
|
139
154
|
# Sets the pins on which an interrupt is activated with a bitmask.
|
|
@@ -147,12 +162,16 @@ module Tinkerforge
|
|
|
147
162
|
#
|
|
148
163
|
# The interrupt is delivered with the CALLBACK_INTERRUPT callback.
|
|
149
164
|
def set_interrupt(interrupt_mask)
|
|
150
|
-
|
|
165
|
+
check_validity
|
|
166
|
+
|
|
167
|
+
send_request FUNCTION_SET_INTERRUPT, [interrupt_mask], 'S', 8, ''
|
|
151
168
|
end
|
|
152
169
|
|
|
153
170
|
# Returns the interrupt bitmask as set by BrickletIndustrialDigitalIn4#set_interrupt.
|
|
154
171
|
def get_interrupt
|
|
155
|
-
|
|
172
|
+
check_validity
|
|
173
|
+
|
|
174
|
+
send_request FUNCTION_GET_INTERRUPT, [], '', 10, 'S'
|
|
156
175
|
end
|
|
157
176
|
|
|
158
177
|
# Returns the current value of the edge counter for the selected pin. You can
|
|
@@ -161,9 +180,13 @@ module Tinkerforge
|
|
|
161
180
|
# If you set the reset counter to *true*, the count is set back to 0
|
|
162
181
|
# directly after it is read.
|
|
163
182
|
#
|
|
183
|
+
# The edge counters use the grouping as set by BrickletIndustrialDigitalIn4#set_group.
|
|
184
|
+
#
|
|
164
185
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
165
186
|
def get_edge_count(pin, reset_counter)
|
|
166
|
-
|
|
187
|
+
check_validity
|
|
188
|
+
|
|
189
|
+
send_request FUNCTION_GET_EDGE_COUNT, [pin, reset_counter], 'C ?', 12, 'L'
|
|
167
190
|
end
|
|
168
191
|
|
|
169
192
|
# Configures the edge counter for the selected pins. A bitmask of 9 or 0b1001 will
|
|
@@ -172,22 +195,22 @@ module Tinkerforge
|
|
|
172
195
|
# The edge type parameter configures if rising edges, falling edges or
|
|
173
196
|
# both are counted if the pin is configured for input. Possible edge types are:
|
|
174
197
|
#
|
|
175
|
-
# * 0 = rising
|
|
198
|
+
# * 0 = rising
|
|
176
199
|
# * 1 = falling
|
|
177
200
|
# * 2 = both
|
|
178
201
|
#
|
|
179
|
-
# The debounce time is given in ms.
|
|
180
|
-
#
|
|
181
202
|
# Configuring an edge counter resets its value to 0.
|
|
182
203
|
#
|
|
183
204
|
# If you don't know what any of this means, just leave it at default. The
|
|
184
205
|
# default configuration is very likely OK for you.
|
|
185
206
|
#
|
|
186
|
-
#
|
|
207
|
+
# The edge counters use the grouping as set by BrickletIndustrialDigitalIn4#set_group.
|
|
187
208
|
#
|
|
188
209
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
189
210
|
def set_edge_count_config(selection_mask, edge_type, debounce)
|
|
190
|
-
|
|
211
|
+
check_validity
|
|
212
|
+
|
|
213
|
+
send_request FUNCTION_SET_EDGE_COUNT_CONFIG, [selection_mask, edge_type, debounce], 'S C C', 8, ''
|
|
191
214
|
end
|
|
192
215
|
|
|
193
216
|
# Returns the edge type and debounce time for the selected pin as set by
|
|
@@ -195,19 +218,23 @@ module Tinkerforge
|
|
|
195
218
|
#
|
|
196
219
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
197
220
|
def get_edge_count_config(pin)
|
|
198
|
-
|
|
221
|
+
check_validity
|
|
222
|
+
|
|
223
|
+
send_request FUNCTION_GET_EDGE_COUNT_CONFIG, [pin], 'C', 10, 'C C'
|
|
199
224
|
end
|
|
200
225
|
|
|
201
226
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
202
227
|
# the position, the hardware and firmware version as well as the
|
|
203
228
|
# device identifier.
|
|
204
229
|
#
|
|
205
|
-
# The position can be 'a', 'b', 'c' or '
|
|
230
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
231
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
232
|
+
# position 'z'.
|
|
206
233
|
#
|
|
207
234
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
208
235
|
# |device_identifier_constant|
|
|
209
236
|
def get_identity
|
|
210
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
237
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
211
238
|
end
|
|
212
239
|
|
|
213
240
|
# 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
|
# 4 galvanically isolated digital inputs
|
|
14
16
|
class BrickletIndustrialDigitalIn4V2 < Device
|
|
@@ -84,7 +86,7 @@ module Tinkerforge
|
|
|
84
86
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
85
87
|
# the IP Connection <tt>ipcon</tt>.
|
|
86
88
|
def initialize(uid, ipcon)
|
|
87
|
-
super uid, ipcon
|
|
89
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
88
90
|
|
|
89
91
|
@api_version = [2, 0, 0]
|
|
90
92
|
|
|
@@ -111,19 +113,22 @@ module Tinkerforge
|
|
|
111
113
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
112
114
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
113
115
|
|
|
114
|
-
@callback_formats[CALLBACK_VALUE] = 'C ? ?'
|
|
115
|
-
@callback_formats[CALLBACK_ALL_VALUE] = '?4 ?4'
|
|
116
|
+
@callback_formats[CALLBACK_VALUE] = [11, 'C ? ?']
|
|
117
|
+
@callback_formats[CALLBACK_ALL_VALUE] = [10, '?4 ?4']
|
|
116
118
|
|
|
119
|
+
@ipcon.add_device self
|
|
117
120
|
end
|
|
118
121
|
|
|
119
122
|
# Returns the input value as bools, *true* refers to high and *false* refers to low.
|
|
120
123
|
def get_value
|
|
121
|
-
|
|
124
|
+
check_validity
|
|
125
|
+
|
|
126
|
+
send_request FUNCTION_GET_VALUE, [], '', 9, '?4'
|
|
122
127
|
end
|
|
123
128
|
|
|
124
129
|
# This callback can be configured per channel.
|
|
125
130
|
#
|
|
126
|
-
# The period
|
|
131
|
+
# The period is the period with which the CALLBACK_VALUE
|
|
127
132
|
# callback is triggered periodically. A value of 0 turns the callback off.
|
|
128
133
|
#
|
|
129
134
|
# If the `value has to change`-parameter is set to true, the callback is only
|
|
@@ -132,19 +137,21 @@ module Tinkerforge
|
|
|
132
137
|
#
|
|
133
138
|
# If it is set to false, the callback is continuously triggered with the period,
|
|
134
139
|
# independent of the value.
|
|
135
|
-
#
|
|
136
|
-
# The default value is (0, false).
|
|
137
140
|
def set_value_callback_configuration(channel, period, value_has_to_change)
|
|
138
|
-
|
|
141
|
+
check_validity
|
|
142
|
+
|
|
143
|
+
send_request FUNCTION_SET_VALUE_CALLBACK_CONFIGURATION, [channel, period, value_has_to_change], 'C L ?', 8, ''
|
|
139
144
|
end
|
|
140
145
|
|
|
141
146
|
# Returns the callback configuration for the given channel as set by
|
|
142
147
|
# BrickletIndustrialDigitalIn4V2#set_value_callback_configuration.
|
|
143
148
|
def get_value_callback_configuration(channel)
|
|
144
|
-
|
|
149
|
+
check_validity
|
|
150
|
+
|
|
151
|
+
send_request FUNCTION_GET_VALUE_CALLBACK_CONFIGURATION, [channel], 'C', 13, 'L ?'
|
|
145
152
|
end
|
|
146
153
|
|
|
147
|
-
# The period
|
|
154
|
+
# The period is the period with which the CALLBACK_ALL_VALUE
|
|
148
155
|
# callback is triggered periodically. A value of 0 turns the callback off.
|
|
149
156
|
#
|
|
150
157
|
# If the `value has to change`-parameter is set to true, the callback is only
|
|
@@ -153,16 +160,18 @@ module Tinkerforge
|
|
|
153
160
|
#
|
|
154
161
|
# If it is set to false, the callback is continuously triggered with the period,
|
|
155
162
|
# independent of the value.
|
|
156
|
-
#
|
|
157
|
-
# The default value is (0, false).
|
|
158
163
|
def set_all_value_callback_configuration(period, value_has_to_change)
|
|
159
|
-
|
|
164
|
+
check_validity
|
|
165
|
+
|
|
166
|
+
send_request FUNCTION_SET_ALL_VALUE_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
|
160
167
|
end
|
|
161
168
|
|
|
162
169
|
# Returns the callback configuration as set by
|
|
163
170
|
# BrickletIndustrialDigitalIn4V2#set_all_value_callback_configuration.
|
|
164
171
|
def get_all_value_callback_configuration
|
|
165
|
-
|
|
172
|
+
check_validity
|
|
173
|
+
|
|
174
|
+
send_request FUNCTION_GET_ALL_VALUE_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
|
166
175
|
end
|
|
167
176
|
|
|
168
177
|
# Returns the current value of the edge counter for the selected channel. You can
|
|
@@ -171,7 +180,9 @@ module Tinkerforge
|
|
|
171
180
|
# If you set the reset counter to *true*, the count is set back to 0
|
|
172
181
|
# directly after it is read.
|
|
173
182
|
def get_edge_count(channel, reset_counter)
|
|
174
|
-
|
|
183
|
+
check_validity
|
|
184
|
+
|
|
185
|
+
send_request FUNCTION_GET_EDGE_COUNT, [channel, reset_counter], 'C ?', 12, 'L'
|
|
175
186
|
end
|
|
176
187
|
|
|
177
188
|
# Configures the edge counter for a specific channel.
|
|
@@ -179,26 +190,26 @@ module Tinkerforge
|
|
|
179
190
|
# The edge type parameter configures if rising edges, falling edges or both are
|
|
180
191
|
# counted. Possible edge types are:
|
|
181
192
|
#
|
|
182
|
-
# * 0 = rising
|
|
193
|
+
# * 0 = rising
|
|
183
194
|
# * 1 = falling
|
|
184
195
|
# * 2 = both
|
|
185
196
|
#
|
|
186
|
-
# The debounce time is given in ms.
|
|
187
|
-
#
|
|
188
197
|
# Configuring an edge counter resets its value to 0.
|
|
189
198
|
#
|
|
190
199
|
# If you don't know what any of this means, just leave it at default. The
|
|
191
200
|
# default configuration is very likely OK for you.
|
|
192
|
-
#
|
|
193
|
-
# Default values: 0 (edge type) and 100ms (debounce time)
|
|
194
201
|
def set_edge_count_configuration(channel, edge_type, debounce)
|
|
195
|
-
|
|
202
|
+
check_validity
|
|
203
|
+
|
|
204
|
+
send_request FUNCTION_SET_EDGE_COUNT_CONFIGURATION, [channel, edge_type, debounce], 'C C C', 8, ''
|
|
196
205
|
end
|
|
197
206
|
|
|
198
207
|
# Returns the edge type and debounce time for the selected channel as set by
|
|
199
208
|
# BrickletIndustrialDigitalIn4V2#set_edge_count_configuration.
|
|
200
209
|
def get_edge_count_configuration(channel)
|
|
201
|
-
|
|
210
|
+
check_validity
|
|
211
|
+
|
|
212
|
+
send_request FUNCTION_GET_EDGE_COUNT_CONFIGURATION, [channel], 'C', 10, 'C C'
|
|
202
213
|
end
|
|
203
214
|
|
|
204
215
|
# Each channel has a corresponding LED. You can turn the LED off, on or show a
|
|
@@ -207,12 +218,16 @@ module Tinkerforge
|
|
|
207
218
|
#
|
|
208
219
|
# By default all channel LEDs are configured as "Channel Status".
|
|
209
220
|
def set_channel_led_config(channel, config)
|
|
210
|
-
|
|
221
|
+
check_validity
|
|
222
|
+
|
|
223
|
+
send_request FUNCTION_SET_CHANNEL_LED_CONFIG, [channel, config], 'C C', 8, ''
|
|
211
224
|
end
|
|
212
225
|
|
|
213
226
|
# Returns the channel LED configuration as set by BrickletIndustrialDigitalIn4V2#set_channel_led_config
|
|
214
227
|
def get_channel_led_config(channel)
|
|
215
|
-
|
|
228
|
+
check_validity
|
|
229
|
+
|
|
230
|
+
send_request FUNCTION_GET_CHANNEL_LED_CONFIG, [channel], 'C', 9, 'C'
|
|
216
231
|
end
|
|
217
232
|
|
|
218
233
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -227,7 +242,9 @@ module Tinkerforge
|
|
|
227
242
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
228
243
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
229
244
|
def get_spitfp_error_count
|
|
230
|
-
|
|
245
|
+
check_validity
|
|
246
|
+
|
|
247
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
231
248
|
end
|
|
232
249
|
|
|
233
250
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -240,12 +257,16 @@ module Tinkerforge
|
|
|
240
257
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
241
258
|
# necessary to call it in a normal user program.
|
|
242
259
|
def set_bootloader_mode(mode)
|
|
243
|
-
|
|
260
|
+
check_validity
|
|
261
|
+
|
|
262
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
244
263
|
end
|
|
245
264
|
|
|
246
265
|
# Returns the current bootloader mode, see BrickletIndustrialDigitalIn4V2#set_bootloader_mode.
|
|
247
266
|
def get_bootloader_mode
|
|
248
|
-
|
|
267
|
+
check_validity
|
|
268
|
+
|
|
269
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
249
270
|
end
|
|
250
271
|
|
|
251
272
|
# Sets the firmware pointer for BrickletIndustrialDigitalIn4V2#write_firmware. The pointer has
|
|
@@ -255,7 +276,9 @@ module Tinkerforge
|
|
|
255
276
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
256
277
|
# necessary to call it in a normal user program.
|
|
257
278
|
def set_write_firmware_pointer(pointer)
|
|
258
|
-
|
|
279
|
+
check_validity
|
|
280
|
+
|
|
281
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
259
282
|
end
|
|
260
283
|
|
|
261
284
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -267,7 +290,9 @@ module Tinkerforge
|
|
|
267
290
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
268
291
|
# necessary to call it in a normal user program.
|
|
269
292
|
def write_firmware(data)
|
|
270
|
-
|
|
293
|
+
check_validity
|
|
294
|
+
|
|
295
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
271
296
|
end
|
|
272
297
|
|
|
273
298
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -278,22 +303,28 @@ module Tinkerforge
|
|
|
278
303
|
#
|
|
279
304
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
280
305
|
def set_status_led_config(config)
|
|
281
|
-
|
|
306
|
+
check_validity
|
|
307
|
+
|
|
308
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
282
309
|
end
|
|
283
310
|
|
|
284
311
|
# Returns the configuration as set by BrickletIndustrialDigitalIn4V2#set_status_led_config
|
|
285
312
|
def get_status_led_config
|
|
286
|
-
|
|
313
|
+
check_validity
|
|
314
|
+
|
|
315
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
287
316
|
end
|
|
288
317
|
|
|
289
|
-
# Returns the temperature
|
|
318
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
290
319
|
# value returned is not the ambient temperature!
|
|
291
320
|
#
|
|
292
321
|
# The temperature is only proportional to the real temperature and it has bad
|
|
293
322
|
# accuracy. Practically it is only useful as an indicator for
|
|
294
323
|
# temperature changes.
|
|
295
324
|
def get_chip_temperature
|
|
296
|
-
|
|
325
|
+
check_validity
|
|
326
|
+
|
|
327
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
297
328
|
end
|
|
298
329
|
|
|
299
330
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -303,7 +334,9 @@ module Tinkerforge
|
|
|
303
334
|
# calling functions on the existing ones will result in
|
|
304
335
|
# undefined behavior!
|
|
305
336
|
def reset
|
|
306
|
-
|
|
337
|
+
check_validity
|
|
338
|
+
|
|
339
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
307
340
|
end
|
|
308
341
|
|
|
309
342
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -312,25 +345,31 @@ module Tinkerforge
|
|
|
312
345
|
#
|
|
313
346
|
# We recommend that you use Brick Viewer to change the UID.
|
|
314
347
|
def write_uid(uid)
|
|
315
|
-
|
|
348
|
+
check_validity
|
|
349
|
+
|
|
350
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
316
351
|
end
|
|
317
352
|
|
|
318
353
|
# Returns the current UID as an integer. Encode as
|
|
319
354
|
# Base58 to get the usual string version.
|
|
320
355
|
def read_uid
|
|
321
|
-
|
|
356
|
+
check_validity
|
|
357
|
+
|
|
358
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
322
359
|
end
|
|
323
360
|
|
|
324
361
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
325
362
|
# the position, the hardware and firmware version as well as the
|
|
326
363
|
# device identifier.
|
|
327
364
|
#
|
|
328
|
-
# The position can be 'a', 'b', 'c' or '
|
|
365
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
366
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
367
|
+
# position 'z'.
|
|
329
368
|
#
|
|
330
369
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
331
370
|
# |device_identifier_constant|
|
|
332
371
|
def get_identity
|
|
333
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
372
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
334
373
|
end
|
|
335
374
|
|
|
336
375
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|