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