tinkerforge 2.1.23 → 2.1.28
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 +156 -75
- data/lib/tinkerforge/brick_hat.rb +109 -30
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +191 -86
- data/lib/tinkerforge/brick_imu_v2.rb +219 -118
- data/lib/tinkerforge/brick_master.rb +495 -195
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +186 -102
- data/lib/tinkerforge/brick_silent_stepper.rb +248 -168
- data/lib/tinkerforge/brick_stepper.rb +212 -100
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +107 -63
- 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 +75 -47
- data/lib/tinkerforge/bricklet_color_v2.rb +91 -47
- data/lib/tinkerforge/bricklet_compass.rb +81 -40
- 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 +68 -33
- 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 +81 -40
- 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 +99 -51
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +219 -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 +76 -39
- 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 +75 -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_performance_dc.rb +676 -0
- 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 +57 -26
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +250 -164
- 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_servo_v2.rb +565 -0
- 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 +61 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +74 -44
- 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 +92 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +81 -36
- data/lib/tinkerforge/device_display_names.rb +167 -0
- data/lib/tinkerforge/ip_connection.rb +156 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +8 -3
@@ -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 2021-01-15. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.28 #
|
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
|
# Measures ambient light up to 900lux
|
14
16
|
class BrickletAmbientLight < Device
|
@@ -19,16 +21,16 @@ module Tinkerforge
|
|
19
21
|
# BrickletAmbientLight#set_illuminance_callback_period. The parameter is the illuminance of the
|
20
22
|
# ambient light sensor.
|
21
23
|
#
|
22
|
-
# The CALLBACK_ILLUMINANCE callback is only triggered if the illuminance has changed
|
23
|
-
# last triggering.
|
24
|
+
# The CALLBACK_ILLUMINANCE callback is only triggered if the illuminance has changed
|
25
|
+
# since the last triggering.
|
24
26
|
CALLBACK_ILLUMINANCE = 13
|
25
27
|
|
26
28
|
# This callback is triggered periodically with the period that is set by
|
27
29
|
# BrickletAmbientLight#set_analog_value_callback_period. The parameter is the analog value of the
|
28
30
|
# ambient light sensor.
|
29
31
|
#
|
30
|
-
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
31
|
-
# last triggering.
|
32
|
+
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
33
|
+
# changed since the last triggering.
|
32
34
|
CALLBACK_ANALOG_VALUE = 14
|
33
35
|
|
34
36
|
# This callback is triggered when the threshold as set by
|
@@ -70,7 +72,7 @@ module Tinkerforge
|
|
70
72
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
71
73
|
# the IP Connection <tt>ipcon</tt>.
|
72
74
|
def initialize(uid, ipcon)
|
73
|
-
super uid, ipcon
|
75
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
74
76
|
|
75
77
|
@api_version = [2, 0, 1]
|
76
78
|
|
@@ -88,26 +90,26 @@ module Tinkerforge
|
|
88
90
|
@response_expected[FUNCTION_GET_DEBOUNCE_PERIOD] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
89
91
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
90
92
|
|
91
|
-
@callback_formats[CALLBACK_ILLUMINANCE] = 'S'
|
92
|
-
@callback_formats[CALLBACK_ANALOG_VALUE] = 'S'
|
93
|
-
@callback_formats[CALLBACK_ILLUMINANCE_REACHED] = 'S'
|
94
|
-
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = 'S'
|
93
|
+
@callback_formats[CALLBACK_ILLUMINANCE] = [10, 'S']
|
94
|
+
@callback_formats[CALLBACK_ANALOG_VALUE] = [10, 'S']
|
95
|
+
@callback_formats[CALLBACK_ILLUMINANCE_REACHED] = [10, 'S']
|
96
|
+
@callback_formats[CALLBACK_ANALOG_VALUE_REACHED] = [10, 'S']
|
95
97
|
|
98
|
+
@ipcon.add_device self
|
96
99
|
end
|
97
100
|
|
98
|
-
# Returns the illuminance of the ambient light sensor.
|
99
|
-
# has a range of 0 to 9000 and is given in lux/10, i.e. a value
|
100
|
-
# of 4500 means that an illuminance of 450lux is measured.
|
101
|
+
# Returns the illuminance of the ambient light sensor.
|
101
102
|
#
|
102
103
|
# If you want to get the illuminance periodically, it is recommended to use the
|
103
104
|
# CALLBACK_ILLUMINANCE callback and set the period with
|
104
105
|
# BrickletAmbientLight#set_illuminance_callback_period.
|
105
106
|
def get_illuminance
|
106
|
-
|
107
|
+
check_validity
|
108
|
+
|
109
|
+
send_request FUNCTION_GET_ILLUMINANCE, [], '', 10, 'S'
|
107
110
|
end
|
108
111
|
|
109
112
|
# Returns the value as read by a 12-bit analog-to-digital converter.
|
110
|
-
# The value is between 0 and 4095.
|
111
113
|
#
|
112
114
|
# .. note::
|
113
115
|
# The value returned by BrickletAmbientLight#get_illuminance is averaged over several samples
|
@@ -123,39 +125,45 @@ module Tinkerforge
|
|
123
125
|
# CALLBACK_ANALOG_VALUE callback and set the period with
|
124
126
|
# BrickletAmbientLight#set_analog_value_callback_period.
|
125
127
|
def get_analog_value
|
126
|
-
|
128
|
+
check_validity
|
129
|
+
|
130
|
+
send_request FUNCTION_GET_ANALOG_VALUE, [], '', 10, 'S'
|
127
131
|
end
|
128
132
|
|
129
|
-
# Sets the period
|
133
|
+
# Sets the period with which the CALLBACK_ILLUMINANCE callback is triggered
|
130
134
|
# periodically. A value of 0 turns the callback off.
|
131
135
|
#
|
132
|
-
# The CALLBACK_ILLUMINANCE callback is only triggered if the illuminance has changed
|
133
|
-
# last triggering.
|
134
|
-
#
|
135
|
-
# The default value is 0.
|
136
|
+
# The CALLBACK_ILLUMINANCE callback is only triggered if the illuminance has changed
|
137
|
+
# since the last triggering.
|
136
138
|
def set_illuminance_callback_period(period)
|
137
|
-
|
139
|
+
check_validity
|
140
|
+
|
141
|
+
send_request FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
138
142
|
end
|
139
143
|
|
140
144
|
# Returns the period as set by BrickletAmbientLight#set_illuminance_callback_period.
|
141
145
|
def get_illuminance_callback_period
|
142
|
-
|
146
|
+
check_validity
|
147
|
+
|
148
|
+
send_request FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD, [], '', 12, 'L'
|
143
149
|
end
|
144
150
|
|
145
|
-
# Sets the period
|
151
|
+
# Sets the period with which the CALLBACK_ANALOG_VALUE callback is triggered
|
146
152
|
# periodically. A value of 0 turns the callback off.
|
147
153
|
#
|
148
|
-
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
149
|
-
# last triggering.
|
150
|
-
#
|
151
|
-
# The default value is 0.
|
154
|
+
# The CALLBACK_ANALOG_VALUE callback is only triggered if the analog value has
|
155
|
+
# changed since the last triggering.
|
152
156
|
def set_analog_value_callback_period(period)
|
153
|
-
|
157
|
+
check_validity
|
158
|
+
|
159
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
154
160
|
end
|
155
161
|
|
156
162
|
# Returns the period as set by BrickletAmbientLight#set_analog_value_callback_period.
|
157
163
|
def get_analog_value_callback_period
|
158
|
-
|
164
|
+
check_validity
|
165
|
+
|
166
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_PERIOD, [], '', 12, 'L'
|
159
167
|
end
|
160
168
|
|
161
169
|
# Sets the thresholds for the CALLBACK_ILLUMINANCE_REACHED callback.
|
@@ -169,15 +177,17 @@ module Tinkerforge
|
|
169
177
|
# "'i'", "Callback is triggered when the illuminance is *inside* the min and max values"
|
170
178
|
# "'<'", "Callback is triggered when the illuminance is smaller than the min value (max is ignored)"
|
171
179
|
# "'>'", "Callback is triggered when the illuminance is greater than the min value (max is ignored)"
|
172
|
-
#
|
173
|
-
# The default value is ('x', 0, 0).
|
174
180
|
def set_illuminance_callback_threshold(option, min, max)
|
175
|
-
|
181
|
+
check_validity
|
182
|
+
|
183
|
+
send_request FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
176
184
|
end
|
177
185
|
|
178
186
|
# Returns the threshold as set by BrickletAmbientLight#set_illuminance_callback_threshold.
|
179
187
|
def get_illuminance_callback_threshold
|
180
|
-
|
188
|
+
check_validity
|
189
|
+
|
190
|
+
send_request FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
181
191
|
end
|
182
192
|
|
183
193
|
# Sets the thresholds for the CALLBACK_ANALOG_VALUE_REACHED callback.
|
@@ -191,18 +201,20 @@ module Tinkerforge
|
|
191
201
|
# "'i'", "Callback is triggered when the analog value is *inside* the min and max values"
|
192
202
|
# "'<'", "Callback is triggered when the analog value is smaller than the min value (max is ignored)"
|
193
203
|
# "'>'", "Callback is triggered when the analog value is greater than the min value (max is ignored)"
|
194
|
-
#
|
195
|
-
# The default value is ('x', 0, 0).
|
196
204
|
def set_analog_value_callback_threshold(option, min, max)
|
197
|
-
|
205
|
+
check_validity
|
206
|
+
|
207
|
+
send_request FUNCTION_SET_ANALOG_VALUE_CALLBACK_THRESHOLD, [option, min, max], 'k S S', 8, ''
|
198
208
|
end
|
199
209
|
|
200
210
|
# Returns the threshold as set by BrickletAmbientLight#set_analog_value_callback_threshold.
|
201
211
|
def get_analog_value_callback_threshold
|
202
|
-
|
212
|
+
check_validity
|
213
|
+
|
214
|
+
send_request FUNCTION_GET_ANALOG_VALUE_CALLBACK_THRESHOLD, [], '', 13, 'k S S'
|
203
215
|
end
|
204
216
|
|
205
|
-
# Sets the period
|
217
|
+
# Sets the period with which the threshold callbacks
|
206
218
|
#
|
207
219
|
# * CALLBACK_ILLUMINANCE_REACHED,
|
208
220
|
# * CALLBACK_ANALOG_VALUE_REACHED
|
@@ -213,27 +225,31 @@ module Tinkerforge
|
|
213
225
|
# * BrickletAmbientLight#set_analog_value_callback_threshold
|
214
226
|
#
|
215
227
|
# keep being reached.
|
216
|
-
#
|
217
|
-
# The default value is 100.
|
218
228
|
def set_debounce_period(debounce)
|
219
|
-
|
229
|
+
check_validity
|
230
|
+
|
231
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
220
232
|
end
|
221
233
|
|
222
234
|
# Returns the debounce period as set by BrickletAmbientLight#set_debounce_period.
|
223
235
|
def get_debounce_period
|
224
|
-
|
236
|
+
check_validity
|
237
|
+
|
238
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
225
239
|
end
|
226
240
|
|
227
241
|
# Returns the UID, the UID where the Bricklet is connected to,
|
228
242
|
# the position, the hardware and firmware version as well as the
|
229
243
|
# device identifier.
|
230
244
|
#
|
231
|
-
# 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'.
|
232
248
|
#
|
233
249
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
234
250
|
# |device_identifier_constant|
|
235
251
|
def get_identity
|
236
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
252
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
237
253
|
end
|
238
254
|
|
239
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 2021-01-15. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.28 #
|
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
|
# Measures ambient light up to 64000lux
|
14
16
|
class BrickletAmbientLightV2 < Device
|
@@ -66,7 +68,7 @@ module Tinkerforge
|
|
66
68
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
67
69
|
# the IP Connection <tt>ipcon</tt>.
|
68
70
|
def initialize(uid, ipcon)
|
69
|
-
super uid, ipcon
|
71
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
70
72
|
|
71
73
|
@api_version = [2, 0, 1]
|
72
74
|
|
@@ -81,15 +83,14 @@ module Tinkerforge
|
|
81
83
|
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
82
84
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
83
85
|
|
84
|
-
@callback_formats[CALLBACK_ILLUMINANCE] = 'L'
|
85
|
-
@callback_formats[CALLBACK_ILLUMINANCE_REACHED] = 'L'
|
86
|
+
@callback_formats[CALLBACK_ILLUMINANCE] = [12, 'L']
|
87
|
+
@callback_formats[CALLBACK_ILLUMINANCE_REACHED] = [12, 'L']
|
86
88
|
|
89
|
+
@ipcon.add_device self
|
87
90
|
end
|
88
91
|
|
89
92
|
# Returns the illuminance of the ambient light sensor. The measurement range goes
|
90
93
|
# up to about 100000lux, but above 64000lux the precision starts to drop.
|
91
|
-
# The illuminance is given in lux/100, i.e. a value of 450000 means that an
|
92
|
-
# illuminance of 4500lux is measured.
|
93
94
|
#
|
94
95
|
# .. versionchanged:: 2.0.2$nbsp;(Plugin)
|
95
96
|
# An illuminance of 0lux indicates that the sensor is saturated and the
|
@@ -99,23 +100,27 @@ module Tinkerforge
|
|
99
100
|
# CALLBACK_ILLUMINANCE callback and set the period with
|
100
101
|
# BrickletAmbientLightV2#set_illuminance_callback_period.
|
101
102
|
def get_illuminance
|
102
|
-
|
103
|
+
check_validity
|
104
|
+
|
105
|
+
send_request FUNCTION_GET_ILLUMINANCE, [], '', 12, 'L'
|
103
106
|
end
|
104
107
|
|
105
|
-
# Sets the period
|
108
|
+
# Sets the period with which the CALLBACK_ILLUMINANCE callback is triggered
|
106
109
|
# periodically. A value of 0 turns the callback off.
|
107
110
|
#
|
108
111
|
# The CALLBACK_ILLUMINANCE callback is only triggered if the illuminance has changed
|
109
112
|
# since the last triggering.
|
110
|
-
#
|
111
|
-
# The default value is 0.
|
112
113
|
def set_illuminance_callback_period(period)
|
113
|
-
|
114
|
+
check_validity
|
115
|
+
|
116
|
+
send_request FUNCTION_SET_ILLUMINANCE_CALLBACK_PERIOD, [period], 'L', 8, ''
|
114
117
|
end
|
115
118
|
|
116
119
|
# Returns the period as set by BrickletAmbientLightV2#set_illuminance_callback_period.
|
117
120
|
def get_illuminance_callback_period
|
118
|
-
|
121
|
+
check_validity
|
122
|
+
|
123
|
+
send_request FUNCTION_GET_ILLUMINANCE_CALLBACK_PERIOD, [], '', 12, 'L'
|
119
124
|
end
|
120
125
|
|
121
126
|
# Sets the thresholds for the CALLBACK_ILLUMINANCE_REACHED callback.
|
@@ -129,18 +134,20 @@ module Tinkerforge
|
|
129
134
|
# "'i'", "Callback is triggered when the illuminance is *inside* the min and max values"
|
130
135
|
# "'<'", "Callback is triggered when the illuminance is smaller than the min value (max is ignored)"
|
131
136
|
# "'>'", "Callback is triggered when the illuminance is greater than the min value (max is ignored)"
|
132
|
-
#
|
133
|
-
# The default value is ('x', 0, 0).
|
134
137
|
def set_illuminance_callback_threshold(option, min, max)
|
135
|
-
|
138
|
+
check_validity
|
139
|
+
|
140
|
+
send_request FUNCTION_SET_ILLUMINANCE_CALLBACK_THRESHOLD, [option, min, max], 'k L L', 8, ''
|
136
141
|
end
|
137
142
|
|
138
143
|
# Returns the threshold as set by BrickletAmbientLightV2#set_illuminance_callback_threshold.
|
139
144
|
def get_illuminance_callback_threshold
|
140
|
-
|
145
|
+
check_validity
|
146
|
+
|
147
|
+
send_request FUNCTION_GET_ILLUMINANCE_CALLBACK_THRESHOLD, [], '', 17, 'k L L'
|
141
148
|
end
|
142
149
|
|
143
|
-
# Sets the period
|
150
|
+
# Sets the period with which the threshold callbacks
|
144
151
|
#
|
145
152
|
# * CALLBACK_ILLUMINANCE_REACHED,
|
146
153
|
#
|
@@ -149,15 +156,17 @@ module Tinkerforge
|
|
149
156
|
# * BrickletAmbientLightV2#set_illuminance_callback_threshold,
|
150
157
|
#
|
151
158
|
# keep being reached.
|
152
|
-
#
|
153
|
-
# The default value is 100.
|
154
159
|
def set_debounce_period(debounce)
|
155
|
-
|
160
|
+
check_validity
|
161
|
+
|
162
|
+
send_request FUNCTION_SET_DEBOUNCE_PERIOD, [debounce], 'L', 8, ''
|
156
163
|
end
|
157
164
|
|
158
165
|
# Returns the debounce period as set by BrickletAmbientLightV2#set_debounce_period.
|
159
166
|
def get_debounce_period
|
160
|
-
|
167
|
+
check_validity
|
168
|
+
|
169
|
+
send_request FUNCTION_GET_DEBOUNCE_PERIOD, [], '', 12, 'L'
|
161
170
|
end
|
162
171
|
|
163
172
|
# Sets the configuration. It is possible to configure an illuminance range
|
@@ -183,27 +192,31 @@ module Tinkerforge
|
|
183
192
|
# If the measurement is out-of-range or the sensor is saturated then you should
|
184
193
|
# configure the next higher illuminance range. If the highest range is already
|
185
194
|
# in use, then start to reduce the integration time.
|
186
|
-
#
|
187
|
-
# The default values are 0-8000lux illuminance range and 200ms integration time.
|
188
195
|
def set_configuration(illuminance_range, integration_time)
|
189
|
-
|
196
|
+
check_validity
|
197
|
+
|
198
|
+
send_request FUNCTION_SET_CONFIGURATION, [illuminance_range, integration_time], 'C C', 8, ''
|
190
199
|
end
|
191
200
|
|
192
201
|
# Returns the configuration as set by BrickletAmbientLightV2#set_configuration.
|
193
202
|
def get_configuration
|
194
|
-
|
203
|
+
check_validity
|
204
|
+
|
205
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
|
195
206
|
end
|
196
207
|
|
197
208
|
# Returns the UID, the UID where the Bricklet is connected to,
|
198
209
|
# the position, the hardware and firmware version as well as the
|
199
210
|
# device identifier.
|
200
211
|
#
|
201
|
-
# The position can be 'a', 'b', 'c' or '
|
212
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
213
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
214
|
+
# position 'z'.
|
202
215
|
#
|
203
216
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
204
217
|
# |device_identifier_constant|
|
205
218
|
def get_identity
|
206
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
219
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
207
220
|
end
|
208
221
|
|
209
222
|
# 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 2021-01-15. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.28 #
|
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
|
# Measures ambient light up to 64000lux
|
14
16
|
class BrickletAmbientLightV3 < 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
|
|
@@ -100,8 +102,9 @@ module Tinkerforge
|
|
100
102
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
101
103
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
102
104
|
|
103
|
-
@callback_formats[CALLBACK_ILLUMINANCE] = 'L'
|
105
|
+
@callback_formats[CALLBACK_ILLUMINANCE] = [12, 'L']
|
104
106
|
|
107
|
+
@ipcon.add_device self
|
105
108
|
end
|
106
109
|
|
107
110
|
# Returns the illuminance of the ambient light sensor. The measurement range goes
|
@@ -117,10 +120,12 @@ module Tinkerforge
|
|
117
120
|
# CALLBACK_ILLUMINANCE callback. You can set the callback configuration
|
118
121
|
# with BrickletAmbientLightV3#set_illuminance_callback_configuration.
|
119
122
|
def get_illuminance
|
120
|
-
|
123
|
+
check_validity
|
124
|
+
|
125
|
+
send_request FUNCTION_GET_ILLUMINANCE, [], '', 12, 'L'
|
121
126
|
end
|
122
127
|
|
123
|
-
# The period
|
128
|
+
# The period is the period with which the CALLBACK_ILLUMINANCE callback is triggered
|
124
129
|
# periodically. A value of 0 turns the callback off.
|
125
130
|
#
|
126
131
|
# If the `value has to change`-parameter is set to true, the callback is only
|
@@ -145,15 +150,17 @@ module Tinkerforge
|
|
145
150
|
# "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
|
146
151
|
#
|
147
152
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
148
|
-
#
|
149
|
-
# The default value is (0, false, 'x', 0, 0).
|
150
153
|
def set_illuminance_callback_configuration(period, value_has_to_change, option, min, max)
|
151
|
-
|
154
|
+
check_validity
|
155
|
+
|
156
|
+
send_request FUNCTION_SET_ILLUMINANCE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k L L', 8, ''
|
152
157
|
end
|
153
158
|
|
154
159
|
# Returns the callback configuration as set by BrickletAmbientLightV3#set_illuminance_callback_configuration.
|
155
160
|
def get_illuminance_callback_configuration
|
156
|
-
|
161
|
+
check_validity
|
162
|
+
|
163
|
+
send_request FUNCTION_GET_ILLUMINANCE_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k L L'
|
157
164
|
end
|
158
165
|
|
159
166
|
# Sets the configuration. It is possible to configure an illuminance range
|
@@ -176,15 +183,17 @@ module Tinkerforge
|
|
176
183
|
# If the measurement is out-of-range or the sensor is saturated then you should
|
177
184
|
# configure the next higher illuminance range. If the highest range is already
|
178
185
|
# in use, then start to reduce the integration time.
|
179
|
-
#
|
180
|
-
# The default values are 0-8000lux illuminance range and 150ms integration time.
|
181
186
|
def set_configuration(illuminance_range, integration_time)
|
182
|
-
|
187
|
+
check_validity
|
188
|
+
|
189
|
+
send_request FUNCTION_SET_CONFIGURATION, [illuminance_range, integration_time], 'C C', 8, ''
|
183
190
|
end
|
184
191
|
|
185
192
|
# Returns the configuration as set by BrickletAmbientLightV3#set_configuration.
|
186
193
|
def get_configuration
|
187
|
-
|
194
|
+
check_validity
|
195
|
+
|
196
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 10, 'C C'
|
188
197
|
end
|
189
198
|
|
190
199
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -199,7 +208,9 @@ module Tinkerforge
|
|
199
208
|
# The errors counts are for errors that occur on the Bricklet side. All
|
200
209
|
# Bricks have a similar function that returns the errors on the Brick side.
|
201
210
|
def get_spitfp_error_count
|
202
|
-
|
211
|
+
check_validity
|
212
|
+
|
213
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
203
214
|
end
|
204
215
|
|
205
216
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -212,12 +223,16 @@ module Tinkerforge
|
|
212
223
|
# This function is used by Brick Viewer during flashing. It should not be
|
213
224
|
# necessary to call it in a normal user program.
|
214
225
|
def set_bootloader_mode(mode)
|
215
|
-
|
226
|
+
check_validity
|
227
|
+
|
228
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
216
229
|
end
|
217
230
|
|
218
231
|
# Returns the current bootloader mode, see BrickletAmbientLightV3#set_bootloader_mode.
|
219
232
|
def get_bootloader_mode
|
220
|
-
|
233
|
+
check_validity
|
234
|
+
|
235
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
221
236
|
end
|
222
237
|
|
223
238
|
# Sets the firmware pointer for BrickletAmbientLightV3#write_firmware. The pointer has
|
@@ -227,7 +242,9 @@ module Tinkerforge
|
|
227
242
|
# This function is used by Brick Viewer during flashing. It should not be
|
228
243
|
# necessary to call it in a normal user program.
|
229
244
|
def set_write_firmware_pointer(pointer)
|
230
|
-
|
245
|
+
check_validity
|
246
|
+
|
247
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
231
248
|
end
|
232
249
|
|
233
250
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -239,7 +256,9 @@ module Tinkerforge
|
|
239
256
|
# This function is used by Brick Viewer during flashing. It should not be
|
240
257
|
# necessary to call it in a normal user program.
|
241
258
|
def write_firmware(data)
|
242
|
-
|
259
|
+
check_validity
|
260
|
+
|
261
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
243
262
|
end
|
244
263
|
|
245
264
|
# Sets the status LED configuration. By default the LED shows
|
@@ -250,22 +269,28 @@ module Tinkerforge
|
|
250
269
|
#
|
251
270
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
252
271
|
def set_status_led_config(config)
|
253
|
-
|
272
|
+
check_validity
|
273
|
+
|
274
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
254
275
|
end
|
255
276
|
|
256
277
|
# Returns the configuration as set by BrickletAmbientLightV3#set_status_led_config
|
257
278
|
def get_status_led_config
|
258
|
-
|
279
|
+
check_validity
|
280
|
+
|
281
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
259
282
|
end
|
260
283
|
|
261
|
-
# Returns the temperature
|
284
|
+
# Returns the temperature as measured inside the microcontroller. The
|
262
285
|
# value returned is not the ambient temperature!
|
263
286
|
#
|
264
287
|
# The temperature is only proportional to the real temperature and it has bad
|
265
288
|
# accuracy. Practically it is only useful as an indicator for
|
266
289
|
# temperature changes.
|
267
290
|
def get_chip_temperature
|
268
|
-
|
291
|
+
check_validity
|
292
|
+
|
293
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
269
294
|
end
|
270
295
|
|
271
296
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -275,7 +300,9 @@ module Tinkerforge
|
|
275
300
|
# calling functions on the existing ones will result in
|
276
301
|
# undefined behavior!
|
277
302
|
def reset
|
278
|
-
|
303
|
+
check_validity
|
304
|
+
|
305
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
279
306
|
end
|
280
307
|
|
281
308
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -284,25 +311,31 @@ module Tinkerforge
|
|
284
311
|
#
|
285
312
|
# We recommend that you use Brick Viewer to change the UID.
|
286
313
|
def write_uid(uid)
|
287
|
-
|
314
|
+
check_validity
|
315
|
+
|
316
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
288
317
|
end
|
289
318
|
|
290
319
|
# Returns the current UID as an integer. Encode as
|
291
320
|
# Base58 to get the usual string version.
|
292
321
|
def read_uid
|
293
|
-
|
322
|
+
check_validity
|
323
|
+
|
324
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
294
325
|
end
|
295
326
|
|
296
327
|
# Returns the UID, the UID where the Bricklet is connected to,
|
297
328
|
# the position, the hardware and firmware version as well as the
|
298
329
|
# device identifier.
|
299
330
|
#
|
300
|
-
# The position can be 'a', 'b', 'c' or '
|
331
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
332
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
333
|
+
# position 'z'.
|
301
334
|
#
|
302
335
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
303
336
|
# |device_identifier_constant|
|
304
337
|
def get_identity
|
305
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
338
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
306
339
|
end
|
307
340
|
|
308
341
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|