tinkerforge 2.1.22 → 2.1.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
@@ -1,26 +1,38 @@
|
|
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
|
# Galvanically isolates any Bricklet from any Brick
|
14
16
|
class BrickletIsolator < Device
|
15
17
|
DEVICE_IDENTIFIER = 2122 # :nodoc:
|
16
18
|
DEVICE_DISPLAY_NAME = 'Isolator Bricklet' # :nodoc:
|
17
19
|
|
20
|
+
# This callback is triggered periodically according to the configuration set by
|
21
|
+
# BrickletIsolator#set_statistics_callback_configuration.
|
22
|
+
#
|
23
|
+
# The parameters are the same as BrickletIsolator#get_statistics.
|
24
|
+
#
|
25
|
+
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
26
|
+
CALLBACK_STATISTICS = 9
|
27
|
+
|
18
28
|
FUNCTION_GET_STATISTICS = 1 # :nodoc:
|
19
29
|
FUNCTION_SET_SPITFP_BAUDRATE_CONFIG = 2 # :nodoc:
|
20
30
|
FUNCTION_GET_SPITFP_BAUDRATE_CONFIG = 3 # :nodoc:
|
21
31
|
FUNCTION_SET_SPITFP_BAUDRATE = 4 # :nodoc:
|
22
32
|
FUNCTION_GET_SPITFP_BAUDRATE = 5 # :nodoc:
|
23
33
|
FUNCTION_GET_ISOLATOR_SPITFP_ERROR_COUNT = 6 # :nodoc:
|
34
|
+
FUNCTION_SET_STATISTICS_CALLBACK_CONFIGURATION = 7 # :nodoc:
|
35
|
+
FUNCTION_GET_STATISTICS_CALLBACK_CONFIGURATION = 8 # :nodoc:
|
24
36
|
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
25
37
|
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
26
38
|
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
@@ -53,9 +65,9 @@ module Tinkerforge
|
|
53
65
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
54
66
|
# the IP Connection <tt>ipcon</tt>.
|
55
67
|
def initialize(uid, ipcon)
|
56
|
-
super uid, ipcon
|
68
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
57
69
|
|
58
|
-
@api_version = [2, 0,
|
70
|
+
@api_version = [2, 0, 1]
|
59
71
|
|
60
72
|
@response_expected[FUNCTION_GET_STATISTICS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
61
73
|
@response_expected[FUNCTION_SET_SPITFP_BAUDRATE_CONFIG] = RESPONSE_EXPECTED_FALSE
|
@@ -63,6 +75,8 @@ module Tinkerforge
|
|
63
75
|
@response_expected[FUNCTION_SET_SPITFP_BAUDRATE] = RESPONSE_EXPECTED_FALSE
|
64
76
|
@response_expected[FUNCTION_GET_SPITFP_BAUDRATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
65
77
|
@response_expected[FUNCTION_GET_ISOLATOR_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
78
|
+
@response_expected[FUNCTION_SET_STATISTICS_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
79
|
+
@response_expected[FUNCTION_GET_STATISTICS_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
66
80
|
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
67
81
|
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
68
82
|
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
@@ -76,12 +90,16 @@ module Tinkerforge
|
|
76
90
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
77
91
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
78
92
|
|
93
|
+
@callback_formats[CALLBACK_STATISTICS] = [26, 'L L S Z8']
|
79
94
|
|
95
|
+
@ipcon.add_device self
|
80
96
|
end
|
81
97
|
|
82
98
|
# Returns statistics for the Isolator Bricklet.
|
83
99
|
def get_statistics
|
84
|
-
|
100
|
+
check_validity
|
101
|
+
|
102
|
+
send_request FUNCTION_GET_STATISTICS, [], '', 26, 'L L S Z8'
|
85
103
|
end
|
86
104
|
|
87
105
|
# The SPITF protocol can be used with a dynamic baudrate. If the dynamic baudrate is
|
@@ -91,8 +109,8 @@ module Tinkerforge
|
|
91
109
|
# The baudrate for communication config between
|
92
110
|
# Brick and Isolator Bricklet can be set through the API of the Brick.
|
93
111
|
#
|
94
|
-
# The baudrate will be increased exponentially if lots of data is
|
95
|
-
# decreased linearly if little data is
|
112
|
+
# The baudrate will be increased exponentially if lots of data is sent/received and
|
113
|
+
# decreased linearly if little data is sent/received.
|
96
114
|
#
|
97
115
|
# This lowers the baudrate in applications where little data is transferred (e.g.
|
98
116
|
# a weather station) and increases the robustness. If there is lots of data to transfer
|
@@ -105,25 +123,23 @@ module Tinkerforge
|
|
105
123
|
# The maximum value of the baudrate can be set per port with the function
|
106
124
|
# BrickletIsolator#set_spitfp_baudrate. If the dynamic baudrate is disabled, the baudrate
|
107
125
|
# as set by BrickletIsolator#set_spitfp_baudrate will be used statically.
|
108
|
-
#
|
109
|
-
# The minimum dynamic baudrate has a value range of 400000 to 2000000 baud.
|
110
|
-
#
|
111
|
-
# By default dynamic baudrate is enabled and the minimum dynamic baudrate is 400000.
|
112
126
|
def set_spitfp_baudrate_config(enable_dynamic_baudrate, minimum_dynamic_baudrate)
|
113
|
-
|
127
|
+
check_validity
|
128
|
+
|
129
|
+
send_request FUNCTION_SET_SPITFP_BAUDRATE_CONFIG, [enable_dynamic_baudrate, minimum_dynamic_baudrate], '? L', 8, ''
|
114
130
|
end
|
115
131
|
|
116
132
|
# Returns the baudrate config, see BrickletIsolator#set_spitfp_baudrate_config.
|
117
133
|
def get_spitfp_baudrate_config
|
118
|
-
|
134
|
+
check_validity
|
135
|
+
|
136
|
+
send_request FUNCTION_GET_SPITFP_BAUDRATE_CONFIG, [], '', 13, '? L'
|
119
137
|
end
|
120
138
|
|
121
139
|
# Sets the baudrate for a the communication between Isolator Bricklet
|
122
140
|
# and the connected Bricklet. The baudrate for communication between
|
123
141
|
# Brick and Isolator Bricklet can be set through the API of the Brick.
|
124
142
|
#
|
125
|
-
# The baudrate can be in the range 400000 to 2000000.
|
126
|
-
#
|
127
143
|
# If you want to increase the throughput of Bricklets you can increase
|
128
144
|
# the baudrate. If you get a high error count because of high
|
129
145
|
# interference (see BrickletIsolator#get_spitfp_error_count) you can decrease the
|
@@ -133,17 +149,19 @@ module Tinkerforge
|
|
133
149
|
# function corresponds to the maximum baudrate (see BrickletIsolator#set_spitfp_baudrate_config).
|
134
150
|
#
|
135
151
|
# Regulatory testing is done with the default baudrate. If CE compatibility
|
136
|
-
# or similar is necessary in
|
152
|
+
# or similar is necessary in your applications we recommend to not change
|
137
153
|
# the baudrate.
|
138
|
-
#
|
139
|
-
# The default baudrate for all ports is 1400000.
|
140
154
|
def set_spitfp_baudrate(baudrate)
|
141
|
-
|
155
|
+
check_validity
|
156
|
+
|
157
|
+
send_request FUNCTION_SET_SPITFP_BAUDRATE, [baudrate], 'L', 8, ''
|
142
158
|
end
|
143
159
|
|
144
160
|
# Returns the baudrate, see BrickletIsolator#set_spitfp_baudrate.
|
145
161
|
def get_spitfp_baudrate
|
146
|
-
|
162
|
+
check_validity
|
163
|
+
|
164
|
+
send_request FUNCTION_GET_SPITFP_BAUDRATE, [], '', 12, 'L'
|
147
165
|
end
|
148
166
|
|
149
167
|
# Returns the error count for the communication between Isolator Bricklet and
|
@@ -157,7 +175,36 @@ module Tinkerforge
|
|
157
175
|
# * framing errors and
|
158
176
|
# * overflow errors.
|
159
177
|
def get_isolator_spitfp_error_count
|
160
|
-
|
178
|
+
check_validity
|
179
|
+
|
180
|
+
send_request FUNCTION_GET_ISOLATOR_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
181
|
+
end
|
182
|
+
|
183
|
+
# The period is the period with which the CALLBACK_STATISTICS
|
184
|
+
# callback is triggered periodically. A value of 0 turns the callback off.
|
185
|
+
#
|
186
|
+
# If the `value has to change`-parameter is set to true, the callback is only
|
187
|
+
# triggered after the value has changed. If the value didn't change within the
|
188
|
+
# period, the callback is triggered immediately on change.
|
189
|
+
#
|
190
|
+
# If it is set to false, the callback is continuously triggered with the period,
|
191
|
+
# independent of the value.
|
192
|
+
#
|
193
|
+
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
194
|
+
def set_statistics_callback_configuration(period, value_has_to_change)
|
195
|
+
check_validity
|
196
|
+
|
197
|
+
send_request FUNCTION_SET_STATISTICS_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
|
198
|
+
end
|
199
|
+
|
200
|
+
# Returns the callback configuration as set by
|
201
|
+
# BrickletIsolator#set_statistics_callback_configuration.
|
202
|
+
#
|
203
|
+
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
204
|
+
def get_statistics_callback_configuration
|
205
|
+
check_validity
|
206
|
+
|
207
|
+
send_request FUNCTION_GET_STATISTICS_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
|
161
208
|
end
|
162
209
|
|
163
210
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -172,7 +219,9 @@ module Tinkerforge
|
|
172
219
|
# The errors counts are for errors that occur on the Bricklet side. All
|
173
220
|
# Bricks have a similar function that returns the errors on the Brick side.
|
174
221
|
def get_spitfp_error_count
|
175
|
-
|
222
|
+
check_validity
|
223
|
+
|
224
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
176
225
|
end
|
177
226
|
|
178
227
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -185,12 +234,16 @@ module Tinkerforge
|
|
185
234
|
# This function is used by Brick Viewer during flashing. It should not be
|
186
235
|
# necessary to call it in a normal user program.
|
187
236
|
def set_bootloader_mode(mode)
|
188
|
-
|
237
|
+
check_validity
|
238
|
+
|
239
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
189
240
|
end
|
190
241
|
|
191
242
|
# Returns the current bootloader mode, see BrickletIsolator#set_bootloader_mode.
|
192
243
|
def get_bootloader_mode
|
193
|
-
|
244
|
+
check_validity
|
245
|
+
|
246
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
194
247
|
end
|
195
248
|
|
196
249
|
# Sets the firmware pointer for BrickletIsolator#write_firmware. The pointer has
|
@@ -200,7 +253,9 @@ module Tinkerforge
|
|
200
253
|
# This function is used by Brick Viewer during flashing. It should not be
|
201
254
|
# necessary to call it in a normal user program.
|
202
255
|
def set_write_firmware_pointer(pointer)
|
203
|
-
|
256
|
+
check_validity
|
257
|
+
|
258
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
204
259
|
end
|
205
260
|
|
206
261
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -212,7 +267,9 @@ module Tinkerforge
|
|
212
267
|
# This function is used by Brick Viewer during flashing. It should not be
|
213
268
|
# necessary to call it in a normal user program.
|
214
269
|
def write_firmware(data)
|
215
|
-
|
270
|
+
check_validity
|
271
|
+
|
272
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
216
273
|
end
|
217
274
|
|
218
275
|
# Sets the status LED configuration. By default the LED shows
|
@@ -223,22 +280,28 @@ module Tinkerforge
|
|
223
280
|
#
|
224
281
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
225
282
|
def set_status_led_config(config)
|
226
|
-
|
283
|
+
check_validity
|
284
|
+
|
285
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
227
286
|
end
|
228
287
|
|
229
288
|
# Returns the configuration as set by BrickletIsolator#set_status_led_config
|
230
289
|
def get_status_led_config
|
231
|
-
|
290
|
+
check_validity
|
291
|
+
|
292
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
232
293
|
end
|
233
294
|
|
234
|
-
# Returns the temperature
|
295
|
+
# Returns the temperature as measured inside the microcontroller. The
|
235
296
|
# value returned is not the ambient temperature!
|
236
297
|
#
|
237
298
|
# The temperature is only proportional to the real temperature and it has bad
|
238
299
|
# accuracy. Practically it is only useful as an indicator for
|
239
300
|
# temperature changes.
|
240
301
|
def get_chip_temperature
|
241
|
-
|
302
|
+
check_validity
|
303
|
+
|
304
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
242
305
|
end
|
243
306
|
|
244
307
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -248,7 +311,9 @@ module Tinkerforge
|
|
248
311
|
# calling functions on the existing ones will result in
|
249
312
|
# undefined behavior!
|
250
313
|
def reset
|
251
|
-
|
314
|
+
check_validity
|
315
|
+
|
316
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
252
317
|
end
|
253
318
|
|
254
319
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -257,26 +322,37 @@ module Tinkerforge
|
|
257
322
|
#
|
258
323
|
# We recommend that you use Brick Viewer to change the UID.
|
259
324
|
def write_uid(uid)
|
260
|
-
|
325
|
+
check_validity
|
326
|
+
|
327
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
261
328
|
end
|
262
329
|
|
263
330
|
# Returns the current UID as an integer. Encode as
|
264
331
|
# Base58 to get the usual string version.
|
265
332
|
def read_uid
|
266
|
-
|
333
|
+
check_validity
|
334
|
+
|
335
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
267
336
|
end
|
268
337
|
|
269
338
|
# Returns the UID, the UID where the Bricklet is connected to,
|
270
339
|
# the position, the hardware and firmware version as well as the
|
271
340
|
# device identifier.
|
272
341
|
#
|
273
|
-
# The position can be 'a', 'b', 'c' or '
|
342
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
343
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
344
|
+
# position 'z'.
|
274
345
|
#
|
275
346
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
276
347
|
# |device_identifier_constant|
|
277
348
|
def get_identity
|
278
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
349
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
279
350
|
end
|
280
351
|
|
352
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
353
|
+
def register_callback(id, &block)
|
354
|
+
callback = block
|
355
|
+
@registered_callbacks[id] = callback
|
356
|
+
end
|
281
357
|
end
|
282
358
|
end
|
@@ -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
|
# 2-axis joystick with push-button
|
14
16
|
class BrickletJoystick < Device
|
@@ -78,7 +80,7 @@ module Tinkerforge
|
|
78
80
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
79
81
|
# the IP Connection <tt>ipcon</tt>.
|
80
82
|
def initialize(uid, ipcon)
|
81
|
-
super uid, ipcon
|
83
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
82
84
|
|
83
85
|
@api_version = [2, 0, 0]
|
84
86
|
|
@@ -98,24 +100,26 @@ module Tinkerforge
|
|
98
100
|
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
99
101
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
100
102
|
|
101
|
-
@callback_formats[CALLBACK_POSITION] = 's s'
|
102
|
-
@callback_formats[CALLBACK_ANALOG_VALUE] = 'S S'
|
103
|
-
@callback_formats[CALLBACK_POSITION_REACHED] = 's s'
|
104
|
-
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S S'
|
105
|
-
@callback_formats[CALLBACK_PRESSED] = ''
|
106
|
-
@callback_formats[CALLBACK_RELEASED] = ''
|
103
|
+
@callback_formats[CALLBACK_POSITION] = [12, 's s']
|
104
|
+
@callback_formats[CALLBACK_ANALOG_VALUE] = [12, 'S S']
|
105
|
+
@callback_formats[CALLBACK_POSITION_REACHED] = [12, 's s']
|
106
|
+
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [12, 'S S']
|
107
|
+
@callback_formats[CALLBACK_PRESSED] = [8, '']
|
108
|
+
@callback_formats[CALLBACK_RELEASED] = [8, '']
|
107
109
|
|
110
|
+
@ipcon.add_device self
|
108
111
|
end
|
109
112
|
|
110
|
-
# Returns the position of the joystick. The
|
111
|
-
#
|
112
|
-
# returned values are averaged and calibrated (see BrickletJoystick#calibrate).
|
113
|
+
# Returns the position of the joystick. The middle position of the joystick is x=0, y=0.
|
114
|
+
# The returned values are averaged and calibrated (see BrickletJoystick#calibrate).
|
113
115
|
#
|
114
116
|
# If you want to get the position periodically, it is recommended to use the
|
115
117
|
# CALLBACK_POSITION callback and set the period with
|
116
118
|
# BrickletJoystick#set_position_callback_period.
|
117
119
|
def get_position
|
118
|
-
|
120
|
+
check_validity
|
121
|
+
|
122
|
+
send_request FUNCTION_GET_POSITION, [], '', 12, 's s'
|
119
123
|
end
|
120
124
|
|
121
125
|
# Returns *true* if the button is pressed and *false* otherwise.
|
@@ -123,11 +127,12 @@ module Tinkerforge
|
|
123
127
|
# It is recommended to use the CALLBACK_PRESSED and CALLBACK_RELEASED callbacks
|
124
128
|
# to handle the button.
|
125
129
|
def is_pressed
|
126
|
-
|
130
|
+
check_validity
|
131
|
+
|
132
|
+
send_request FUNCTION_IS_PRESSED, [], '', 9, '?'
|
127
133
|
end
|
128
134
|
|
129
135
|
# Returns the values as read by a 12-bit analog-to-digital converter.
|
130
|
-
# The values are between 0 and 4095 for both axis.
|
131
136
|
#
|
132
137
|
# .. note::
|
133
138
|
# The values returned by BrickletJoystick#get_position are averaged over several samples
|
@@ -139,7 +144,9 @@ module Tinkerforge
|
|
139
144
|
# CALLBACK_ANALOG_VALUE callback and set the period with
|
140
145
|
# BrickletJoystick#set_analog_value_callback_period.
|
141
146
|
def get_analog_value
|
142
|
-
|
147
|
+
check_validity
|
148
|
+
|
149
|
+
send_request FUNCTION_GET_ANALOG_VALUE, [], '', 12, 'S S'
|
143
150
|
end
|
144
151
|
|
145
152
|
# Calibrates the middle position of the joystick. If your Joystick Bricklet
|
@@ -149,39 +156,45 @@ module Tinkerforge
|
|
149
156
|
# The resulting calibration will be saved on the EEPROM of the Joystick
|
150
157
|
# Bricklet, thus you only have to calibrate it once.
|
151
158
|
def calibrate
|
152
|
-
|
159
|
+
check_validity
|
160
|
+
|
161
|
+
send_request FUNCTION_CALIBRATE, [], '', 8, ''
|
153
162
|
end
|
154
163
|
|
155
|
-
# Sets the period
|
164
|
+
# Sets the period with which the CALLBACK_POSITION callback is triggered
|
156
165
|
# periodically. A value of 0 turns the callback off.
|
157
166
|
#
|
158
167
|
# The CALLBACK_POSITION callback is only triggered if the position has changed since the
|
159
168
|
# last triggering.
|
160
|
-
#
|
161
|
-
# The default value is 0.
|
162
169
|
def set_position_callback_period(period)
|
163
|
-
|
170
|
+
check_validity
|
171
|
+
|
172
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_PERIOD, [period], 'L', 8, ''
|
164
173
|
end
|
165
174
|
|
166
175
|
# Returns the period as set by BrickletJoystick#set_position_callback_period.
|
167
176
|
def get_position_callback_period
|
168
|
-
|
177
|
+
check_validity
|
178
|
+
|
179
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_PERIOD, [], '', 12, 'L'
|
169
180
|
end
|
170
181
|
|
171
|
-
# Sets the period
|
182
|
+
# Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
|
172
183
|
# periodically. A value of 0 turns the callback off.
|
173
184
|
#
|
174
185
|
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog values have
|
175
186
|
# changed since the last triggering.
|
176
|
-
#
|
177
|
-
# The default value is 0.
|
178
187
|
def set_analog_value_callback_period(period)
|
179
|
-
|
188
|
+
check_validity
|
189
|
+
|
190
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
180
191
|
end
|
181
192
|
|
182
193
|
# Returns the period as set by BrickletJoystick#set_analog_value_callback_period.
|
183
194
|
def get_analog_value_callback_period
|
184
|
-
|
195
|
+
check_validity
|
196
|
+
|
197
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
|
185
198
|
end
|
186
199
|
|
187
200
|
# Sets the thresholds for the CALLBACK_POSITION_REACHED callback.
|
@@ -195,15 +208,17 @@ module Tinkerforge
|
|
195
208
|
# "'i'", "Callback is triggered when the position is *inside* the min and max values"
|
196
209
|
# "'<'", "Callback is triggered when the position is smaller than the min values (max is ignored)"
|
197
210
|
# "'>'", "Callback is triggered when the position is greater than the min values (max is ignored)"
|
198
|
-
#
|
199
|
-
# The default value is ('x', 0, 0, 0, 0).
|
200
211
|
def set_position_callback_threshold(option, min_x, max_x, min_y, max_y)
|
201
|
-
|
212
|
+
check_validity
|
213
|
+
|
214
|
+
send_request FUNCTION_SET_POSITION_CALLBACK_THRESHOLD, [option, min_x, max_x, min_y, max_y], 'k s s s s', 8, ''
|
202
215
|
end
|
203
216
|
|
204
217
|
# Returns the threshold as set by BrickletJoystick#set_position_callback_threshold.
|
205
218
|
def get_position_callback_threshold
|
206
|
-
|
219
|
+
check_validity
|
220
|
+
|
221
|
+
send_request FUNCTION_GET_POSITION_CALLBACK_THRESHOLD, [], '', 17, 'k s s s s'
|
207
222
|
end
|
208
223
|
|
209
224
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
@@ -217,18 +232,20 @@ module Tinkerforge
|
|
217
232
|
# "'i'", "Callback is triggered when the analog values are *inside* the min and max values"
|
218
233
|
# "'<'", "Callback is triggered when the analog values are smaller than the min values (max is ignored)"
|
219
234
|
# "'>'", "Callback is triggered when the analog values are greater than the min values (max is ignored)"
|
220
|
-
#
|
221
|
-
# The default value is ('x', 0, 0, 0, 0).
|
222
235
|
def set_analog_value_callback_threshold(option, min_x, max_x, min_y, max_y)
|
223
|
-
|
236
|
+
check_validity
|
237
|
+
|
238
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min_x, max_x, min_y, max_y], 'k S S S S', 8, ''
|
224
239
|
end
|
225
240
|
|
226
241
|
# Returns the threshold as set by BrickletJoystick#set_analog_value_callback_threshold.
|
227
242
|
def get_analog_value_callback_threshold
|
228
|
-
|
243
|
+
check_validity
|
244
|
+
|
245
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 17, 'k S S S S'
|
229
246
|
end
|
230
247
|
|
231
|
-
# Sets the period
|
248
|
+
# Sets the period with which the threshold callbacks
|
232
249
|
#
|
233
250
|
# * CALLBACK_POSITION_REACHED,
|
234
251
|
# * CALLBACK_ANALOG_VALUE_REACHED
|
@@ -239,27 +256,31 @@ module Tinkerforge
|
|
239
256
|
# * BrickletJoystick#set_analog_value_callback_threshold
|
240
257
|
#
|
241
258
|
# keep being reached.
|
242
|
-
#
|
243
|
-
# The default value is 100.
|
244
259
|
def set_debounce_period(debounce)
|
245
|
-
|
260
|
+
check_validity
|
261
|
+
|
262
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
246
263
|
end
|
247
264
|
|
248
265
|
# Returns the debounce period as set by BrickletJoystick#set_debounce_period.
|
249
266
|
def get_debounce_period
|
250
|
-
|
267
|
+
check_validity
|
268
|
+
|
269
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
251
270
|
end
|
252
271
|
|
253
272
|
# Returns the UID, the UID where the Bricklet is connected to,
|
254
273
|
# the position, the hardware and firmware version as well as the
|
255
274
|
# device identifier.
|
256
275
|
#
|
257
|
-
# The position can be 'a', 'b', 'c' or '
|
276
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
277
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
278
|
+
# position 'z'.
|
258
279
|
#
|
259
280
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
260
281
|
# |device_identifier_constant|
|
261
282
|
def get_identity
|
262
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
283
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
263
284
|
end
|
264
285
|
|
265
286
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|