tinkerforge 2.1.24 → 2.1.29
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 +156 -75
- data/lib/tinkerforge/brick_hat.rb +69 -31
- data/lib/tinkerforge/brick_hat_zero.rb +55 -23
- data/lib/tinkerforge/brick_imu.rb +185 -78
- data/lib/tinkerforge/brick_imu_v2.rb +209 -106
- data/lib/tinkerforge/brick_master.rb +491 -183
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +186 -102
- data/lib/tinkerforge/brick_silent_stepper.rb +247 -167
- data/lib/tinkerforge/brick_stepper.rb +211 -99
- data/lib/tinkerforge/bricklet_accelerometer.rb +57 -23
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +104 -54
- data/lib/tinkerforge/bricklet_air_quality.rb +116 -59
- data/lib/tinkerforge/bricklet_ambient_light.rb +50 -21
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +44 -24
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +65 -27
- data/lib/tinkerforge/bricklet_analog_in.rb +62 -25
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +56 -23
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +66 -25
- data/lib/tinkerforge/bricklet_analog_out.rb +22 -9
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +19 -8
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +53 -20
- data/lib/tinkerforge/bricklet_barometer.rb +100 -27
- data/lib/tinkerforge/bricklet_barometer_v2.rb +98 -37
- data/lib/tinkerforge/bricklet_can.rb +83 -19
- data/lib/tinkerforge/bricklet_can_v2.rb +171 -38
- data/lib/tinkerforge/bricklet_co2.rb +33 -14
- data/lib/tinkerforge/bricklet_co2_v2.rb +97 -38
- data/lib/tinkerforge/bricklet_color.rb +68 -27
- data/lib/tinkerforge/bricklet_color_v2.rb +86 -33
- data/lib/tinkerforge/bricklet_compass.rb +77 -30
- data/lib/tinkerforge/bricklet_current12.rb +57 -24
- data/lib/tinkerforge/bricklet_current25.rb +57 -24
- data/lib/tinkerforge/bricklet_dc_v2.rb +521 -0
- data/lib/tinkerforge/bricklet_distance_ir.rb +56 -23
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +82 -31
- data/lib/tinkerforge/bricklet_distance_us.rb +39 -16
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +66 -25
- data/lib/tinkerforge/bricklet_dmx.rb +87 -34
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -10
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +63 -24
- data/lib/tinkerforge/bricklet_dual_relay.rb +26 -11
- data/lib/tinkerforge/bricklet_dust_detector.rb +39 -16
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +87 -32
- data/lib/tinkerforge/bricklet_energy_monitor.rb +72 -27
- data/lib/tinkerforge/bricklet_gps.rb +63 -26
- data/lib/tinkerforge/bricklet_gps_v2.rb +116 -47
- data/lib/tinkerforge/bricklet_hall_effect.rb +42 -23
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +70 -27
- data/lib/tinkerforge/bricklet_humidity.rb +50 -21
- data/lib/tinkerforge/bricklet_humidity_v2.rb +82 -31
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +37 -14
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +80 -29
- data/lib/tinkerforge/bricklet_industrial_counter.rb +100 -39
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +44 -17
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +76 -29
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +35 -14
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +72 -27
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +39 -16
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -30
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +48 -19
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +137 -31
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +60 -23
- data/lib/tinkerforge/bricklet_industrial_ptc.rb +475 -0
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +35 -14
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +66 -25
- data/lib/tinkerforge/bricklet_io16.rb +54 -21
- data/lib/tinkerforge/bricklet_io16_v2.rb +89 -34
- data/lib/tinkerforge/bricklet_io4.rb +54 -23
- data/lib/tinkerforge/bricklet_io4_v2.rb +95 -36
- data/lib/tinkerforge/bricklet_isolator.rb +72 -29
- data/lib/tinkerforge/bricklet_joystick.rb +58 -25
- data/lib/tinkerforge/bricklet_joystick_v2.rb +67 -26
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +81 -32
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +95 -36
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +191 -70
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +44 -18
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +57 -23
- data/lib/tinkerforge/bricklet_led_strip.rb +59 -22
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +90 -46
- data/lib/tinkerforge/bricklet_line.rb +33 -14
- data/lib/tinkerforge/bricklet_linear_poti.rb +50 -21
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +54 -21
- data/lib/tinkerforge/bricklet_load_cell.rb +60 -23
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +79 -30
- data/lib/tinkerforge/bricklet_moisture.rb +39 -16
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +61 -27
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +70 -27
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -13
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +75 -28
- data/lib/tinkerforge/bricklet_nfc.rb +126 -62
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +28 -11
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +65 -24
- data/lib/tinkerforge/bricklet_oled_64x48.rb +28 -11
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -28
- data/lib/tinkerforge/bricklet_particulate_matter.rb +74 -30
- data/lib/tinkerforge/bricklet_performance_dc.rb +682 -0
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +18 -9
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +21 -10
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +79 -42
- data/lib/tinkerforge/bricklet_ptc.rb +73 -42
- data/lib/tinkerforge/bricklet_ptc_v2.rb +94 -48
- data/lib/tinkerforge/bricklet_real_time_clock.rb +44 -33
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +77 -44
- 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 +38 -19
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +59 -24
- data/lib/tinkerforge/bricklet_rotary_poti.rb +52 -28
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +56 -23
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +117 -44
- data/lib/tinkerforge/bricklet_rs485.rb +222 -95
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +74 -35
- data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
- data/lib/tinkerforge/bricklet_silent_stepper_v2.rb +1024 -0
- 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 +34 -18
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +71 -31
- data/lib/tinkerforge/bricklet_temperature.rb +39 -16
- data/lib/tinkerforge/bricklet_temperature_ir.rb +56 -23
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +70 -27
- data/lib/tinkerforge/bricklet_temperature_v2.rb +60 -25
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +104 -44
- data/lib/tinkerforge/bricklet_thermocouple.rb +44 -24
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +64 -27
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +35 -18
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +84 -37
- data/lib/tinkerforge/bricklet_voltage.rb +51 -28
- data/lib/tinkerforge/bricklet_voltage_current.rb +90 -73
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +89 -68
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +79 -30
- data/lib/tinkerforge/device_display_names.rb +170 -0
- data/lib/tinkerforge/ip_connection.rb +153 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +11 -3
|
@@ -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 2021-05-06. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.29 #
|
|
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
|
# 300° rotary potentiometer
|
|
14
16
|
class BrickletRotaryPoti < Device
|
|
@@ -70,7 +72,7 @@ module Tinkerforge
|
|
|
70
72
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
71
73
|
# the IP Connection <tt>ipcon</tt>.
|
|
72
74
|
def initialize(uid, ipcon)
|
|
73
|
-
super uid, ipcon
|
|
75
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
74
76
|
|
|
75
77
|
@api_version = [2, 0, 0]
|
|
76
78
|
|
|
@@ -88,25 +90,27 @@ module Tinkerforge
|
|
|
88
90
|
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
89
91
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
90
92
|
|
|
91
|
-
@callback_formats[CALLBACK_POSITION] = 's'
|
|
92
|
-
@callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
|
|
93
|
-
@callback_formats[CALLBACK_POSITION_REACHED] = 's'
|
|
94
|
-
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
|
|
93
|
+
@callback_formats[CALLBACK_POSITION] = [10, 's']
|
|
94
|
+
@callback_formats[CALLBACK_ANALOG_VALUE] = [10, 'S']
|
|
95
|
+
@callback_formats[CALLBACK_POSITION_REACHED] = [10, 's']
|
|
96
|
+
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [10, 'S']
|
|
95
97
|
|
|
98
|
+
@ipcon.add_device self
|
|
96
99
|
end
|
|
97
100
|
|
|
98
|
-
# Returns the position of the rotary potentiometer. The value is
|
|
99
|
-
#
|
|
101
|
+
# Returns the position of the rotary potentiometer. The value is
|
|
102
|
+
# between -150° (turned left) and 150° (turned right).
|
|
100
103
|
#
|
|
101
104
|
# If you want to get the position periodically, it is recommended to use the
|
|
102
105
|
# CALLBACK_POSITION callback and set the period with
|
|
103
106
|
# BrickletRotaryPoti#set_position_callback_period.
|
|
104
107
|
def get_position
|
|
105
|
-
|
|
108
|
+
check_validity
|
|
109
|
+
|
|
110
|
+
send_request FUNCTION_GET_POSITION, [], '', 10, 's'
|
|
106
111
|
end
|
|
107
112
|
|
|
108
113
|
# Returns the value as read by a 12-bit analog-to-digital converter.
|
|
109
|
-
# The value is between 0 and 4095.
|
|
110
114
|
#
|
|
111
115
|
# .. note::
|
|
112
116
|
# The value returned by BrickletRotaryPoti#get_position is averaged over several samples
|
|
@@ -118,7 +122,9 @@ module Tinkerforge
|
|
|
118
122
|
# CALLBACK_ANALOG_VALUE callback and set the period with
|
|
119
123
|
# BrickletRotaryPoti#set_analog_value_callback_period.
|
|
120
124
|
def get_analog_value
|
|
121
|
-
|
|
125
|
+
check_validity
|
|
126
|
+
|
|
127
|
+
send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
|
|
122
128
|
end
|
|
123
129
|
|
|
124
130
|
# Sets the period with which the CALLBACK_POSITION callback is triggered
|
|
@@ -127,12 +133,16 @@ module Tinkerforge
|
|
|
127
133
|
# The CALLBACK_POSITION callback is only triggered if the position has changed since
|
|
128
134
|
# the last triggering.
|
|
129
135
|
def set_position_callback_period(period)
|
|
130
|
-
|
|
136
|
+
check_validity
|
|
137
|
+
|
|
138
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
131
139
|
end
|
|
132
140
|
|
|
133
141
|
# Returns the period as set by BrickletRotaryPoti#set_position_callback_period.
|
|
134
142
|
def get_position_callback_period
|
|
135
|
-
|
|
143
|
+
check_validity
|
|
144
|
+
|
|
145
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
136
146
|
end
|
|
137
147
|
|
|
138
148
|
# Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
|
|
@@ -141,12 +151,16 @@ module Tinkerforge
|
|
|
141
151
|
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
|
142
152
|
# changed since the last triggering.
|
|
143
153
|
def set_analog_value_callback_period(period)
|
|
144
|
-
|
|
154
|
+
check_validity
|
|
155
|
+
|
|
156
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
|
145
157
|
end
|
|
146
158
|
|
|
147
159
|
# Returns the period as set by BrickletRotaryPoti#set_analog_value_callback_period.
|
|
148
160
|
def get_analog_value_callback_period
|
|
149
|
-
|
|
161
|
+
check_validity
|
|
162
|
+
|
|
163
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
|
|
150
164
|
end
|
|
151
165
|
|
|
152
166
|
# Sets the thresholds for the CALLBACK_POSITION_REACHED callback.
|
|
@@ -160,15 +174,17 @@ module Tinkerforge
|
|
|
160
174
|
# "'i'", "Callback is triggered when the position is *inside* the min and max values"
|
|
161
175
|
# "'<'", "Callback is triggered when the position is smaller than the min value (max is ignored)"
|
|
162
176
|
# "'>'", "Callback is triggered when the position is greater than the min value (max is ignored)"
|
|
163
|
-
#
|
|
164
|
-
# The default value is ('x', 0, 0).
|
|
165
177
|
def set_position_callback_threshold(option, min, max)
|
|
166
|
-
|
|
178
|
+
check_validity
|
|
179
|
+
|
|
180
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_THRESHOLD, [option, min, max], 'k s s', 8, ''
|
|
167
181
|
end
|
|
168
182
|
|
|
169
183
|
# Returns the threshold as set by BrickletRotaryPoti#set_position_callback_threshold.
|
|
170
184
|
def get_position_callback_threshold
|
|
171
|
-
|
|
185
|
+
check_validity
|
|
186
|
+
|
|
187
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_THRESHOLD, [], '', 13, 'k s s'
|
|
172
188
|
end
|
|
173
189
|
|
|
174
190
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
|
@@ -182,15 +198,17 @@ module Tinkerforge
|
|
|
182
198
|
# "'i'", "Callback is triggered when the analog value is *inside* the min and max values"
|
|
183
199
|
# "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
|
|
184
200
|
# "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
|
|
185
|
-
#
|
|
186
|
-
# The default value is ('x', 0, 0).
|
|
187
201
|
def set_analog_value_callback_threshold(option, min, max)
|
|
188
|
-
|
|
202
|
+
check_validity
|
|
203
|
+
|
|
204
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
|
189
205
|
end
|
|
190
206
|
|
|
191
207
|
# Returns the threshold as set by BrickletRotaryPoti#set_analog_value_callback_threshold.
|
|
192
208
|
def get_analog_value_callback_threshold
|
|
193
|
-
|
|
209
|
+
check_validity
|
|
210
|
+
|
|
211
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
|
194
212
|
end
|
|
195
213
|
|
|
196
214
|
# Sets the period with which the threshold callbacks
|
|
@@ -205,24 +223,30 @@ module Tinkerforge
|
|
|
205
223
|
#
|
|
206
224
|
# keep being reached.
|
|
207
225
|
def set_debounce_period(debounce)
|
|
208
|
-
|
|
226
|
+
check_validity
|
|
227
|
+
|
|
228
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
|
209
229
|
end
|
|
210
230
|
|
|
211
231
|
# Returns the debounce period as set by BrickletRotaryPoti#set_debounce_period.
|
|
212
232
|
def get_debounce_period
|
|
213
|
-
|
|
233
|
+
check_validity
|
|
234
|
+
|
|
235
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
|
214
236
|
end
|
|
215
237
|
|
|
216
238
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
217
239
|
# the position, the hardware and firmware version as well as the
|
|
218
240
|
# device identifier.
|
|
219
241
|
#
|
|
220
|
-
# The position can be 'a', 'b', 'c' or '
|
|
242
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
243
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
244
|
+
# position 'z'.
|
|
221
245
|
#
|
|
222
246
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
223
247
|
# |device_identifier_constant|
|
|
224
248
|
def get_identity
|
|
225
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
249
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
226
250
|
end
|
|
227
251
|
|
|
228
252
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2021-05-06. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.29 #
|
|
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
|
# 300° rotary potentiometer
|
|
14
16
|
class BrickletRotaryPotiV2 < Device
|
|
@@ -61,7 +63,7 @@ module Tinkerforge
|
|
|
61
63
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
62
64
|
# the IP Connection <tt>ipcon</tt>.
|
|
63
65
|
def initialize(uid, ipcon)
|
|
64
|
-
super uid, ipcon
|
|
66
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
65
67
|
|
|
66
68
|
@api_version = [2, 0, 0]
|
|
67
69
|
|
|
@@ -81,19 +83,22 @@ module Tinkerforge
|
|
|
81
83
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
82
84
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
83
85
|
|
|
84
|
-
@callback_formats[CALLBACK_POSITION] = 's'
|
|
86
|
+
@callback_formats[CALLBACK_POSITION] = [10, 's']
|
|
85
87
|
|
|
88
|
+
@ipcon.add_device self
|
|
86
89
|
end
|
|
87
90
|
|
|
88
|
-
# Returns the position of the rotary potentiometer. The value is
|
|
89
|
-
#
|
|
91
|
+
# Returns the position of the rotary potentiometer. The value is
|
|
92
|
+
# between -150° (turned left) and 150° (turned right).
|
|
90
93
|
#
|
|
91
94
|
#
|
|
92
95
|
# If you want to get the value periodically, it is recommended to use the
|
|
93
96
|
# CALLBACK_POSITION callback. You can set the callback configuration
|
|
94
97
|
# with BrickletRotaryPotiV2#set_position_callback_configuration.
|
|
95
98
|
def get_position
|
|
96
|
-
|
|
99
|
+
check_validity
|
|
100
|
+
|
|
101
|
+
send_request FUNCTION_GET_POSITION, [], '', 10, 's'
|
|
97
102
|
end
|
|
98
103
|
|
|
99
104
|
# The period is the period with which the CALLBACK_POSITION callback is triggered
|
|
@@ -122,12 +127,16 @@ module Tinkerforge
|
|
|
122
127
|
#
|
|
123
128
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
124
129
|
def set_position_callback_configuration(period, value_has_to_change, option, min, max)
|
|
125
|
-
|
|
130
|
+
check_validity
|
|
131
|
+
|
|
132
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k s s', 8, ''
|
|
126
133
|
end
|
|
127
134
|
|
|
128
135
|
# Returns the callback configuration as set by BrickletRotaryPotiV2#set_position_callback_configuration.
|
|
129
136
|
def get_position_callback_configuration
|
|
130
|
-
|
|
137
|
+
check_validity
|
|
138
|
+
|
|
139
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_CONFIGURATION, [], '', 18, 'L ? k s s'
|
|
131
140
|
end
|
|
132
141
|
|
|
133
142
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -142,7 +151,9 @@ module Tinkerforge
|
|
|
142
151
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
143
152
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
144
153
|
def get_spitfp_error_count
|
|
145
|
-
|
|
154
|
+
check_validity
|
|
155
|
+
|
|
156
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
146
157
|
end
|
|
147
158
|
|
|
148
159
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -155,12 +166,16 @@ module Tinkerforge
|
|
|
155
166
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
156
167
|
# necessary to call it in a normal user program.
|
|
157
168
|
def set_bootloader_mode(mode)
|
|
158
|
-
|
|
169
|
+
check_validity
|
|
170
|
+
|
|
171
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
159
172
|
end
|
|
160
173
|
|
|
161
174
|
# Returns the current bootloader mode, see BrickletRotaryPotiV2#set_bootloader_mode.
|
|
162
175
|
def get_bootloader_mode
|
|
163
|
-
|
|
176
|
+
check_validity
|
|
177
|
+
|
|
178
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
164
179
|
end
|
|
165
180
|
|
|
166
181
|
# Sets the firmware pointer for BrickletRotaryPotiV2#write_firmware. The pointer has
|
|
@@ -170,7 +185,9 @@ module Tinkerforge
|
|
|
170
185
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
171
186
|
# necessary to call it in a normal user program.
|
|
172
187
|
def set_write_firmware_pointer(pointer)
|
|
173
|
-
|
|
188
|
+
check_validity
|
|
189
|
+
|
|
190
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
174
191
|
end
|
|
175
192
|
|
|
176
193
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -182,7 +199,9 @@ module Tinkerforge
|
|
|
182
199
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
183
200
|
# necessary to call it in a normal user program.
|
|
184
201
|
def write_firmware(data)
|
|
185
|
-
|
|
202
|
+
check_validity
|
|
203
|
+
|
|
204
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
186
205
|
end
|
|
187
206
|
|
|
188
207
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -193,22 +212,28 @@ module Tinkerforge
|
|
|
193
212
|
#
|
|
194
213
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
195
214
|
def set_status_led_config(config)
|
|
196
|
-
|
|
215
|
+
check_validity
|
|
216
|
+
|
|
217
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
197
218
|
end
|
|
198
219
|
|
|
199
220
|
# Returns the configuration as set by BrickletRotaryPotiV2#set_status_led_config
|
|
200
221
|
def get_status_led_config
|
|
201
|
-
|
|
222
|
+
check_validity
|
|
223
|
+
|
|
224
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
202
225
|
end
|
|
203
226
|
|
|
204
|
-
# Returns the temperature
|
|
227
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
205
228
|
# value returned is not the ambient temperature!
|
|
206
229
|
#
|
|
207
230
|
# The temperature is only proportional to the real temperature and it has bad
|
|
208
231
|
# accuracy. Practically it is only useful as an indicator for
|
|
209
232
|
# temperature changes.
|
|
210
233
|
def get_chip_temperature
|
|
211
|
-
|
|
234
|
+
check_validity
|
|
235
|
+
|
|
236
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
212
237
|
end
|
|
213
238
|
|
|
214
239
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -218,7 +243,9 @@ module Tinkerforge
|
|
|
218
243
|
# calling functions on the existing ones will result in
|
|
219
244
|
# undefined behavior!
|
|
220
245
|
def reset
|
|
221
|
-
|
|
246
|
+
check_validity
|
|
247
|
+
|
|
248
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
222
249
|
end
|
|
223
250
|
|
|
224
251
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -227,25 +254,31 @@ module Tinkerforge
|
|
|
227
254
|
#
|
|
228
255
|
# We recommend that you use Brick Viewer to change the UID.
|
|
229
256
|
def write_uid(uid)
|
|
230
|
-
|
|
257
|
+
check_validity
|
|
258
|
+
|
|
259
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
231
260
|
end
|
|
232
261
|
|
|
233
262
|
# Returns the current UID as an integer. Encode as
|
|
234
263
|
# Base58 to get the usual string version.
|
|
235
264
|
def read_uid
|
|
236
|
-
|
|
265
|
+
check_validity
|
|
266
|
+
|
|
267
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
237
268
|
end
|
|
238
269
|
|
|
239
270
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
240
271
|
# the position, the hardware and firmware version as well as the
|
|
241
272
|
# device identifier.
|
|
242
273
|
#
|
|
243
|
-
# The position can be 'a', 'b', 'c' or '
|
|
274
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
275
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
276
|
+
# position 'z'.
|
|
244
277
|
#
|
|
245
278
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
246
279
|
# |device_identifier_constant|
|
|
247
280
|
def get_identity
|
|
248
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
281
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
249
282
|
end
|
|
250
283
|
|
|
251
284
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2021-05-06. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.29 #
|
|
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
|
# Communicates with RS232 devices
|
|
14
16
|
class BrickletRS232 < Device
|
|
@@ -28,6 +30,14 @@ module Tinkerforge
|
|
|
28
30
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
29
31
|
CALLBACK_ERROR = 9
|
|
30
32
|
|
|
33
|
+
# This callback is called if at least one frame of data is readable. The frame size is configured with BrickletRS232#set_frame_readable_callback_configuration.
|
|
34
|
+
# The frame count parameter is the number of frames that can be read.
|
|
35
|
+
# This callback is triggered only once until BrickletRS232#read or BrickletRS232#read_frame is called. This means, that if you have configured a frame size of X bytes,
|
|
36
|
+
# you can read exactly X bytes using the BrickletRS232#read_frame function, every time the callback triggers without checking the frame count parameter.
|
|
37
|
+
#
|
|
38
|
+
# .. versionadded:: 2.0.4$nbsp;(Plugin)
|
|
39
|
+
CALLBACK_FRAME_READABLE = 13
|
|
40
|
+
|
|
31
41
|
CALLBACK_READ_CALLBACK = 8 # :nodoc: for backward compatibility
|
|
32
42
|
CALLBACK_ERROR_CALLBACK = 9 # :nodoc: for backward compatibility
|
|
33
43
|
|
|
@@ -39,6 +49,9 @@ module Tinkerforge
|
|
|
39
49
|
FUNCTION_SET_CONFIGURATION = 6 # :nodoc:
|
|
40
50
|
FUNCTION_GET_CONFIGURATION = 7 # :nodoc:
|
|
41
51
|
FUNCTION_SET_BREAK_CONDITION = 10 # :nodoc:
|
|
52
|
+
FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION = 11 # :nodoc:
|
|
53
|
+
FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION = 12 # :nodoc:
|
|
54
|
+
FUNCTION_READ_FRAME = 14 # :nodoc:
|
|
42
55
|
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
43
56
|
|
|
44
57
|
BAUDRATE_300 = 0 # :nodoc:
|
|
@@ -76,9 +89,9 @@ module Tinkerforge
|
|
|
76
89
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
77
90
|
# the IP Connection <tt>ipcon</tt>.
|
|
78
91
|
def initialize(uid, ipcon)
|
|
79
|
-
super uid, ipcon
|
|
92
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
80
93
|
|
|
81
|
-
@api_version = [2, 0,
|
|
94
|
+
@api_version = [2, 0, 3]
|
|
82
95
|
|
|
83
96
|
@response_expected[FUNCTION_WRITE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
84
97
|
@response_expected[FUNCTION_READ] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
@@ -88,11 +101,16 @@ module Tinkerforge
|
|
|
88
101
|
@response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
|
89
102
|
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
90
103
|
@response_expected[FUNCTION_SET_BREAK_CONDITION] = RESPONSE_EXPECTED_FALSE
|
|
104
|
+
@response_expected[FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
105
|
+
@response_expected[FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
106
|
+
@response_expected[FUNCTION_READ_FRAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
91
107
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
92
108
|
|
|
93
|
-
@callback_formats[CALLBACK_READ] = 'k60 C'
|
|
94
|
-
@callback_formats[CALLBACK_ERROR] = 'C'
|
|
109
|
+
@callback_formats[CALLBACK_READ] = [69, 'k60 C']
|
|
110
|
+
@callback_formats[CALLBACK_ERROR] = [9, 'C']
|
|
111
|
+
@callback_formats[CALLBACK_FRAME_READABLE] = [9, 'C']
|
|
95
112
|
|
|
113
|
+
@ipcon.add_device self
|
|
96
114
|
end
|
|
97
115
|
|
|
98
116
|
# Writes a string of up to 60 characters to the RS232 interface. The string
|
|
@@ -105,75 +123,118 @@ module Tinkerforge
|
|
|
105
123
|
# See BrickletRS232#set_configuration for configuration possibilities
|
|
106
124
|
# regarding baudrate, parity and so on.
|
|
107
125
|
def write(message, length)
|
|
108
|
-
|
|
126
|
+
check_validity
|
|
127
|
+
|
|
128
|
+
send_request FUNCTION_WRITE, [message, length], 'k60 C', 9, 'C'
|
|
109
129
|
end
|
|
110
130
|
|
|
111
131
|
# Returns the currently buffered message. The maximum length
|
|
112
|
-
# of message is 60. If the length is
|
|
113
|
-
# new data available.
|
|
132
|
+
# of message is 60. If the returned length is 0, no new data was available.
|
|
114
133
|
#
|
|
115
134
|
# Instead of polling with this function, you can also use
|
|
116
135
|
# callbacks. See BrickletRS232#enable_read_callback and CALLBACK_READ callback.
|
|
117
136
|
def read
|
|
118
|
-
|
|
137
|
+
check_validity
|
|
138
|
+
|
|
139
|
+
send_request FUNCTION_READ, [], '', 69, 'k60 C'
|
|
119
140
|
end
|
|
120
141
|
|
|
121
|
-
# Enables the CALLBACK_READ callback.
|
|
142
|
+
# Enables the CALLBACK_READ callback. This will disable the CALLBACK_FRAME_READABLE callback.
|
|
122
143
|
#
|
|
123
144
|
# By default the callback is disabled.
|
|
124
145
|
def enable_read_callback
|
|
125
|
-
|
|
146
|
+
check_validity
|
|
147
|
+
|
|
148
|
+
send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 8, ''
|
|
126
149
|
end
|
|
127
150
|
|
|
128
151
|
# Disables the CALLBACK_READ callback.
|
|
129
152
|
#
|
|
130
153
|
# By default the callback is disabled.
|
|
131
154
|
def disable_read_callback
|
|
132
|
-
|
|
155
|
+
check_validity
|
|
156
|
+
|
|
157
|
+
send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 8, ''
|
|
133
158
|
end
|
|
134
159
|
|
|
135
160
|
# Returns *true* if the CALLBACK_READ callback is enabled,
|
|
136
161
|
# *false* otherwise.
|
|
137
162
|
def is_read_callback_enabled
|
|
138
|
-
|
|
163
|
+
check_validity
|
|
164
|
+
|
|
165
|
+
send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 9, '?'
|
|
139
166
|
end
|
|
140
167
|
|
|
141
|
-
# Sets the configuration for the RS232 communication.
|
|
142
|
-
#
|
|
143
|
-
# * Baudrate between 300 and 230400 baud.
|
|
144
|
-
# * Parity of none, odd, even or forced parity.
|
|
145
|
-
# * Stopbits can be 1 or 2.
|
|
146
|
-
# * Word length of 5 to 8.
|
|
147
|
-
# * Hard-/Software flow control can either be on or off but not both simultaneously on.
|
|
168
|
+
# Sets the configuration for the RS232 communication.
|
|
148
169
|
#
|
|
149
|
-
#
|
|
170
|
+
# Hard-/Software flow control can either be on or off but not both simultaneously on.
|
|
150
171
|
def set_configuration(baudrate, parity, stopbits, wordlength, hardware_flowcontrol, software_flowcontrol)
|
|
151
|
-
|
|
172
|
+
check_validity
|
|
173
|
+
|
|
174
|
+
send_request FUNCTION_SET_CONFIGURATION, [baudrate, parity, stopbits, wordlength, hardware_flowcontrol, software_flowcontrol], 'C C C C C C', 8, ''
|
|
152
175
|
end
|
|
153
176
|
|
|
154
177
|
# Returns the configuration as set by BrickletRS232#set_configuration.
|
|
155
178
|
def get_configuration
|
|
156
|
-
|
|
179
|
+
check_validity
|
|
180
|
+
|
|
181
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 14, 'C C C C C C'
|
|
157
182
|
end
|
|
158
183
|
|
|
159
184
|
# Sets a break condition (the TX output is forced to a logic 0 state).
|
|
160
|
-
# The parameter sets the hold-time of the break condition
|
|
185
|
+
# The parameter sets the hold-time of the break condition.
|
|
161
186
|
#
|
|
162
187
|
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
|
163
188
|
def set_break_condition(break_time)
|
|
164
|
-
|
|
189
|
+
check_validity
|
|
190
|
+
|
|
191
|
+
send_request FUNCTION_SET_BREAK_CONDITION, [break_time], 'S', 8, ''
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Configures the CALLBACK_FRAME_READABLE callback. The frame size is the number of bytes, that have to be readable to trigger the callback.
|
|
195
|
+
# A frame size of 0 disables the callback. A frame size greater than 0 enables the callback and disables the CALLBACK_READ callback.
|
|
196
|
+
#
|
|
197
|
+
# By default the callback is disabled.
|
|
198
|
+
#
|
|
199
|
+
# .. versionadded:: 2.0.4$nbsp;(Plugin)
|
|
200
|
+
def set_frame_readable_callback_configuration(frame_size)
|
|
201
|
+
check_validity
|
|
202
|
+
|
|
203
|
+
send_request FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION, [frame_size], 'C', 8, ''
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Returns the callback configuration as set by BrickletRS232#set_frame_readable_callback_configuration.
|
|
207
|
+
#
|
|
208
|
+
# .. versionadded:: 2.0.4$nbsp;(Plugin)
|
|
209
|
+
def get_frame_readable_callback_configuration
|
|
210
|
+
check_validity
|
|
211
|
+
|
|
212
|
+
send_request FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION, [], '', 9, 'C'
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Returns up to one frame of bytes from the read buffer.
|
|
216
|
+
# The frame size is configured with BrickletRS232#set_frame_readable_callback_configuration.
|
|
217
|
+
# If the returned length is 0, no new data was available.
|
|
218
|
+
#
|
|
219
|
+
# .. versionadded:: 2.0.4$nbsp;(Plugin)
|
|
220
|
+
def read_frame
|
|
221
|
+
check_validity
|
|
222
|
+
|
|
223
|
+
send_request FUNCTION_READ_FRAME, [], '', 69, 'k60 C'
|
|
165
224
|
end
|
|
166
225
|
|
|
167
226
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
168
227
|
# the position, the hardware and firmware version as well as the
|
|
169
228
|
# device identifier.
|
|
170
229
|
#
|
|
171
|
-
# 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'.
|
|
172
233
|
#
|
|
173
234
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
174
235
|
# |device_identifier_constant|
|
|
175
236
|
def get_identity
|
|
176
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
237
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
177
238
|
end
|
|
178
239
|
|
|
179
240
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|