tinkerforge 2.1.22 → 2.1.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
@@ -1,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
|
# 16x2 character alphanumeric display with blue backlight
|
14
16
|
class BrickletLCD16x2 < Device
|
@@ -16,11 +18,11 @@ module Tinkerforge
|
|
16
18
|
DEVICE_DISPLAY_NAME = 'LCD 16x2 Bricklet' # :nodoc:
|
17
19
|
|
18
20
|
# This callback is triggered when a button is pressed. The parameter is
|
19
|
-
# the number of the button
|
21
|
+
# the number of the button.
|
20
22
|
CALLBACK_BUTTON_PRESSED = 9
|
21
23
|
|
22
24
|
# This callback is triggered when a button is released. The parameter is
|
23
|
-
# the number of the button
|
25
|
+
# the number of the button.
|
24
26
|
CALLBACK_BUTTON_RELEASED = 10
|
25
27
|
|
26
28
|
FUNCTION_WRITE_LINE = 1 # :nodoc:
|
@@ -39,7 +41,7 @@ module Tinkerforge
|
|
39
41
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
40
42
|
# the IP Connection <tt>ipcon</tt>.
|
41
43
|
def initialize(uid, ipcon)
|
42
|
-
super uid, ipcon
|
44
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
43
45
|
|
44
46
|
@api_version = [2, 0, 1]
|
45
47
|
|
@@ -55,13 +57,14 @@ module Tinkerforge
|
|
55
57
|
@response_expected[FUNCTION_GET_CUSTOM_CHARACTER] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
56
58
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
57
59
|
|
58
|
-
@callback_formats[CALLBACK_BUTTON_PRESSED] = 'C'
|
59
|
-
@callback_formats[CALLBACK_BUTTON_RELEASED] = 'C'
|
60
|
+
@callback_formats[CALLBACK_BUTTON_PRESSED] = [9, 'C']
|
61
|
+
@callback_formats[CALLBACK_BUTTON_RELEASED] = [9, 'C']
|
60
62
|
|
63
|
+
@ipcon.add_device self
|
61
64
|
end
|
62
65
|
|
63
|
-
# Writes text to a specific line
|
64
|
-
#
|
66
|
+
# Writes text to a specific line with a specific position.
|
67
|
+
# The text can have a maximum of 16 characters.
|
65
68
|
#
|
66
69
|
# For example: (0, 5, "Hello") will write *Hello* in the middle of the
|
67
70
|
# first line of the display.
|
@@ -72,50 +75,64 @@ module Tinkerforge
|
|
72
75
|
# for details. The Unicode example above shows how to specify non-ASCII characters
|
73
76
|
# and how to translate from Unicode to the LCD charset.
|
74
77
|
def write_line(line, position, text)
|
75
|
-
|
78
|
+
check_validity
|
79
|
+
|
80
|
+
send_request FUNCTION_WRITE_LINE, [line, position, text], 'C C Z16', 8, ''
|
76
81
|
end
|
77
82
|
|
78
83
|
# Deletes all characters from the display.
|
79
84
|
def clear_display
|
80
|
-
|
85
|
+
check_validity
|
86
|
+
|
87
|
+
send_request FUNCTION_CLEAR_DISPLAY, [], '', 8, ''
|
81
88
|
end
|
82
89
|
|
83
90
|
# Turns the backlight on.
|
84
91
|
def backlight_on
|
85
|
-
|
92
|
+
check_validity
|
93
|
+
|
94
|
+
send_request FUNCTION_BACKLIGHT_ON, [], '', 8, ''
|
86
95
|
end
|
87
96
|
|
88
97
|
# Turns the backlight off.
|
89
98
|
def backlight_off
|
90
|
-
|
99
|
+
check_validity
|
100
|
+
|
101
|
+
send_request FUNCTION_BACKLIGHT_OFF, [], '', 8, ''
|
91
102
|
end
|
92
103
|
|
93
104
|
# Returns *true* if the backlight is on and *false* otherwise.
|
94
105
|
def is_backlight_on
|
95
|
-
|
106
|
+
check_validity
|
107
|
+
|
108
|
+
send_request FUNCTION_IS_BACKLIGHT_ON, [], '', 9, '?'
|
96
109
|
end
|
97
110
|
|
98
111
|
# Configures if the cursor (shown as "_") should be visible and if it
|
99
112
|
# should be blinking (shown as a blinking block). The cursor position
|
100
113
|
# is one character behind the the last text written with
|
101
114
|
# BrickletLCD16x2#write_line.
|
102
|
-
#
|
103
|
-
# The default is (false, false).
|
104
115
|
def set_config(cursor, blinking)
|
105
|
-
|
116
|
+
check_validity
|
117
|
+
|
118
|
+
send_request FUNCTION_SET_CONFIG, [cursor, blinking], '? ?', 8, ''
|
106
119
|
end
|
107
120
|
|
108
121
|
# Returns the configuration as set by BrickletLCD16x2#set_config.
|
109
122
|
def get_config
|
110
|
-
|
123
|
+
check_validity
|
124
|
+
|
125
|
+
send_request FUNCTION_GET_CONFIG, [], '', 10, '? ?'
|
111
126
|
end
|
112
127
|
|
113
|
-
# Returns *true* if the button
|
128
|
+
# Returns *true* if the button is pressed.
|
114
129
|
#
|
115
130
|
# If you want to react on button presses and releases it is recommended to use the
|
116
131
|
# CALLBACK_BUTTON_PRESSED and CALLBACK_BUTTON_RELEASED callbacks.
|
117
132
|
def is_button_pressed(button)
|
118
|
-
|
133
|
+
check_validity
|
134
|
+
|
135
|
+
send_request FUNCTION_IS_BUTTON_PRESSED, [button], 'C', 9, '?'
|
119
136
|
end
|
120
137
|
|
121
138
|
# The LCD 16x2 Bricklet can store up to 8 custom characters. The characters
|
@@ -133,7 +150,8 @@ module Tinkerforge
|
|
133
150
|
# * ``character[7] = 0b00000000`` (decimal value 0)
|
134
151
|
#
|
135
152
|
# The characters can later be written with BrickletLCD16x2#write_line by using the
|
136
|
-
# characters with the byte representation 8 to 15
|
153
|
+
# characters with the byte representation 8 ("\\x08" or "\\u0008") to 15
|
154
|
+
# ("\\x0F" or "\\u000F").
|
137
155
|
#
|
138
156
|
# You can play around with the custom characters in Brick Viewer since
|
139
157
|
# version 2.0.1.
|
@@ -143,7 +161,9 @@ module Tinkerforge
|
|
143
161
|
#
|
144
162
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
145
163
|
def set_custom_character(index, character)
|
146
|
-
|
164
|
+
check_validity
|
165
|
+
|
166
|
+
send_request FUNCTION_SET_CUSTOM_CHARACTER, [index, character], 'C C8', 8, ''
|
147
167
|
end
|
148
168
|
|
149
169
|
# Returns the custom character for a given index, as set with
|
@@ -151,19 +171,23 @@ module Tinkerforge
|
|
151
171
|
#
|
152
172
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
153
173
|
def get_custom_character(index)
|
154
|
-
|
174
|
+
check_validity
|
175
|
+
|
176
|
+
send_request FUNCTION_GET_CUSTOM_CHARACTER, [index], 'C', 16, 'C8'
|
155
177
|
end
|
156
178
|
|
157
179
|
# Returns the UID, the UID where the Bricklet is connected to,
|
158
180
|
# the position, the hardware and firmware version as well as the
|
159
181
|
# device identifier.
|
160
182
|
#
|
161
|
-
# The position can be 'a', 'b', 'c' or '
|
183
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
184
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
185
|
+
# position 'z'.
|
162
186
|
#
|
163
187
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
164
188
|
# |device_identifier_constant|
|
165
189
|
def get_identity
|
166
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
190
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
167
191
|
end
|
168
192
|
|
169
193
|
# 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
|
# 20x4 character alphanumeric display with blue backlight
|
14
16
|
class BrickletLCD20x4 < Device
|
@@ -43,7 +45,7 @@ module Tinkerforge
|
|
43
45
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
44
46
|
# the IP Connection <tt>ipcon</tt>.
|
45
47
|
def initialize(uid, ipcon)
|
46
|
-
super uid, ipcon
|
48
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
47
49
|
|
48
50
|
@api_version = [2, 0, 2]
|
49
51
|
|
@@ -63,13 +65,14 @@ module Tinkerforge
|
|
63
65
|
@response_expected[FUNCTION_GET_DEFAULT_TEXT_COUNTER] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
64
66
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
65
67
|
|
66
|
-
@callback_formats[CALLBACK_BUTTON_PRESSED] = 'C'
|
67
|
-
@callback_formats[CALLBACK_BUTTON_RELEASED] = 'C'
|
68
|
+
@callback_formats[CALLBACK_BUTTON_PRESSED] = [9, 'C']
|
69
|
+
@callback_formats[CALLBACK_BUTTON_RELEASED] = [9, 'C']
|
68
70
|
|
71
|
+
@ipcon.add_device self
|
69
72
|
end
|
70
73
|
|
71
|
-
# Writes text to a specific line
|
72
|
-
#
|
74
|
+
# Writes text to a specific line with a specific position.
|
75
|
+
# The text can have a maximum of 20 characters.
|
73
76
|
#
|
74
77
|
# For example: (0, 7, "Hello") will write *Hello* in the middle of the
|
75
78
|
# first line of the display.
|
@@ -80,42 +83,54 @@ module Tinkerforge
|
|
80
83
|
# for details. The Unicode example above shows how to specify non-ASCII characters
|
81
84
|
# and how to translate from Unicode to the LCD charset.
|
82
85
|
def write_line(line, position, text)
|
83
|
-
|
86
|
+
check_validity
|
87
|
+
|
88
|
+
send_request FUNCTION_WRITE_LINE, [line, position, text], 'C C Z20', 8, ''
|
84
89
|
end
|
85
90
|
|
86
91
|
# Deletes all characters from the display.
|
87
92
|
def clear_display
|
88
|
-
|
93
|
+
check_validity
|
94
|
+
|
95
|
+
send_request FUNCTION_CLEAR_DISPLAY, [], '', 8, ''
|
89
96
|
end
|
90
97
|
|
91
98
|
# Turns the backlight on.
|
92
99
|
def backlight_on
|
93
|
-
|
100
|
+
check_validity
|
101
|
+
|
102
|
+
send_request FUNCTION_BACKLIGHT_ON, [], '', 8, ''
|
94
103
|
end
|
95
104
|
|
96
105
|
# Turns the backlight off.
|
97
106
|
def backlight_off
|
98
|
-
|
107
|
+
check_validity
|
108
|
+
|
109
|
+
send_request FUNCTION_BACKLIGHT_OFF, [], '', 8, ''
|
99
110
|
end
|
100
111
|
|
101
112
|
# Returns *true* if the backlight is on and *false* otherwise.
|
102
113
|
def is_backlight_on
|
103
|
-
|
114
|
+
check_validity
|
115
|
+
|
116
|
+
send_request FUNCTION_IS_BACKLIGHT_ON, [], '', 9, '?'
|
104
117
|
end
|
105
118
|
|
106
119
|
# Configures if the cursor (shown as "_") should be visible and if it
|
107
120
|
# should be blinking (shown as a blinking block). The cursor position
|
108
121
|
# is one character behind the the last text written with
|
109
122
|
# BrickletLCD20x4#write_line.
|
110
|
-
#
|
111
|
-
# The default is (*false*, *false*).
|
112
123
|
def set_config(cursor, blinking)
|
113
|
-
|
124
|
+
check_validity
|
125
|
+
|
126
|
+
send_request FUNCTION_SET_CONFIG, [cursor, blinking], '? ?', 8, ''
|
114
127
|
end
|
115
128
|
|
116
129
|
# Returns the configuration as set by BrickletLCD20x4#set_config.
|
117
130
|
def get_config
|
118
|
-
|
131
|
+
check_validity
|
132
|
+
|
133
|
+
send_request FUNCTION_GET_CONFIG, [], '', 10, '? ?'
|
119
134
|
end
|
120
135
|
|
121
136
|
# Returns *true* if the button (0 to 2 or 0 to 3 since hardware version 1.2)
|
@@ -124,7 +139,9 @@ module Tinkerforge
|
|
124
139
|
# If you want to react on button presses and releases it is recommended to use
|
125
140
|
# the CALLBACK_BUTTON_PRESSED and CALLBACK_BUTTON_RELEASED callbacks.
|
126
141
|
def is_button_pressed(button)
|
127
|
-
|
142
|
+
check_validity
|
143
|
+
|
144
|
+
send_request FUNCTION_IS_BUTTON_PRESSED, [button], 'C', 9, '?'
|
128
145
|
end
|
129
146
|
|
130
147
|
# The LCD 20x4 Bricklet can store up to 8 custom characters. The characters
|
@@ -142,7 +159,8 @@ module Tinkerforge
|
|
142
159
|
# * ``character[7] = 0b00000000`` (decimal value 0)
|
143
160
|
#
|
144
161
|
# The characters can later be written with BrickletLCD20x4#write_line by using the
|
145
|
-
# characters with the byte representation 8 ("
|
162
|
+
# characters with the byte representation 8 ("\\x08" or "\\u0008") to 15
|
163
|
+
# ("\\x0F" or "\\u000F").
|
146
164
|
#
|
147
165
|
# You can play around with the custom characters in Brick Viewer version
|
148
166
|
# since 2.0.1.
|
@@ -152,7 +170,9 @@ module Tinkerforge
|
|
152
170
|
#
|
153
171
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
154
172
|
def set_custom_character(index, character)
|
155
|
-
|
173
|
+
check_validity
|
174
|
+
|
175
|
+
send_request FUNCTION_SET_CUSTOM_CHARACTER, [index, character], 'C C8', 8, ''
|
156
176
|
end
|
157
177
|
|
158
178
|
# Returns the custom character for a given index, as set with
|
@@ -160,7 +180,9 @@ module Tinkerforge
|
|
160
180
|
#
|
161
181
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
162
182
|
def get_custom_character(index)
|
163
|
-
|
183
|
+
check_validity
|
184
|
+
|
185
|
+
send_request FUNCTION_GET_CUSTOM_CHARACTER, [index], 'C', 16, 'C8'
|
164
186
|
end
|
165
187
|
|
166
188
|
# Sets the default text for lines 0-3. The max number of characters
|
@@ -171,7 +193,9 @@ module Tinkerforge
|
|
171
193
|
#
|
172
194
|
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
173
195
|
def set_default_text(line, text)
|
174
|
-
|
196
|
+
check_validity
|
197
|
+
|
198
|
+
send_request FUNCTION_SET_DEFAULT_TEXT, [line, text], 'C Z20', 8, ''
|
175
199
|
end
|
176
200
|
|
177
201
|
# Returns the default text for a given line (0-3) as set by
|
@@ -179,10 +203,12 @@ module Tinkerforge
|
|
179
203
|
#
|
180
204
|
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
181
205
|
def get_default_text(line)
|
182
|
-
|
206
|
+
check_validity
|
207
|
+
|
208
|
+
send_request FUNCTION_GET_DEFAULT_TEXT, [line], 'C', 28, 'Z20'
|
183
209
|
end
|
184
210
|
|
185
|
-
# Sets the default text counter
|
211
|
+
# Sets the default text counter. This counter is decremented each
|
186
212
|
# ms by the LCD firmware. If the counter reaches 0, the default text
|
187
213
|
# (see BrickletLCD20x4#set_default_text) is shown on the LCD.
|
188
214
|
#
|
@@ -196,30 +222,34 @@ module Tinkerforge
|
|
196
222
|
#
|
197
223
|
# A negative counter turns the default text functionality off.
|
198
224
|
#
|
199
|
-
# The default is -1.
|
200
|
-
#
|
201
225
|
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
202
226
|
def set_default_text_counter(counter)
|
203
|
-
|
227
|
+
check_validity
|
228
|
+
|
229
|
+
send_request FUNCTION_SET_DEFAULT_TEXT_COUNTER, [counter], 'l', 8, ''
|
204
230
|
end
|
205
231
|
|
206
232
|
# Returns the current value of the default text counter.
|
207
233
|
#
|
208
234
|
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
209
235
|
def get_default_text_counter
|
210
|
-
|
236
|
+
check_validity
|
237
|
+
|
238
|
+
send_request FUNCTION_GET_DEFAULT_TEXT_COUNTER, [], '', 12, 'l'
|
211
239
|
end
|
212
240
|
|
213
241
|
# Returns the UID, the UID where the Bricklet is connected to,
|
214
242
|
# the position, the hardware and firmware version as well as the
|
215
243
|
# device identifier.
|
216
244
|
#
|
217
|
-
# The position can be 'a', 'b', 'c' or '
|
245
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
246
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
247
|
+
# position 'z'.
|
218
248
|
#
|
219
249
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
220
250
|
# |device_identifier_constant|
|
221
251
|
def get_identity
|
222
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
252
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
223
253
|
end
|
224
254
|
|
225
255
|
# 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
|
# Controls up to 320 RGB LEDs
|
14
16
|
class BrickletLEDStrip < Device
|
@@ -16,7 +18,7 @@ module Tinkerforge
|
|
16
18
|
DEVICE_DISPLAY_NAME = 'LED Strip Bricklet' # :nodoc:
|
17
19
|
|
18
20
|
# This callback is triggered directly after a new frame is rendered. The
|
19
|
-
# parameter is the number of LEDs in that frame.
|
21
|
+
# parameter is the number of RGB or RGBW LEDs in that frame.
|
20
22
|
#
|
21
23
|
# You should send the data for the next frame directly after this callback
|
22
24
|
# was triggered.
|
@@ -81,7 +83,7 @@ module Tinkerforge
|
|
81
83
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
82
84
|
# the IP Connection <tt>ipcon</tt>.
|
83
85
|
def initialize(uid, ipcon)
|
84
|
-
super uid, ipcon
|
86
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
85
87
|
|
86
88
|
@api_version = [2, 0, 3]
|
87
89
|
|
@@ -103,20 +105,17 @@ module Tinkerforge
|
|
103
105
|
@response_expected[FUNCTION_IS_FRAME_RENDERED_CALLBACK_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
104
106
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
105
107
|
|
106
|
-
@callback_formats[CALLBACK_FRAME_RENDERED] = 'S'
|
108
|
+
@callback_formats[CALLBACK_FRAME_RENDERED] = [10, 'S']
|
107
109
|
|
110
|
+
@ipcon.add_device self
|
108
111
|
end
|
109
112
|
|
110
|
-
# Sets
|
111
|
-
# from *index*.
|
113
|
+
# Sets *length* RGB values for the LEDs starting from *index*.
|
112
114
|
#
|
113
115
|
# To make the colors show correctly you need to configure the chip type
|
114
116
|
# (BrickletLEDStrip#set_chip_type) and a 3-channel channel mapping (BrickletLEDStrip#set_channel_mapping)
|
115
117
|
# according to the connected LEDs.
|
116
118
|
#
|
117
|
-
# The maximum length is 16, the index goes from 0 to 319 and the rgb values
|
118
|
-
# have 8 bits each.
|
119
|
-
#
|
120
119
|
# Example: If you set
|
121
120
|
#
|
122
121
|
# * index to 5,
|
@@ -150,41 +149,48 @@ module Tinkerforge
|
|
150
149
|
# information. A call of BrickletLEDStrip#set_rgb_values with index + length above the
|
151
150
|
# bounds is ignored completely.
|
152
151
|
def set_rgb_values(index, length, r, g, b)
|
153
|
-
|
152
|
+
check_validity
|
153
|
+
|
154
|
+
send_request FUNCTION_SET_RGB_VALUES, [index, length, r, g, b], 'S C C16 C16 C16', 8, ''
|
154
155
|
end
|
155
156
|
|
156
|
-
# Returns
|
157
|
-
# given *index*.
|
157
|
+
# Returns *length* R, G and B values starting from the
|
158
|
+
# given LED *index*.
|
158
159
|
#
|
159
160
|
# The values are the last values that were set by BrickletLEDStrip#set_rgb_values.
|
160
161
|
def get_rgb_values(index, length)
|
161
|
-
|
162
|
+
check_validity
|
163
|
+
|
164
|
+
send_request FUNCTION_GET_RGB_VALUES, [index, length], 'S C', 56, 'C16 C16 C16'
|
162
165
|
end
|
163
166
|
|
164
|
-
# Sets the frame duration
|
167
|
+
# Sets the frame duration.
|
165
168
|
#
|
166
169
|
# Example: If you want to achieve 20 frames per second, you should
|
167
170
|
# set the frame duration to 50ms (50ms * 20 = 1 second).
|
168
171
|
#
|
169
172
|
# For an explanation of the general approach see BrickletLEDStrip#set_rgb_values.
|
170
|
-
#
|
171
|
-
# Default value: 100ms (10 frames per second).
|
172
173
|
def set_frame_duration(duration)
|
173
|
-
|
174
|
+
check_validity
|
175
|
+
|
176
|
+
send_request FUNCTION_SET_FRAME_DURATION, [duration], 'S', 8, ''
|
174
177
|
end
|
175
178
|
|
176
|
-
# Returns the frame duration
|
179
|
+
# Returns the frame duration as set by BrickletLEDStrip#set_frame_duration.
|
177
180
|
def get_frame_duration
|
178
|
-
|
181
|
+
check_validity
|
182
|
+
|
183
|
+
send_request FUNCTION_GET_FRAME_DURATION, [], '', 10, 'S'
|
179
184
|
end
|
180
185
|
|
181
|
-
# Returns the current supply voltage of the LEDs.
|
186
|
+
# Returns the current supply voltage of the LEDs.
|
182
187
|
def get_supply_voltage
|
183
|
-
|
188
|
+
check_validity
|
189
|
+
|
190
|
+
send_request FUNCTION_GET_SUPPLY_VOLTAGE, [], '', 10, 'S'
|
184
191
|
end
|
185
192
|
|
186
|
-
# Sets the frequency of the clock
|
187
|
-
# 2000000Hz (2MHz).
|
193
|
+
# Sets the frequency of the clock.
|
188
194
|
#
|
189
195
|
# The Bricklet will choose the nearest achievable frequency, which may
|
190
196
|
# be off by a few Hz. You can get the exact frequency that is used by
|
@@ -197,21 +203,23 @@ module Tinkerforge
|
|
197
203
|
# With a decreasing frequency your maximum frames per second will decrease
|
198
204
|
# too.
|
199
205
|
#
|
200
|
-
# The default value is 1.66MHz.
|
201
|
-
#
|
202
206
|
# .. note::
|
203
207
|
# The frequency in firmware version 2.0.0 is fixed at 2MHz.
|
204
208
|
#
|
205
209
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
206
210
|
def set_clock_frequency(frequency)
|
207
|
-
|
211
|
+
check_validity
|
212
|
+
|
213
|
+
send_request FUNCTION_SET_CLOCK_FREQUENCY, [frequency], 'L', 8, ''
|
208
214
|
end
|
209
215
|
|
210
216
|
# Returns the currently used clock frequency as set by BrickletLEDStrip#set_clock_frequency.
|
211
217
|
#
|
212
218
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
213
219
|
def get_clock_frequency
|
214
|
-
|
220
|
+
check_validity
|
221
|
+
|
222
|
+
send_request FUNCTION_GET_CLOCK_FREQUENCY, [], '', 12, 'L'
|
215
223
|
end
|
216
224
|
|
217
225
|
# Sets the type of the LED driver chip. We currently support the chips
|
@@ -223,22 +231,23 @@ module Tinkerforge
|
|
223
231
|
# * LPD8806 and
|
224
232
|
# * APA102 / DotStar.
|
225
233
|
#
|
226
|
-
# The default value is WS2801 (2801).
|
227
|
-
#
|
228
234
|
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
229
235
|
def set_chip_type(chip)
|
230
|
-
|
236
|
+
check_validity
|
237
|
+
|
238
|
+
send_request FUNCTION_SET_CHIP_TYPE, [chip], 'S', 8, ''
|
231
239
|
end
|
232
240
|
|
233
241
|
# Returns the currently used chip type as set by BrickletLEDStrip#set_chip_type.
|
234
242
|
#
|
235
243
|
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
236
244
|
def get_chip_type
|
237
|
-
|
245
|
+
check_validity
|
246
|
+
|
247
|
+
send_request FUNCTION_GET_CHIP_TYPE, [], '', 10, 'S'
|
238
248
|
end
|
239
249
|
|
240
|
-
# Sets
|
241
|
-
# from *index*.
|
250
|
+
# Sets *length* RGBW values for the LEDs starting from *index*.
|
242
251
|
#
|
243
252
|
# To make the colors show correctly you need to configure the chip type
|
244
253
|
# (BrickletLEDStrip#set_chip_type) and a 4-channel channel mapping (BrickletLEDStrip#set_channel_mapping)
|
@@ -293,17 +302,20 @@ module Tinkerforge
|
|
293
302
|
#
|
294
303
|
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
295
304
|
def set_rgbw_values(index, length, r, g, b, w)
|
296
|
-
|
305
|
+
check_validity
|
306
|
+
|
307
|
+
send_request FUNCTION_SET_RGBW_VALUES, [index, length, r, g, b, w], 'S C C12 C12 C12 C12', 8, ''
|
297
308
|
end
|
298
309
|
|
299
|
-
# Returns RGBW values
|
300
|
-
# given *index*.
|
310
|
+
# Returns *length* RGBW values starting from the given *index*.
|
301
311
|
#
|
302
312
|
# The values are the last values that were set by BrickletLEDStrip#set_rgbw_values.
|
303
313
|
#
|
304
314
|
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
305
315
|
def get_rgbw_values(index, length)
|
306
|
-
|
316
|
+
check_validity
|
317
|
+
|
318
|
+
send_request FUNCTION_GET_RGBW_VALUES, [index, length], 'S C', 56, 'C12 C12 C12 C12'
|
307
319
|
end
|
308
320
|
|
309
321
|
# Sets the channel mapping for the connected LEDs.
|
@@ -326,18 +338,20 @@ module Tinkerforge
|
|
326
338
|
# BrickletLEDStrip#set_rgbw_values has to be used. Calling BrickletLEDStrip#set_rgb_values with a
|
327
339
|
# 4-channel mapping will produce incorrect results.
|
328
340
|
#
|
329
|
-
# The default value is BGR (36).
|
330
|
-
#
|
331
341
|
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
332
342
|
def set_channel_mapping(mapping)
|
333
|
-
|
343
|
+
check_validity
|
344
|
+
|
345
|
+
send_request FUNCTION_SET_CHANNEL_MAPPING, [mapping], 'C', 8, ''
|
334
346
|
end
|
335
347
|
|
336
348
|
# Returns the currently used channel mapping as set by BrickletLEDStrip#set_channel_mapping.
|
337
349
|
#
|
338
350
|
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
339
351
|
def get_channel_mapping
|
340
|
-
|
352
|
+
check_validity
|
353
|
+
|
354
|
+
send_request FUNCTION_GET_CHANNEL_MAPPING, [], '', 9, 'C'
|
341
355
|
end
|
342
356
|
|
343
357
|
# Enables the CALLBACK_FRAME_RENDERED callback.
|
@@ -346,7 +360,9 @@ module Tinkerforge
|
|
346
360
|
#
|
347
361
|
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
348
362
|
def enable_frame_rendered_callback
|
349
|
-
|
363
|
+
check_validity
|
364
|
+
|
365
|
+
send_request FUNCTION_ENABLE_FRAME_RENDERED_CALLBACK, [], '', 8, ''
|
350
366
|
end
|
351
367
|
|
352
368
|
# Disables the CALLBACK_FRAME_RENDERED callback.
|
@@ -355,26 +371,32 @@ module Tinkerforge
|
|
355
371
|
#
|
356
372
|
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
357
373
|
def disable_frame_rendered_callback
|
358
|
-
|
374
|
+
check_validity
|
375
|
+
|
376
|
+
send_request FUNCTION_DISABLE_FRAME_RENDERED_CALLBACK, [], '', 8, ''
|
359
377
|
end
|
360
378
|
|
361
379
|
# Returns *true* if the CALLBACK_FRAME_RENDERED callback is enabled, *false* otherwise.
|
362
380
|
#
|
363
381
|
# .. versionadded:: 2.0.6$nbsp;(Plugin)
|
364
382
|
def is_frame_rendered_callback_enabled
|
365
|
-
|
383
|
+
check_validity
|
384
|
+
|
385
|
+
send_request FUNCTION_IS_FRAME_RENDERED_CALLBACK_ENABLED, [], '', 9, '?'
|
366
386
|
end
|
367
387
|
|
368
388
|
# Returns the UID, the UID where the Bricklet is connected to,
|
369
389
|
# the position, the hardware and firmware version as well as the
|
370
390
|
# device identifier.
|
371
391
|
#
|
372
|
-
# The position can be 'a', 'b', 'c' or '
|
392
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
393
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
394
|
+
# position 'z'.
|
373
395
|
#
|
374
396
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
375
397
|
# |device_identifier_constant|
|
376
398
|
def get_identity
|
377
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
399
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
378
400
|
end
|
379
401
|
|
380
402
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|