tinkerforge 2.1.24 → 2.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tinkerforge/brick_dc.rb +155 -74
- data/lib/tinkerforge/brick_hat.rb +70 -30
- data/lib/tinkerforge/brick_hat_zero.rb +56 -22
- data/lib/tinkerforge/brick_imu.rb +184 -77
- data/lib/tinkerforge/brick_imu_v2.rb +208 -105
- data/lib/tinkerforge/brick_master.rb +484 -182
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +185 -101
- data/lib/tinkerforge/brick_silent_stepper.rb +246 -166
- data/lib/tinkerforge/brick_stepper.rb +210 -98
- data/lib/tinkerforge/bricklet_accelerometer.rb +58 -23
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +105 -54
- data/lib/tinkerforge/bricklet_air_quality.rb +117 -59
- data/lib/tinkerforge/bricklet_ambient_light.rb +51 -21
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +40 -22
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -25
- data/lib/tinkerforge/bricklet_analog_in.rb +63 -25
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +57 -23
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +67 -25
- data/lib/tinkerforge/bricklet_analog_out.rb +23 -9
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +20 -8
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +54 -20
- data/lib/tinkerforge/bricklet_barometer.rb +66 -26
- data/lib/tinkerforge/bricklet_barometer_v2.rb +99 -37
- data/lib/tinkerforge/bricklet_can.rb +83 -18
- data/lib/tinkerforge/bricklet_can_v2.rb +172 -38
- data/lib/tinkerforge/bricklet_co2.rb +34 -14
- data/lib/tinkerforge/bricklet_co2_v2.rb +97 -37
- data/lib/tinkerforge/bricklet_color.rb +69 -27
- data/lib/tinkerforge/bricklet_color_v2.rb +87 -33
- data/lib/tinkerforge/bricklet_compass.rb +78 -30
- data/lib/tinkerforge/bricklet_current12.rb +58 -24
- data/lib/tinkerforge/bricklet_current25.rb +58 -24
- data/lib/tinkerforge/bricklet_distance_ir.rb +57 -23
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +83 -31
- data/lib/tinkerforge/bricklet_distance_us.rb +40 -16
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +67 -25
- data/lib/tinkerforge/bricklet_dmx.rb +88 -34
- data/lib/tinkerforge/bricklet_dual_button.rb +24 -10
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -24
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -11
- data/lib/tinkerforge/bricklet_dust_detector.rb +40 -16
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +88 -32
- data/lib/tinkerforge/bricklet_energy_monitor.rb +73 -27
- data/lib/tinkerforge/bricklet_gps.rb +64 -26
- data/lib/tinkerforge/bricklet_gps_v2.rb +117 -47
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -23
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +71 -27
- data/lib/tinkerforge/bricklet_humidity.rb +51 -21
- data/lib/tinkerforge/bricklet_humidity_v2.rb +83 -31
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +38 -14
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +81 -29
- data/lib/tinkerforge/bricklet_industrial_counter.rb +101 -39
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +45 -17
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +77 -29
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -14
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +73 -27
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +40 -16
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -29
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +49 -19
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +82 -30
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +61 -23
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -14
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -25
- data/lib/tinkerforge/bricklet_io16.rb +55 -21
- data/lib/tinkerforge/bricklet_io16_v2.rb +90 -34
- data/lib/tinkerforge/bricklet_io4.rb +55 -23
- data/lib/tinkerforge/bricklet_io4_v2.rb +96 -36
- data/lib/tinkerforge/bricklet_isolator.rb +72 -28
- data/lib/tinkerforge/bricklet_joystick.rb +59 -25
- data/lib/tinkerforge/bricklet_joystick_v2.rb +68 -26
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +82 -32
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +96 -36
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +192 -70
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +45 -18
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +58 -23
- data/lib/tinkerforge/bricklet_led_strip.rb +60 -22
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +91 -46
- data/lib/tinkerforge/bricklet_line.rb +34 -14
- data/lib/tinkerforge/bricklet_linear_poti.rb +51 -21
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -21
- data/lib/tinkerforge/bricklet_load_cell.rb +61 -23
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +80 -30
- data/lib/tinkerforge/bricklet_moisture.rb +40 -16
- data/lib/tinkerforge/bricklet_motion_detector.rb +22 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -24
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -27
- data/lib/tinkerforge/bricklet_multi_touch.rb +31 -13
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -28
- data/lib/tinkerforge/bricklet_nfc.rb +123 -58
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +33 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +29 -11
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +66 -24
- data/lib/tinkerforge/bricklet_oled_64x48.rb +29 -11
- data/lib/tinkerforge/bricklet_one_wire.rb +66 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -27
- data/lib/tinkerforge/bricklet_particulate_matter.rb +75 -30
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -9
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -10
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +80 -42
- data/lib/tinkerforge/bricklet_ptc.rb +74 -42
- data/lib/tinkerforge/bricklet_ptc_v2.rb +95 -48
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -33
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -44
- data/lib/tinkerforge/bricklet_remote_switch.rb +39 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +87 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +18 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +62 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +79 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +52 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +39 -19
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -24
- data/lib/tinkerforge/bricklet_rotary_poti.rb +53 -28
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -23
- data/lib/tinkerforge/bricklet_rs232.rb +90 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +118 -44
- data/lib/tinkerforge/bricklet_rs485.rb +223 -95
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +25 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -35
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +25 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +59 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +35 -18
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +72 -31
- data/lib/tinkerforge/bricklet_temperature.rb +40 -16
- data/lib/tinkerforge/bricklet_temperature_ir.rb +57 -23
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +71 -27
- data/lib/tinkerforge/bricklet_temperature_v2.rb +61 -25
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +105 -44
- data/lib/tinkerforge/bricklet_thermocouple.rb +45 -24
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -27
- data/lib/tinkerforge/bricklet_tilt.rb +24 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +36 -18
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +85 -37
- data/lib/tinkerforge/bricklet_voltage.rb +52 -28
- data/lib/tinkerforge/bricklet_voltage_current.rb +91 -73
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +90 -68
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +80 -30
- data/lib/tinkerforge/device_display_names.rb +163 -0
- data/lib/tinkerforge/ip_connection.rb +151 -32
- data/lib/tinkerforge/version.rb +1 -1
- metadata +3 -2
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2020-04-07. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# 360° rotary encoder with push-button
|
|
14
16
|
class BrickletRotaryEncoderV2 < Device
|
|
@@ -68,7 +70,7 @@ module Tinkerforge
|
|
|
68
70
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
69
71
|
# the IP Connection <tt>ipcon</tt>.
|
|
70
72
|
def initialize(uid, ipcon)
|
|
71
|
-
super uid, ipcon
|
|
73
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
72
74
|
|
|
73
75
|
@api_version = [2, 0, 1]
|
|
74
76
|
|
|
@@ -89,10 +91,11 @@ module Tinkerforge
|
|
|
89
91
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
90
92
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
91
93
|
|
|
92
|
-
@callback_formats[CALLBACK_COUNT] = 'l'
|
|
93
|
-
@callback_formats[CALLBACK_PRESSED] = ''
|
|
94
|
-
@callback_formats[CALLBACK_RELEASED] = ''
|
|
94
|
+
@callback_formats[CALLBACK_COUNT] = [12, 'l']
|
|
95
|
+
@callback_formats[CALLBACK_PRESSED] = [8, '']
|
|
96
|
+
@callback_formats[CALLBACK_RELEASED] = [8, '']
|
|
95
97
|
|
|
98
|
+
@ipcon.add_device self
|
|
96
99
|
end
|
|
97
100
|
|
|
98
101
|
# Returns the current count of the encoder. If you set reset
|
|
@@ -109,7 +112,9 @@ module Tinkerforge
|
|
|
109
112
|
# CALLBACK_COUNT callback. You can set the callback configuration
|
|
110
113
|
# with BrickletRotaryEncoderV2#set_count_callback_configuration.
|
|
111
114
|
def get_count(reset)
|
|
112
|
-
|
|
115
|
+
check_validity
|
|
116
|
+
|
|
117
|
+
send_request FUNCTION_GET_COUNT, [reset], '?', 12, 'l'
|
|
113
118
|
end
|
|
114
119
|
|
|
115
120
|
# The period is the period with which the CALLBACK_COUNT callback is triggered
|
|
@@ -138,12 +143,16 @@ module Tinkerforge
|
|
|
138
143
|
#
|
|
139
144
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
|
140
145
|
def set_count_callback_configuration(period, value_has_to_change, option, min, max)
|
|
141
|
-
|
|
146
|
+
check_validity
|
|
147
|
+
|
|
148
|
+
send_request FUNCTION_SET_COUNT_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
|
|
142
149
|
end
|
|
143
150
|
|
|
144
151
|
# Returns the callback configuration as set by BrickletRotaryEncoderV2#set_count_callback_configuration.
|
|
145
152
|
def get_count_callback_configuration
|
|
146
|
-
|
|
153
|
+
check_validity
|
|
154
|
+
|
|
155
|
+
send_request FUNCTION_GET_COUNT_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
|
|
147
156
|
end
|
|
148
157
|
|
|
149
158
|
# Returns *true* if the button is pressed and *false* otherwise.
|
|
@@ -151,7 +160,9 @@ module Tinkerforge
|
|
|
151
160
|
# It is recommended to use the CALLBACK_PRESSED and CALLBACK_RELEASED callbacks
|
|
152
161
|
# to handle the button.
|
|
153
162
|
def is_pressed
|
|
154
|
-
|
|
163
|
+
check_validity
|
|
164
|
+
|
|
165
|
+
send_request FUNCTION_IS_PRESSED, [], '', 9, '?'
|
|
155
166
|
end
|
|
156
167
|
|
|
157
168
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -166,7 +177,9 @@ module Tinkerforge
|
|
|
166
177
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
167
178
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
168
179
|
def get_spitfp_error_count
|
|
169
|
-
|
|
180
|
+
check_validity
|
|
181
|
+
|
|
182
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
170
183
|
end
|
|
171
184
|
|
|
172
185
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -179,12 +192,16 @@ module Tinkerforge
|
|
|
179
192
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
180
193
|
# necessary to call it in a normal user program.
|
|
181
194
|
def set_bootloader_mode(mode)
|
|
182
|
-
|
|
195
|
+
check_validity
|
|
196
|
+
|
|
197
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
183
198
|
end
|
|
184
199
|
|
|
185
200
|
# Returns the current bootloader mode, see BrickletRotaryEncoderV2#set_bootloader_mode.
|
|
186
201
|
def get_bootloader_mode
|
|
187
|
-
|
|
202
|
+
check_validity
|
|
203
|
+
|
|
204
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
188
205
|
end
|
|
189
206
|
|
|
190
207
|
# Sets the firmware pointer for BrickletRotaryEncoderV2#write_firmware. The pointer has
|
|
@@ -194,7 +211,9 @@ module Tinkerforge
|
|
|
194
211
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
195
212
|
# necessary to call it in a normal user program.
|
|
196
213
|
def set_write_firmware_pointer(pointer)
|
|
197
|
-
|
|
214
|
+
check_validity
|
|
215
|
+
|
|
216
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
198
217
|
end
|
|
199
218
|
|
|
200
219
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -206,7 +225,9 @@ module Tinkerforge
|
|
|
206
225
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
207
226
|
# necessary to call it in a normal user program.
|
|
208
227
|
def write_firmware(data)
|
|
209
|
-
|
|
228
|
+
check_validity
|
|
229
|
+
|
|
230
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
210
231
|
end
|
|
211
232
|
|
|
212
233
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -217,22 +238,28 @@ module Tinkerforge
|
|
|
217
238
|
#
|
|
218
239
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
219
240
|
def set_status_led_config(config)
|
|
220
|
-
|
|
241
|
+
check_validity
|
|
242
|
+
|
|
243
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
221
244
|
end
|
|
222
245
|
|
|
223
246
|
# Returns the configuration as set by BrickletRotaryEncoderV2#set_status_led_config
|
|
224
247
|
def get_status_led_config
|
|
225
|
-
|
|
248
|
+
check_validity
|
|
249
|
+
|
|
250
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
226
251
|
end
|
|
227
252
|
|
|
228
|
-
# Returns the temperature
|
|
253
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
229
254
|
# value returned is not the ambient temperature!
|
|
230
255
|
#
|
|
231
256
|
# The temperature is only proportional to the real temperature and it has bad
|
|
232
257
|
# accuracy. Practically it is only useful as an indicator for
|
|
233
258
|
# temperature changes.
|
|
234
259
|
def get_chip_temperature
|
|
235
|
-
|
|
260
|
+
check_validity
|
|
261
|
+
|
|
262
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
236
263
|
end
|
|
237
264
|
|
|
238
265
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -242,7 +269,9 @@ module Tinkerforge
|
|
|
242
269
|
# calling functions on the existing ones will result in
|
|
243
270
|
# undefined behavior!
|
|
244
271
|
def reset
|
|
245
|
-
|
|
272
|
+
check_validity
|
|
273
|
+
|
|
274
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
246
275
|
end
|
|
247
276
|
|
|
248
277
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -251,25 +280,32 @@ module Tinkerforge
|
|
|
251
280
|
#
|
|
252
281
|
# We recommend that you use Brick Viewer to change the UID.
|
|
253
282
|
def write_uid(uid)
|
|
254
|
-
|
|
283
|
+
check_validity
|
|
284
|
+
|
|
285
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
255
286
|
end
|
|
256
287
|
|
|
257
288
|
# Returns the current UID as an integer. Encode as
|
|
258
289
|
# Base58 to get the usual string version.
|
|
259
290
|
def read_uid
|
|
260
|
-
|
|
291
|
+
check_validity
|
|
292
|
+
|
|
293
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
261
294
|
end
|
|
262
295
|
|
|
263
296
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
264
297
|
# the position, the hardware and firmware version as well as the
|
|
265
298
|
# device identifier.
|
|
266
299
|
#
|
|
267
|
-
# The position can be 'a', 'b', 'c' or '
|
|
300
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
301
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
302
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
303
|
+
# position 'z'.
|
|
268
304
|
#
|
|
269
305
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
270
306
|
# |device_identifier_constant|
|
|
271
307
|
def get_identity
|
|
272
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
308
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
273
309
|
end
|
|
274
310
|
|
|
275
311
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2020-04-07. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# 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,31 @@ 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
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
244
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
245
|
+
# position 'z'.
|
|
221
246
|
#
|
|
222
247
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
223
248
|
# |device_identifier_constant|
|
|
224
249
|
def get_identity
|
|
225
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
250
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
226
251
|
end
|
|
227
252
|
|
|
228
253
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2020-04-07. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# 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,32 @@ 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
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
|
276
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
|
277
|
+
# position 'z'.
|
|
244
278
|
#
|
|
245
279
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
246
280
|
# |device_identifier_constant|
|
|
247
281
|
def get_identity
|
|
248
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
282
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
249
283
|
end
|
|
250
284
|
|
|
251
285
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|