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
|
# DMX master and slave
|
14
16
|
class BrickletDMX < Device
|
@@ -113,7 +115,7 @@ module Tinkerforge
|
|
113
115
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
114
116
|
# the IP Connection <tt>ipcon</tt>.
|
115
117
|
def initialize(uid, ipcon)
|
116
|
-
super uid, ipcon
|
118
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
117
119
|
|
118
120
|
@api_version = [2, 0, 0]
|
119
121
|
|
@@ -143,24 +145,29 @@ module Tinkerforge
|
|
143
145
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
144
146
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
145
147
|
|
146
|
-
@callback_formats[CALLBACK_FRAME_STARTED] = ''
|
147
|
-
@callback_formats[CALLBACK_FRAME_AVAILABLE] = 'L'
|
148
|
-
@callback_formats[CALLBACK_FRAME_LOW_LEVEL] = 'S S C56 L'
|
149
|
-
@callback_formats[CALLBACK_FRAME_ERROR_COUNT] = 'L L'
|
148
|
+
@callback_formats[CALLBACK_FRAME_STARTED] = [8, '']
|
149
|
+
@callback_formats[CALLBACK_FRAME_AVAILABLE] = [12, 'L']
|
150
|
+
@callback_formats[CALLBACK_FRAME_LOW_LEVEL] = [72, 'S S C56 L']
|
151
|
+
@callback_formats[CALLBACK_FRAME_ERROR_COUNT] = [16, 'L L']
|
150
152
|
|
151
153
|
@high_level_callbacks[CALLBACK_FRAME] = [['stream_length', 'stream_chunk_offset', 'stream_chunk_data', nil], {'fixed_length' => nil, 'single_chunk' => false}, nil]
|
154
|
+
@ipcon.add_device self
|
152
155
|
end
|
153
156
|
|
154
157
|
# Sets the DMX mode to either master or slave.
|
155
158
|
#
|
156
159
|
# Calling this function sets frame number to 0.
|
157
160
|
def set_dmx_mode(dmx_mode)
|
158
|
-
|
161
|
+
check_validity
|
162
|
+
|
163
|
+
send_request FUNCTION_SET_DMX_MODE, [dmx_mode], 'C', 8, ''
|
159
164
|
end
|
160
165
|
|
161
166
|
# Returns the DMX mode, as set by BrickletDMX#set_dmx_mode.
|
162
167
|
def get_dmx_mode
|
163
|
-
|
168
|
+
check_validity
|
169
|
+
|
170
|
+
send_request FUNCTION_GET_DMX_MODE, [], '', 9, 'C'
|
164
171
|
end
|
165
172
|
|
166
173
|
# Writes a DMX frame. The maximum frame size is 512 byte. Each byte represents one channel.
|
@@ -184,7 +191,9 @@ module Tinkerforge
|
|
184
191
|
#
|
185
192
|
# This function can only be called in master mode.
|
186
193
|
def write_frame_low_level(frame_length, frame_chunk_offset, frame_chunk_data)
|
187
|
-
|
194
|
+
check_validity
|
195
|
+
|
196
|
+
send_request FUNCTION_WRITE_FRAME_LOW_LEVEL, [frame_length, frame_chunk_offset, frame_chunk_data], 'S S C60', 8, ''
|
188
197
|
end
|
189
198
|
|
190
199
|
# Returns the last frame that was written by the DMX master. The size of the array
|
@@ -207,7 +216,9 @@ module Tinkerforge
|
|
207
216
|
#
|
208
217
|
# This function can only be called in slave mode.
|
209
218
|
def read_frame_low_level
|
210
|
-
|
219
|
+
check_validity
|
220
|
+
|
221
|
+
send_request FUNCTION_READ_FRAME_LOW_LEVEL, [], '', 72, 'S S C56 L'
|
211
222
|
end
|
212
223
|
|
213
224
|
# Sets the duration of a frame.
|
@@ -220,17 +231,23 @@ module Tinkerforge
|
|
220
231
|
#
|
221
232
|
# This setting is only used in master mode.
|
222
233
|
def set_frame_duration(frame_duration)
|
223
|
-
|
234
|
+
check_validity
|
235
|
+
|
236
|
+
send_request FUNCTION_SET_FRAME_DURATION, [frame_duration], 'S', 8, ''
|
224
237
|
end
|
225
238
|
|
226
239
|
# Returns the frame duration as set by BrickletDMX#set_frame_duration.
|
227
240
|
def get_frame_duration
|
228
|
-
|
241
|
+
check_validity
|
242
|
+
|
243
|
+
send_request FUNCTION_GET_FRAME_DURATION, [], '', 10, 'S'
|
229
244
|
end
|
230
245
|
|
231
246
|
# Returns the current number of overrun and framing errors.
|
232
247
|
def get_frame_error_count
|
233
|
-
|
248
|
+
check_validity
|
249
|
+
|
250
|
+
send_request FUNCTION_GET_FRAME_ERROR_COUNT, [], '', 16, 'L L'
|
234
251
|
end
|
235
252
|
|
236
253
|
# Sets the communication LED configuration. By default the LED shows
|
@@ -240,12 +257,16 @@ module Tinkerforge
|
|
240
257
|
#
|
241
258
|
# If the Bricklet is in bootloader mode, the LED is off.
|
242
259
|
def set_communication_led_config(config)
|
243
|
-
|
260
|
+
check_validity
|
261
|
+
|
262
|
+
send_request FUNCTION_SET_COMMUNICATION_LED_CONFIG, [config], 'C', 8, ''
|
244
263
|
end
|
245
264
|
|
246
265
|
# Returns the configuration as set by BrickletDMX#set_communication_led_config
|
247
266
|
def get_communication_led_config
|
248
|
-
|
267
|
+
check_validity
|
268
|
+
|
269
|
+
send_request FUNCTION_GET_COMMUNICATION_LED_CONFIG, [], '', 9, 'C'
|
249
270
|
end
|
250
271
|
|
251
272
|
# Sets the error LED configuration.
|
@@ -258,12 +279,16 @@ module Tinkerforge
|
|
258
279
|
#
|
259
280
|
# If the Bricklet is in bootloader mode, the LED is off.
|
260
281
|
def set_error_led_config(config)
|
261
|
-
|
282
|
+
check_validity
|
283
|
+
|
284
|
+
send_request FUNCTION_SET_ERROR_LED_CONFIG, [config], 'C', 8, ''
|
262
285
|
end
|
263
286
|
|
264
287
|
# Returns the configuration as set by BrickletDMX#set_error_led_config.
|
265
288
|
def get_error_led_config
|
266
|
-
|
289
|
+
check_validity
|
290
|
+
|
291
|
+
send_request FUNCTION_GET_ERROR_LED_CONFIG, [], '', 9, 'C'
|
267
292
|
end
|
268
293
|
|
269
294
|
# Enables/Disables the different callbacks. By default the
|
@@ -274,12 +299,16 @@ module Tinkerforge
|
|
274
299
|
# the cb:`Frame Available` callback at the same time. It becomes redundant in
|
275
300
|
# this case.
|
276
301
|
def set_frame_callback_config(frame_started_callback_enabled, frame_available_callback_enabled, frame_callback_enabled, frame_error_count_callback_enabled)
|
277
|
-
|
302
|
+
check_validity
|
303
|
+
|
304
|
+
send_request FUNCTION_SET_FRAME_CALLBACK_CONFIG, [frame_started_callback_enabled, frame_available_callback_enabled, frame_callback_enabled, frame_error_count_callback_enabled], '? ? ? ?', 8, ''
|
278
305
|
end
|
279
306
|
|
280
307
|
# Returns the frame callback config as set by BrickletDMX#set_frame_callback_config.
|
281
308
|
def get_frame_callback_config
|
282
|
-
|
309
|
+
check_validity
|
310
|
+
|
311
|
+
send_request FUNCTION_GET_FRAME_CALLBACK_CONFIG, [], '', 12, '? ? ? ?'
|
283
312
|
end
|
284
313
|
|
285
314
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -294,7 +323,9 @@ module Tinkerforge
|
|
294
323
|
# The errors counts are for errors that occur on the Bricklet side. All
|
295
324
|
# Bricks have a similar function that returns the errors on the Brick side.
|
296
325
|
def get_spitfp_error_count
|
297
|
-
|
326
|
+
check_validity
|
327
|
+
|
328
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
298
329
|
end
|
299
330
|
|
300
331
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -307,12 +338,16 @@ module Tinkerforge
|
|
307
338
|
# This function is used by Brick Viewer during flashing. It should not be
|
308
339
|
# necessary to call it in a normal user program.
|
309
340
|
def set_bootloader_mode(mode)
|
310
|
-
|
341
|
+
check_validity
|
342
|
+
|
343
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
311
344
|
end
|
312
345
|
|
313
346
|
# Returns the current bootloader mode, see BrickletDMX#set_bootloader_mode.
|
314
347
|
def get_bootloader_mode
|
315
|
-
|
348
|
+
check_validity
|
349
|
+
|
350
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
316
351
|
end
|
317
352
|
|
318
353
|
# Sets the firmware pointer for BrickletDMX#write_firmware. The pointer has
|
@@ -322,7 +357,9 @@ module Tinkerforge
|
|
322
357
|
# This function is used by Brick Viewer during flashing. It should not be
|
323
358
|
# necessary to call it in a normal user program.
|
324
359
|
def set_write_firmware_pointer(pointer)
|
325
|
-
|
360
|
+
check_validity
|
361
|
+
|
362
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
326
363
|
end
|
327
364
|
|
328
365
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -334,7 +371,9 @@ module Tinkerforge
|
|
334
371
|
# This function is used by Brick Viewer during flashing. It should not be
|
335
372
|
# necessary to call it in a normal user program.
|
336
373
|
def write_firmware(data)
|
337
|
-
|
374
|
+
check_validity
|
375
|
+
|
376
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
338
377
|
end
|
339
378
|
|
340
379
|
# Sets the status LED configuration. By default the LED shows
|
@@ -345,22 +384,28 @@ module Tinkerforge
|
|
345
384
|
#
|
346
385
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
347
386
|
def set_status_led_config(config)
|
348
|
-
|
387
|
+
check_validity
|
388
|
+
|
389
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
349
390
|
end
|
350
391
|
|
351
392
|
# Returns the configuration as set by BrickletDMX#set_status_led_config
|
352
393
|
def get_status_led_config
|
353
|
-
|
394
|
+
check_validity
|
395
|
+
|
396
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
354
397
|
end
|
355
398
|
|
356
|
-
# Returns the temperature
|
399
|
+
# Returns the temperature as measured inside the microcontroller. The
|
357
400
|
# value returned is not the ambient temperature!
|
358
401
|
#
|
359
402
|
# The temperature is only proportional to the real temperature and it has bad
|
360
403
|
# accuracy. Practically it is only useful as an indicator for
|
361
404
|
# temperature changes.
|
362
405
|
def get_chip_temperature
|
363
|
-
|
406
|
+
check_validity
|
407
|
+
|
408
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
364
409
|
end
|
365
410
|
|
366
411
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -370,7 +415,9 @@ module Tinkerforge
|
|
370
415
|
# calling functions on the existing ones will result in
|
371
416
|
# undefined behavior!
|
372
417
|
def reset
|
373
|
-
|
418
|
+
check_validity
|
419
|
+
|
420
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
374
421
|
end
|
375
422
|
|
376
423
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -379,25 +426,32 @@ module Tinkerforge
|
|
379
426
|
#
|
380
427
|
# We recommend that you use Brick Viewer to change the UID.
|
381
428
|
def write_uid(uid)
|
382
|
-
|
429
|
+
check_validity
|
430
|
+
|
431
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
383
432
|
end
|
384
433
|
|
385
434
|
# Returns the current UID as an integer. Encode as
|
386
435
|
# Base58 to get the usual string version.
|
387
436
|
def read_uid
|
388
|
-
|
437
|
+
check_validity
|
438
|
+
|
439
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
389
440
|
end
|
390
441
|
|
391
442
|
# Returns the UID, the UID where the Bricklet is connected to,
|
392
443
|
# the position, the hardware and firmware version as well as the
|
393
444
|
# device identifier.
|
394
445
|
#
|
395
|
-
# The position can be 'a', 'b', 'c' or '
|
446
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
447
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
448
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
449
|
+
# position 'z'.
|
396
450
|
#
|
397
451
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
398
452
|
# |device_identifier_constant|
|
399
453
|
def get_identity
|
400
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
454
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
401
455
|
end
|
402
456
|
|
403
457
|
# Writes a DMX frame. The maximum frame size is 512 byte. Each byte represents one channel.
|
@@ -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
|
# Two tactile buttons with built-in blue LEDs
|
14
16
|
class BrickletDualButton < Device
|
@@ -48,7 +50,7 @@ module Tinkerforge
|
|
48
50
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
49
51
|
# the IP Connection <tt>ipcon</tt>.
|
50
52
|
def initialize(uid, ipcon)
|
51
|
-
super uid, ipcon
|
53
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
52
54
|
|
53
55
|
@api_version = [2, 0, 0]
|
54
56
|
|
@@ -58,8 +60,9 @@ module Tinkerforge
|
|
58
60
|
@response_expected[FUNCTION_SET_SELECTED_LED_STATE] = RESPONSE_EXPECTED_FALSE
|
59
61
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
60
62
|
|
61
|
-
@callback_formats[CALLBACK_STATE_CHANGED] = 'C C C C'
|
63
|
+
@callback_formats[CALLBACK_STATE_CHANGED] = [12, 'C C C C']
|
62
64
|
|
65
|
+
@ipcon.add_device self
|
63
66
|
end
|
64
67
|
|
65
68
|
# Sets the state of the LEDs. Possible states are:
|
@@ -75,12 +78,16 @@ module Tinkerforge
|
|
75
78
|
# of the other LED, you can get the state with BrickletDualButton#get_led_state or you
|
76
79
|
# can use BrickletDualButton#set_selected_led_state.
|
77
80
|
def set_led_state(led_l, led_r)
|
78
|
-
|
81
|
+
check_validity
|
82
|
+
|
83
|
+
send_request FUNCTION_SET_LED_STATE, [led_l, led_r], 'C C', 8, ''
|
79
84
|
end
|
80
85
|
|
81
86
|
# Returns the current state of the LEDs, as set by BrickletDualButton#set_led_state.
|
82
87
|
def get_led_state
|
83
|
-
|
88
|
+
check_validity
|
89
|
+
|
90
|
+
send_request FUNCTION_GET_LED_STATE, [], '', 10, 'C C'
|
84
91
|
end
|
85
92
|
|
86
93
|
# Returns the current state for both buttons. Possible states are:
|
@@ -88,26 +95,33 @@ module Tinkerforge
|
|
88
95
|
# * 0 = pressed
|
89
96
|
# * 1 = released
|
90
97
|
def get_button_state
|
91
|
-
|
98
|
+
check_validity
|
99
|
+
|
100
|
+
send_request FUNCTION_GET_BUTTON_STATE, [], '', 10, 'C C'
|
92
101
|
end
|
93
102
|
|
94
103
|
# Sets the state of the selected LED (0 or 1).
|
95
104
|
#
|
96
105
|
# The other LED remains untouched.
|
97
106
|
def set_selected_led_state(led, state)
|
98
|
-
|
107
|
+
check_validity
|
108
|
+
|
109
|
+
send_request FUNCTION_SET_SELECTED_LED_STATE, [led, state], 'C C', 8, ''
|
99
110
|
end
|
100
111
|
|
101
112
|
# Returns the UID, the UID where the Bricklet is connected to,
|
102
113
|
# the position, the hardware and firmware version as well as the
|
103
114
|
# device identifier.
|
104
115
|
#
|
105
|
-
# The position can be 'a', 'b', 'c' or '
|
116
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
117
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
118
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
119
|
+
# position 'z'.
|
106
120
|
#
|
107
121
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
108
122
|
# |device_identifier_constant|
|
109
123
|
def get_identity
|
110
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
124
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
111
125
|
end
|
112
126
|
|
113
127
|
# 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
|
# Two tactile buttons with built-in blue LEDs
|
14
16
|
class BrickletDualButtonV2 < 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
|
|
@@ -101,8 +103,9 @@ module Tinkerforge
|
|
101
103
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
102
104
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
103
105
|
|
104
|
-
@callback_formats[CALLBACK_STATE_CHANGED] = 'C C C C'
|
106
|
+
@callback_formats[CALLBACK_STATE_CHANGED] = [12, 'C C C C']
|
105
107
|
|
108
|
+
@ipcon.add_device self
|
106
109
|
end
|
107
110
|
|
108
111
|
# Sets the state of the LEDs. Possible states are:
|
@@ -118,12 +121,16 @@ module Tinkerforge
|
|
118
121
|
# of the other LED, you can get the state with BrickletDualButtonV2#get_led_state or you
|
119
122
|
# can use BrickletDualButtonV2#set_selected_led_state.
|
120
123
|
def set_led_state(led_l, led_r)
|
121
|
-
|
124
|
+
check_validity
|
125
|
+
|
126
|
+
send_request FUNCTION_SET_LED_STATE, [led_l, led_r], 'C C', 8, ''
|
122
127
|
end
|
123
128
|
|
124
129
|
# Returns the current state of the LEDs, as set by BrickletDualButtonV2#set_led_state.
|
125
130
|
def get_led_state
|
126
|
-
|
131
|
+
check_validity
|
132
|
+
|
133
|
+
send_request FUNCTION_GET_LED_STATE, [], '', 10, 'C C'
|
127
134
|
end
|
128
135
|
|
129
136
|
# Returns the current state for both buttons. Possible states are:
|
@@ -131,25 +138,33 @@ module Tinkerforge
|
|
131
138
|
# * 0 = pressed
|
132
139
|
# * 1 = released
|
133
140
|
def get_button_state
|
134
|
-
|
141
|
+
check_validity
|
142
|
+
|
143
|
+
send_request FUNCTION_GET_BUTTON_STATE, [], '', 10, 'C C'
|
135
144
|
end
|
136
145
|
|
137
146
|
# Sets the state of the selected LED.
|
138
147
|
#
|
139
148
|
# The other LED remains untouched.
|
140
149
|
def set_selected_led_state(led, state)
|
141
|
-
|
150
|
+
check_validity
|
151
|
+
|
152
|
+
send_request FUNCTION_SET_SELECTED_LED_STATE, [led, state], 'C C', 8, ''
|
142
153
|
end
|
143
154
|
|
144
155
|
# If you enable this callback, the CALLBACK_STATE_CHANGED callback is triggered
|
145
156
|
# every time a button is pressed/released
|
146
157
|
def set_state_changed_callback_configuration(enabled)
|
147
|
-
|
158
|
+
check_validity
|
159
|
+
|
160
|
+
send_request FUNCTION_SET_STATE_CHANGED_CALLBACK_CONFIGURATION, [enabled], '?', 8, ''
|
148
161
|
end
|
149
162
|
|
150
163
|
# Returns the configuration as set by BrickletDualButtonV2#set_state_changed_callback_configuration.
|
151
164
|
def get_state_changed_callback_configuration
|
152
|
-
|
165
|
+
check_validity
|
166
|
+
|
167
|
+
send_request FUNCTION_GET_STATE_CHANGED_CALLBACK_CONFIGURATION, [], '', 9, '?'
|
153
168
|
end
|
154
169
|
|
155
170
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -164,7 +179,9 @@ module Tinkerforge
|
|
164
179
|
# The errors counts are for errors that occur on the Bricklet side. All
|
165
180
|
# Bricks have a similar function that returns the errors on the Brick side.
|
166
181
|
def get_spitfp_error_count
|
167
|
-
|
182
|
+
check_validity
|
183
|
+
|
184
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
168
185
|
end
|
169
186
|
|
170
187
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -177,12 +194,16 @@ module Tinkerforge
|
|
177
194
|
# This function is used by Brick Viewer during flashing. It should not be
|
178
195
|
# necessary to call it in a normal user program.
|
179
196
|
def set_bootloader_mode(mode)
|
180
|
-
|
197
|
+
check_validity
|
198
|
+
|
199
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
181
200
|
end
|
182
201
|
|
183
202
|
# Returns the current bootloader mode, see BrickletDualButtonV2#set_bootloader_mode.
|
184
203
|
def get_bootloader_mode
|
185
|
-
|
204
|
+
check_validity
|
205
|
+
|
206
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
186
207
|
end
|
187
208
|
|
188
209
|
# Sets the firmware pointer for BrickletDualButtonV2#write_firmware. The pointer has
|
@@ -192,7 +213,9 @@ module Tinkerforge
|
|
192
213
|
# This function is used by Brick Viewer during flashing. It should not be
|
193
214
|
# necessary to call it in a normal user program.
|
194
215
|
def set_write_firmware_pointer(pointer)
|
195
|
-
|
216
|
+
check_validity
|
217
|
+
|
218
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
196
219
|
end
|
197
220
|
|
198
221
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -204,7 +227,9 @@ module Tinkerforge
|
|
204
227
|
# This function is used by Brick Viewer during flashing. It should not be
|
205
228
|
# necessary to call it in a normal user program.
|
206
229
|
def write_firmware(data)
|
207
|
-
|
230
|
+
check_validity
|
231
|
+
|
232
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
208
233
|
end
|
209
234
|
|
210
235
|
# Sets the status LED configuration. By default the LED shows
|
@@ -215,22 +240,28 @@ module Tinkerforge
|
|
215
240
|
#
|
216
241
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
217
242
|
def set_status_led_config(config)
|
218
|
-
|
243
|
+
check_validity
|
244
|
+
|
245
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
219
246
|
end
|
220
247
|
|
221
248
|
# Returns the configuration as set by BrickletDualButtonV2#set_status_led_config
|
222
249
|
def get_status_led_config
|
223
|
-
|
250
|
+
check_validity
|
251
|
+
|
252
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
224
253
|
end
|
225
254
|
|
226
|
-
# Returns the temperature
|
255
|
+
# Returns the temperature as measured inside the microcontroller. The
|
227
256
|
# value returned is not the ambient temperature!
|
228
257
|
#
|
229
258
|
# The temperature is only proportional to the real temperature and it has bad
|
230
259
|
# accuracy. Practically it is only useful as an indicator for
|
231
260
|
# temperature changes.
|
232
261
|
def get_chip_temperature
|
233
|
-
|
262
|
+
check_validity
|
263
|
+
|
264
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
234
265
|
end
|
235
266
|
|
236
267
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -240,7 +271,9 @@ module Tinkerforge
|
|
240
271
|
# calling functions on the existing ones will result in
|
241
272
|
# undefined behavior!
|
242
273
|
def reset
|
243
|
-
|
274
|
+
check_validity
|
275
|
+
|
276
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
244
277
|
end
|
245
278
|
|
246
279
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -249,25 +282,32 @@ module Tinkerforge
|
|
249
282
|
#
|
250
283
|
# We recommend that you use Brick Viewer to change the UID.
|
251
284
|
def write_uid(uid)
|
252
|
-
|
285
|
+
check_validity
|
286
|
+
|
287
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
253
288
|
end
|
254
289
|
|
255
290
|
# Returns the current UID as an integer. Encode as
|
256
291
|
# Base58 to get the usual string version.
|
257
292
|
def read_uid
|
258
|
-
|
293
|
+
check_validity
|
294
|
+
|
295
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
259
296
|
end
|
260
297
|
|
261
298
|
# Returns the UID, the UID where the Bricklet is connected to,
|
262
299
|
# the position, the hardware and firmware version as well as the
|
263
300
|
# device identifier.
|
264
301
|
#
|
265
|
-
# The position can be 'a', 'b', 'c' or '
|
302
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
303
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
304
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
305
|
+
# position 'z'.
|
266
306
|
#
|
267
307
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
268
308
|
# |device_identifier_constant|
|
269
309
|
def get_identity
|
270
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
310
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
271
311
|
end
|
272
312
|
|
273
313
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|