tinkerforge 2.1.24 → 2.1.25
Sign up to get free protection for your applications and to get access to all the features.
- 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
|
# Controls remote mains switches and receives signals from remotes
|
14
16
|
class BrickletRemoteSwitchV2 < Device
|
@@ -105,7 +107,7 @@ module Tinkerforge
|
|
105
107
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
106
108
|
# the IP Connection <tt>ipcon</tt>.
|
107
109
|
def initialize(uid, ipcon)
|
108
|
-
super uid, ipcon
|
110
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
109
111
|
|
110
112
|
@api_version = [2, 0, 0]
|
111
113
|
|
@@ -134,11 +136,12 @@ module Tinkerforge
|
|
134
136
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
135
137
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
136
138
|
|
137
|
-
@callback_formats[CALLBACK_SWITCHING_DONE] = ''
|
138
|
-
@callback_formats[CALLBACK_REMOTE_STATUS_A] = 'C C C S'
|
139
|
-
@callback_formats[CALLBACK_REMOTE_STATUS_B] = 'L C C C S'
|
140
|
-
@callback_formats[CALLBACK_REMOTE_STATUS_C] = 'k C C S'
|
139
|
+
@callback_formats[CALLBACK_SWITCHING_DONE] = [8, '']
|
140
|
+
@callback_formats[CALLBACK_REMOTE_STATUS_A] = [13, 'C C C S']
|
141
|
+
@callback_formats[CALLBACK_REMOTE_STATUS_B] = [17, 'L C C C S']
|
142
|
+
@callback_formats[CALLBACK_REMOTE_STATUS_C] = [13, 'k C C S']
|
141
143
|
|
144
|
+
@ipcon.add_device self
|
142
145
|
end
|
143
146
|
|
144
147
|
# Returns the current switching state. If the current state is busy, the
|
@@ -148,72 +151,74 @@ module Tinkerforge
|
|
148
151
|
# How long the switching takes is dependent on the number of repeats, see
|
149
152
|
# BrickletRemoteSwitchV2#set_repeats.
|
150
153
|
def get_switching_state
|
151
|
-
|
154
|
+
check_validity
|
155
|
+
|
156
|
+
send_request FUNCTION_GET_SWITCHING_STATE, [], '', 9, 'C'
|
152
157
|
end
|
153
158
|
|
154
|
-
# Sets the number of times the code is
|
159
|
+
# Sets the number of times the code is sent when one of the Switch Socket
|
155
160
|
# functions is called. The repeats basically correspond to the amount of time
|
156
161
|
# that a button of the remote is pressed.
|
157
162
|
#
|
158
163
|
# Some dimmers are controlled by the length of a button pressed,
|
159
164
|
# this can be simulated by increasing the repeats.
|
160
|
-
#
|
161
|
-
# The default value is 5.
|
162
165
|
def set_repeats(repeats)
|
163
|
-
|
166
|
+
check_validity
|
167
|
+
|
168
|
+
send_request FUNCTION_SET_REPEATS, [repeats], 'C', 8, ''
|
164
169
|
end
|
165
170
|
|
166
171
|
# Returns the number of repeats as set by BrickletRemoteSwitchV2#set_repeats.
|
167
172
|
def get_repeats
|
168
|
-
|
173
|
+
check_validity
|
174
|
+
|
175
|
+
send_request FUNCTION_GET_REPEATS, [], '', 9, 'C'
|
169
176
|
end
|
170
177
|
|
171
178
|
# To switch a type A socket you have to give the house code, receiver code and the
|
172
179
|
# state (on or off) you want to switch to.
|
173
180
|
#
|
174
|
-
# The house code and receiver code have a range of 0 to 31 (5bit).
|
175
|
-
#
|
176
181
|
# A detailed description on how you can figure out the house and receiver code
|
177
182
|
# can be found :ref:`here <remote_switch_bricklet_type_a_house_and_receiver_code>`.
|
178
183
|
def switch_socket_a(house_code, receiver_code, switch_to)
|
179
|
-
|
184
|
+
check_validity
|
185
|
+
|
186
|
+
send_request FUNCTION_SWITCH_SOCKET_A, [house_code, receiver_code, switch_to], 'C C C', 8, ''
|
180
187
|
end
|
181
188
|
|
182
189
|
# To switch a type B socket you have to give the address, unit and the state
|
183
190
|
# (on or off) you want to switch to.
|
184
191
|
#
|
185
|
-
#
|
186
|
-
# of 0 to 15 (4bit). To switch all devices with the same address use 255 for
|
187
|
-
# the unit.
|
192
|
+
# To switch all devices with the same address use 255 for the unit.
|
188
193
|
#
|
189
194
|
# A detailed description on how you can teach a socket the address and unit can
|
190
195
|
# be found :ref:`here <remote_switch_bricklet_type_b_address_and_unit>`.
|
191
196
|
def switch_socket_b(address, unit, switch_to)
|
192
|
-
|
197
|
+
check_validity
|
198
|
+
|
199
|
+
send_request FUNCTION_SWITCH_SOCKET_B, [address, unit, switch_to], 'L C C', 8, ''
|
193
200
|
end
|
194
201
|
|
195
202
|
# To control a type B dimmer you have to give the address, unit and the
|
196
203
|
# dim value you want to set the dimmer to.
|
197
204
|
#
|
198
|
-
# The address has a range of 0 to 67108863 (26bit), the unit and the dim value
|
199
|
-
# has a range of 0 to 15 (4bit).
|
200
|
-
#
|
201
205
|
# A detailed description on how you can teach a dimmer the address and unit can
|
202
206
|
# be found :ref:`here <remote_switch_bricklet_type_b_address_and_unit>`.
|
203
207
|
def dim_socket_b(address, unit, dim_value)
|
204
|
-
|
208
|
+
check_validity
|
209
|
+
|
210
|
+
send_request FUNCTION_DIM_SOCKET_B, [address, unit, dim_value], 'L C C', 8, ''
|
205
211
|
end
|
206
212
|
|
207
213
|
# To switch a type C socket you have to give the system code, device code and the
|
208
214
|
# state (on or off) you want to switch to.
|
209
215
|
#
|
210
|
-
# The system code has a range of 'A' to 'P' (4bit) and the device code has a
|
211
|
-
# range of 1 to 16 (4bit).
|
212
|
-
#
|
213
216
|
# A detailed description on how you can figure out the system and device code
|
214
217
|
# can be found :ref:`here <remote_switch_bricklet_type_c_system_and_device_code>`.
|
215
218
|
def switch_socket_c(system_code, device_code, switch_to)
|
216
|
-
|
219
|
+
check_validity
|
220
|
+
|
221
|
+
send_request FUNCTION_SWITCH_SOCKET_C, [system_code, device_code, switch_to], 'k C C', 8, ''
|
217
222
|
end
|
218
223
|
|
219
224
|
# Sets the configuration for **receiving** data from a remote of type A, B or C.
|
@@ -223,15 +228,17 @@ module Tinkerforge
|
|
223
228
|
# is triggered (if enabled).
|
224
229
|
# * Callback Enabled: Enable or disable callback (see CALLBACK_REMOTE_STATUS_A callback,
|
225
230
|
# CALLBACK_REMOTE_STATUS_B callback and CALLBACK_REMOTE_STATUS_C callback).
|
226
|
-
#
|
227
|
-
# Default is ('A', 2, false).
|
228
231
|
def set_remote_configuration(remote_type, minimum_repeats, callback_enabled)
|
229
|
-
|
232
|
+
check_validity
|
233
|
+
|
234
|
+
send_request FUNCTION_SET_REMOTE_CONFIGURATION, [remote_type, minimum_repeats, callback_enabled], 'C S ?', 8, ''
|
230
235
|
end
|
231
236
|
|
232
237
|
# Returns the remote configuration as set by BrickletRemoteSwitchV2#set_remote_configuration
|
233
238
|
def get_remote_configuration
|
234
|
-
|
239
|
+
check_validity
|
240
|
+
|
241
|
+
send_request FUNCTION_GET_REMOTE_CONFIGURATION, [], '', 12, 'C S ?'
|
235
242
|
end
|
236
243
|
|
237
244
|
# Returns the house code, receiver code, switch state (on/off) and number of
|
@@ -245,7 +252,9 @@ module Tinkerforge
|
|
245
252
|
# Use the callback to get this data automatically when a button is pressed,
|
246
253
|
# see BrickletRemoteSwitchV2#set_remote_configuration and CALLBACK_REMOTE_STATUS_A callback.
|
247
254
|
def get_remote_status_a
|
248
|
-
|
255
|
+
check_validity
|
256
|
+
|
257
|
+
send_request FUNCTION_GET_REMOTE_STATUS_A, [], '', 13, 'C C C S'
|
249
258
|
end
|
250
259
|
|
251
260
|
# Returns the address (unique per remote), unit (button number), switch state
|
@@ -260,7 +269,9 @@ module Tinkerforge
|
|
260
269
|
# Use the callback to get this data automatically when a button is pressed,
|
261
270
|
# see BrickletRemoteSwitchV2#set_remote_configuration and CALLBACK_REMOTE_STATUS_B callback.
|
262
271
|
def get_remote_status_b
|
263
|
-
|
272
|
+
check_validity
|
273
|
+
|
274
|
+
send_request FUNCTION_GET_REMOTE_STATUS_B, [], '', 17, 'L C C C S'
|
264
275
|
end
|
265
276
|
|
266
277
|
# Returns the system code, device code, switch state (on/off) and number of repeats for
|
@@ -273,7 +284,9 @@ module Tinkerforge
|
|
273
284
|
# Use the callback to get this data automatically when a button is pressed,
|
274
285
|
# see BrickletRemoteSwitchV2#set_remote_configuration and CALLBACK_REMOTE_STATUS_C callback.
|
275
286
|
def get_remote_status_c
|
276
|
-
|
287
|
+
check_validity
|
288
|
+
|
289
|
+
send_request FUNCTION_GET_REMOTE_STATUS_C, [], '', 13, 'k C C S'
|
277
290
|
end
|
278
291
|
|
279
292
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -288,7 +301,9 @@ module Tinkerforge
|
|
288
301
|
# The errors counts are for errors that occur on the Bricklet side. All
|
289
302
|
# Bricks have a similar function that returns the errors on the Brick side.
|
290
303
|
def get_spitfp_error_count
|
291
|
-
|
304
|
+
check_validity
|
305
|
+
|
306
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
292
307
|
end
|
293
308
|
|
294
309
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -301,12 +316,16 @@ module Tinkerforge
|
|
301
316
|
# This function is used by Brick Viewer during flashing. It should not be
|
302
317
|
# necessary to call it in a normal user program.
|
303
318
|
def set_bootloader_mode(mode)
|
304
|
-
|
319
|
+
check_validity
|
320
|
+
|
321
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
305
322
|
end
|
306
323
|
|
307
324
|
# Returns the current bootloader mode, see BrickletRemoteSwitchV2#set_bootloader_mode.
|
308
325
|
def get_bootloader_mode
|
309
|
-
|
326
|
+
check_validity
|
327
|
+
|
328
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
310
329
|
end
|
311
330
|
|
312
331
|
# Sets the firmware pointer for BrickletRemoteSwitchV2#write_firmware. The pointer has
|
@@ -316,7 +335,9 @@ module Tinkerforge
|
|
316
335
|
# This function is used by Brick Viewer during flashing. It should not be
|
317
336
|
# necessary to call it in a normal user program.
|
318
337
|
def set_write_firmware_pointer(pointer)
|
319
|
-
|
338
|
+
check_validity
|
339
|
+
|
340
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
320
341
|
end
|
321
342
|
|
322
343
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -328,7 +349,9 @@ module Tinkerforge
|
|
328
349
|
# This function is used by Brick Viewer during flashing. It should not be
|
329
350
|
# necessary to call it in a normal user program.
|
330
351
|
def write_firmware(data)
|
331
|
-
|
352
|
+
check_validity
|
353
|
+
|
354
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
332
355
|
end
|
333
356
|
|
334
357
|
# Sets the status LED configuration. By default the LED shows
|
@@ -339,22 +362,28 @@ module Tinkerforge
|
|
339
362
|
#
|
340
363
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
341
364
|
def set_status_led_config(config)
|
342
|
-
|
365
|
+
check_validity
|
366
|
+
|
367
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
343
368
|
end
|
344
369
|
|
345
370
|
# Returns the configuration as set by BrickletRemoteSwitchV2#set_status_led_config
|
346
371
|
def get_status_led_config
|
347
|
-
|
372
|
+
check_validity
|
373
|
+
|
374
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
348
375
|
end
|
349
376
|
|
350
|
-
# Returns the temperature
|
377
|
+
# Returns the temperature as measured inside the microcontroller. The
|
351
378
|
# value returned is not the ambient temperature!
|
352
379
|
#
|
353
380
|
# The temperature is only proportional to the real temperature and it has bad
|
354
381
|
# accuracy. Practically it is only useful as an indicator for
|
355
382
|
# temperature changes.
|
356
383
|
def get_chip_temperature
|
357
|
-
|
384
|
+
check_validity
|
385
|
+
|
386
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
358
387
|
end
|
359
388
|
|
360
389
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -364,7 +393,9 @@ module Tinkerforge
|
|
364
393
|
# calling functions on the existing ones will result in
|
365
394
|
# undefined behavior!
|
366
395
|
def reset
|
367
|
-
|
396
|
+
check_validity
|
397
|
+
|
398
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
368
399
|
end
|
369
400
|
|
370
401
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -373,25 +404,32 @@ module Tinkerforge
|
|
373
404
|
#
|
374
405
|
# We recommend that you use Brick Viewer to change the UID.
|
375
406
|
def write_uid(uid)
|
376
|
-
|
407
|
+
check_validity
|
408
|
+
|
409
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
377
410
|
end
|
378
411
|
|
379
412
|
# Returns the current UID as an integer. Encode as
|
380
413
|
# Base58 to get the usual string version.
|
381
414
|
def read_uid
|
382
|
-
|
415
|
+
check_validity
|
416
|
+
|
417
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
383
418
|
end
|
384
419
|
|
385
420
|
# Returns the UID, the UID where the Bricklet is connected to,
|
386
421
|
# the position, the hardware and firmware version as well as the
|
387
422
|
# device identifier.
|
388
423
|
#
|
389
|
-
# The position can be 'a', 'b', 'c' or '
|
424
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
425
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
426
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
427
|
+
# position 'z'.
|
390
428
|
#
|
391
429
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
392
430
|
# |device_identifier_constant|
|
393
431
|
def get_identity
|
394
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
432
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
395
433
|
end
|
396
434
|
|
397
435
|
# 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
|
# Controls one RGB LED
|
14
16
|
class BrickletRGBLED < Device
|
@@ -23,7 +25,7 @@ module Tinkerforge
|
|
23
25
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
24
26
|
# the IP Connection <tt>ipcon</tt>.
|
25
27
|
def initialize(uid, ipcon)
|
26
|
-
super uid, ipcon
|
28
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
27
29
|
|
28
30
|
@api_version = [2, 0, 0]
|
29
31
|
|
@@ -32,28 +34,36 @@ module Tinkerforge
|
|
32
34
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
33
35
|
|
34
36
|
|
37
|
+
@ipcon.add_device self
|
35
38
|
end
|
36
39
|
|
37
|
-
# Sets the *r*, *g* and *b* values for the LED.
|
40
|
+
# Sets the *r*, *g* and *b* values for the LED.
|
38
41
|
def set_rgb_value(r, g, b)
|
39
|
-
|
42
|
+
check_validity
|
43
|
+
|
44
|
+
send_request FUNCTION_SET_RGB_VALUE, [r, g, b], 'C C C', 8, ''
|
40
45
|
end
|
41
46
|
|
42
47
|
# Returns the *r*, *g* and *b* values of the LED as set by BrickletRGBLED#set_rgb_value.
|
43
48
|
def get_rgb_value
|
44
|
-
|
49
|
+
check_validity
|
50
|
+
|
51
|
+
send_request FUNCTION_GET_RGB_VALUE, [], '', 11, 'C C C'
|
45
52
|
end
|
46
53
|
|
47
54
|
# Returns the UID, the UID where the Bricklet is connected to,
|
48
55
|
# the position, the hardware and firmware version as well as the
|
49
56
|
# device identifier.
|
50
57
|
#
|
51
|
-
# The position can be 'a', 'b', 'c' or '
|
58
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
59
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
60
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
61
|
+
# position 'z'.
|
52
62
|
#
|
53
63
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
54
64
|
# |device_identifier_constant|
|
55
65
|
def get_identity
|
56
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
66
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
57
67
|
end
|
58
68
|
|
59
69
|
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-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
|
# Push button with built-in RGB LED
|
14
16
|
class BrickletRGBLEDButton < Device
|
@@ -60,7 +62,7 @@ module Tinkerforge
|
|
60
62
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
61
63
|
# the IP Connection <tt>ipcon</tt>.
|
62
64
|
def initialize(uid, ipcon)
|
63
|
-
super uid, ipcon
|
65
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
64
66
|
|
65
67
|
@api_version = [2, 0, 0]
|
66
68
|
|
@@ -82,43 +84,48 @@ module Tinkerforge
|
|
82
84
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
83
85
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
84
86
|
|
85
|
-
@callback_formats[CALLBACK_BUTTON_STATE_CHANGED] = 'C'
|
87
|
+
@callback_formats[CALLBACK_BUTTON_STATE_CHANGED] = [9, 'C']
|
86
88
|
|
89
|
+
@ipcon.add_device self
|
87
90
|
end
|
88
91
|
|
89
92
|
# Sets the color of the LED.
|
90
|
-
#
|
91
|
-
# By default the LED is off (0, 0, 0).
|
92
93
|
def set_color(red, green, blue)
|
93
|
-
|
94
|
+
check_validity
|
95
|
+
|
96
|
+
send_request FUNCTION_SET_COLOR, [red, green, blue], 'C C C', 8, ''
|
94
97
|
end
|
95
98
|
|
96
99
|
# Returns the LED color as set by BrickletRGBLEDButton#set_color.
|
97
100
|
def get_color
|
98
|
-
|
101
|
+
check_validity
|
102
|
+
|
103
|
+
send_request FUNCTION_GET_COLOR, [], '', 11, 'C C C'
|
99
104
|
end
|
100
105
|
|
101
106
|
# Returns the current state of the button (either pressed or released).
|
102
107
|
def get_button_state
|
103
|
-
|
108
|
+
check_validity
|
109
|
+
|
110
|
+
send_request FUNCTION_GET_BUTTON_STATE, [], '', 9, 'C'
|
104
111
|
end
|
105
112
|
|
106
113
|
# Sets a color calibration. Some colors appear brighter then others,
|
107
|
-
# so a calibration may be necessary for
|
108
|
-
#
|
109
|
-
# The values range from 0% to 100%.
|
114
|
+
# so a calibration may be necessary for uniform colors.
|
110
115
|
#
|
111
116
|
# The calibration is saved in flash. You don't need to call this
|
112
117
|
# function on every startup.
|
113
|
-
#
|
114
|
-
# Default value is (100, 100, 55).
|
115
118
|
def set_color_calibration(red, green, blue)
|
116
|
-
|
119
|
+
check_validity
|
120
|
+
|
121
|
+
send_request FUNCTION_SET_COLOR_CALIBRATION, [red, green, blue], 'C C C', 8, ''
|
117
122
|
end
|
118
123
|
|
119
124
|
# Returns the color calibration as set by BrickletRGBLEDButton#set_color_calibration.
|
120
125
|
def get_color_calibration
|
121
|
-
|
126
|
+
check_validity
|
127
|
+
|
128
|
+
send_request FUNCTION_GET_COLOR_CALIBRATION, [], '', 11, 'C C C'
|
122
129
|
end
|
123
130
|
|
124
131
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -133,7 +140,9 @@ module Tinkerforge
|
|
133
140
|
# The errors counts are for errors that occur on the Bricklet side. All
|
134
141
|
# Bricks have a similar function that returns the errors on the Brick side.
|
135
142
|
def get_spitfp_error_count
|
136
|
-
|
143
|
+
check_validity
|
144
|
+
|
145
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
137
146
|
end
|
138
147
|
|
139
148
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -146,12 +155,16 @@ module Tinkerforge
|
|
146
155
|
# This function is used by Brick Viewer during flashing. It should not be
|
147
156
|
# necessary to call it in a normal user program.
|
148
157
|
def set_bootloader_mode(mode)
|
149
|
-
|
158
|
+
check_validity
|
159
|
+
|
160
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
150
161
|
end
|
151
162
|
|
152
163
|
# Returns the current bootloader mode, see BrickletRGBLEDButton#set_bootloader_mode.
|
153
164
|
def get_bootloader_mode
|
154
|
-
|
165
|
+
check_validity
|
166
|
+
|
167
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
155
168
|
end
|
156
169
|
|
157
170
|
# Sets the firmware pointer for BrickletRGBLEDButton#write_firmware. The pointer has
|
@@ -161,7 +174,9 @@ module Tinkerforge
|
|
161
174
|
# This function is used by Brick Viewer during flashing. It should not be
|
162
175
|
# necessary to call it in a normal user program.
|
163
176
|
def set_write_firmware_pointer(pointer)
|
164
|
-
|
177
|
+
check_validity
|
178
|
+
|
179
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
165
180
|
end
|
166
181
|
|
167
182
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -173,7 +188,9 @@ module Tinkerforge
|
|
173
188
|
# This function is used by Brick Viewer during flashing. It should not be
|
174
189
|
# necessary to call it in a normal user program.
|
175
190
|
def write_firmware(data)
|
176
|
-
|
191
|
+
check_validity
|
192
|
+
|
193
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
177
194
|
end
|
178
195
|
|
179
196
|
# Sets the status LED configuration. By default the LED shows
|
@@ -184,22 +201,28 @@ module Tinkerforge
|
|
184
201
|
#
|
185
202
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
186
203
|
def set_status_led_config(config)
|
187
|
-
|
204
|
+
check_validity
|
205
|
+
|
206
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
188
207
|
end
|
189
208
|
|
190
209
|
# Returns the configuration as set by BrickletRGBLEDButton#set_status_led_config
|
191
210
|
def get_status_led_config
|
192
|
-
|
211
|
+
check_validity
|
212
|
+
|
213
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
193
214
|
end
|
194
215
|
|
195
|
-
# Returns the temperature
|
216
|
+
# Returns the temperature as measured inside the microcontroller. The
|
196
217
|
# value returned is not the ambient temperature!
|
197
218
|
#
|
198
219
|
# The temperature is only proportional to the real temperature and it has bad
|
199
220
|
# accuracy. Practically it is only useful as an indicator for
|
200
221
|
# temperature changes.
|
201
222
|
def get_chip_temperature
|
202
|
-
|
223
|
+
check_validity
|
224
|
+
|
225
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
203
226
|
end
|
204
227
|
|
205
228
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -209,7 +232,9 @@ module Tinkerforge
|
|
209
232
|
# calling functions on the existing ones will result in
|
210
233
|
# undefined behavior!
|
211
234
|
def reset
|
212
|
-
|
235
|
+
check_validity
|
236
|
+
|
237
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
213
238
|
end
|
214
239
|
|
215
240
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -218,25 +243,32 @@ module Tinkerforge
|
|
218
243
|
#
|
219
244
|
# We recommend that you use Brick Viewer to change the UID.
|
220
245
|
def write_uid(uid)
|
221
|
-
|
246
|
+
check_validity
|
247
|
+
|
248
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
222
249
|
end
|
223
250
|
|
224
251
|
# Returns the current UID as an integer. Encode as
|
225
252
|
# Base58 to get the usual string version.
|
226
253
|
def read_uid
|
227
|
-
|
254
|
+
check_validity
|
255
|
+
|
256
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
228
257
|
end
|
229
258
|
|
230
259
|
# Returns the UID, the UID where the Bricklet is connected to,
|
231
260
|
# the position, the hardware and firmware version as well as the
|
232
261
|
# device identifier.
|
233
262
|
#
|
234
|
-
# The position can be 'a', 'b', 'c' or '
|
263
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
264
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
265
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
266
|
+
# position 'z'.
|
235
267
|
#
|
236
268
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
237
269
|
# |device_identifier_constant|
|
238
270
|
def get_identity
|
239
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
271
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
240
272
|
end
|
241
273
|
|
242
274
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|