tinkerforge/bindings/distance_ir_bricklet.rs
1/* ***********************************************************
2 * This file was automatically generated on 2024-02-27. *
3 * *
4 * Rust Bindings Version 2.0.21 *
5 * *
6 * If you have a bugfix for this file and want to commit it, *
7 * please fix the bug in the generator. You can find a link *
8 * to the generators git repository on tinkerforge.com *
9 *************************************************************/
10
11//! Measures distance up to 150cm with infrared light.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/DistanceIR_Bricklet_Rust.html).
14use crate::{
15 byte_converter::*, converting_callback_receiver::ConvertingCallbackReceiver, converting_receiver::ConvertingReceiver, device::*,
16 ip_connection::GetRequestSender,
17};
18pub enum DistanceIrBrickletFunction {
19 GetDistance,
20 GetAnalogValue,
21 SetSamplingPoint,
22 GetSamplingPoint,
23 SetDistanceCallbackPeriod,
24 GetDistanceCallbackPeriod,
25 SetAnalogValueCallbackPeriod,
26 GetAnalogValueCallbackPeriod,
27 SetDistanceCallbackThreshold,
28 GetDistanceCallbackThreshold,
29 SetAnalogValueCallbackThreshold,
30 GetAnalogValueCallbackThreshold,
31 SetDebouncePeriod,
32 GetDebouncePeriod,
33 GetIdentity,
34 CallbackDistance,
35 CallbackAnalogValue,
36 CallbackDistanceReached,
37 CallbackAnalogValueReached,
38}
39impl From<DistanceIrBrickletFunction> for u8 {
40 fn from(fun: DistanceIrBrickletFunction) -> Self {
41 match fun {
42 DistanceIrBrickletFunction::GetDistance => 1,
43 DistanceIrBrickletFunction::GetAnalogValue => 2,
44 DistanceIrBrickletFunction::SetSamplingPoint => 3,
45 DistanceIrBrickletFunction::GetSamplingPoint => 4,
46 DistanceIrBrickletFunction::SetDistanceCallbackPeriod => 5,
47 DistanceIrBrickletFunction::GetDistanceCallbackPeriod => 6,
48 DistanceIrBrickletFunction::SetAnalogValueCallbackPeriod => 7,
49 DistanceIrBrickletFunction::GetAnalogValueCallbackPeriod => 8,
50 DistanceIrBrickletFunction::SetDistanceCallbackThreshold => 9,
51 DistanceIrBrickletFunction::GetDistanceCallbackThreshold => 10,
52 DistanceIrBrickletFunction::SetAnalogValueCallbackThreshold => 11,
53 DistanceIrBrickletFunction::GetAnalogValueCallbackThreshold => 12,
54 DistanceIrBrickletFunction::SetDebouncePeriod => 13,
55 DistanceIrBrickletFunction::GetDebouncePeriod => 14,
56 DistanceIrBrickletFunction::GetIdentity => 255,
57 DistanceIrBrickletFunction::CallbackDistance => 15,
58 DistanceIrBrickletFunction::CallbackAnalogValue => 16,
59 DistanceIrBrickletFunction::CallbackDistanceReached => 17,
60 DistanceIrBrickletFunction::CallbackAnalogValueReached => 18,
61 }
62 }
63}
64pub const DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
65pub const DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
66pub const DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
67pub const DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
68pub const DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
69
70#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
71pub struct DistanceCallbackThreshold {
72 pub option: char,
73 pub min: u16,
74 pub max: u16,
75}
76impl FromByteSlice for DistanceCallbackThreshold {
77 fn bytes_expected() -> usize { 5 }
78 fn from_le_byte_slice(bytes: &[u8]) -> DistanceCallbackThreshold {
79 DistanceCallbackThreshold {
80 option: <char>::from_le_byte_slice(&bytes[0..1]),
81 min: <u16>::from_le_byte_slice(&bytes[1..3]),
82 max: <u16>::from_le_byte_slice(&bytes[3..5]),
83 }
84 }
85}
86
87#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
88pub struct AnalogValueCallbackThreshold {
89 pub option: char,
90 pub min: u16,
91 pub max: u16,
92}
93impl FromByteSlice for AnalogValueCallbackThreshold {
94 fn bytes_expected() -> usize { 5 }
95 fn from_le_byte_slice(bytes: &[u8]) -> AnalogValueCallbackThreshold {
96 AnalogValueCallbackThreshold {
97 option: <char>::from_le_byte_slice(&bytes[0..1]),
98 min: <u16>::from_le_byte_slice(&bytes[1..3]),
99 max: <u16>::from_le_byte_slice(&bytes[3..5]),
100 }
101 }
102}
103
104#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
105pub struct Identity {
106 pub uid: String,
107 pub connected_uid: String,
108 pub position: char,
109 pub hardware_version: [u8; 3],
110 pub firmware_version: [u8; 3],
111 pub device_identifier: u16,
112}
113impl FromByteSlice for Identity {
114 fn bytes_expected() -> usize { 25 }
115 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
116 Identity {
117 uid: <String>::from_le_byte_slice(&bytes[0..8]),
118 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
119 position: <char>::from_le_byte_slice(&bytes[16..17]),
120 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
121 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
122 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
123 }
124 }
125}
126
127/// Measures distance up to 150cm with infrared light
128#[derive(Clone)]
129pub struct DistanceIrBricklet {
130 device: Device,
131}
132impl DistanceIrBricklet {
133 pub const DEVICE_IDENTIFIER: u16 = 25;
134 pub const DEVICE_DISPLAY_NAME: &'static str = "Distance IR Bricklet";
135 /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
136 pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> DistanceIrBricklet {
137 let mut result = DistanceIrBricklet { device: Device::new([2, 0, 1], uid, req_sender, 0) };
138 result.device.response_expected[u8::from(DistanceIrBrickletFunction::GetDistance) as usize] = ResponseExpectedFlag::AlwaysTrue;
139 result.device.response_expected[u8::from(DistanceIrBrickletFunction::GetAnalogValue) as usize] = ResponseExpectedFlag::AlwaysTrue;
140 result.device.response_expected[u8::from(DistanceIrBrickletFunction::SetSamplingPoint) as usize] = ResponseExpectedFlag::False;
141 result.device.response_expected[u8::from(DistanceIrBrickletFunction::GetSamplingPoint) as usize] = ResponseExpectedFlag::AlwaysTrue;
142 result.device.response_expected[u8::from(DistanceIrBrickletFunction::SetDistanceCallbackPeriod) as usize] =
143 ResponseExpectedFlag::True;
144 result.device.response_expected[u8::from(DistanceIrBrickletFunction::GetDistanceCallbackPeriod) as usize] =
145 ResponseExpectedFlag::AlwaysTrue;
146 result.device.response_expected[u8::from(DistanceIrBrickletFunction::SetAnalogValueCallbackPeriod) as usize] =
147 ResponseExpectedFlag::True;
148 result.device.response_expected[u8::from(DistanceIrBrickletFunction::GetAnalogValueCallbackPeriod) as usize] =
149 ResponseExpectedFlag::AlwaysTrue;
150 result.device.response_expected[u8::from(DistanceIrBrickletFunction::SetDistanceCallbackThreshold) as usize] =
151 ResponseExpectedFlag::True;
152 result.device.response_expected[u8::from(DistanceIrBrickletFunction::GetDistanceCallbackThreshold) as usize] =
153 ResponseExpectedFlag::AlwaysTrue;
154 result.device.response_expected[u8::from(DistanceIrBrickletFunction::SetAnalogValueCallbackThreshold) as usize] =
155 ResponseExpectedFlag::True;
156 result.device.response_expected[u8::from(DistanceIrBrickletFunction::GetAnalogValueCallbackThreshold) as usize] =
157 ResponseExpectedFlag::AlwaysTrue;
158 result.device.response_expected[u8::from(DistanceIrBrickletFunction::SetDebouncePeriod) as usize] = ResponseExpectedFlag::True;
159 result.device.response_expected[u8::from(DistanceIrBrickletFunction::GetDebouncePeriod) as usize] =
160 ResponseExpectedFlag::AlwaysTrue;
161 result.device.response_expected[u8::from(DistanceIrBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
162 result
163 }
164
165 /// Returns the response expected flag for the function specified by the function ID parameter.
166 /// It is true if the function is expected to send a response, false otherwise.
167 ///
168 /// For getter functions this is enabled by default and cannot be disabled, because those
169 /// functions will always send a response. For callback configuration functions it is enabled
170 /// by default too, but can be disabled by [`set_response_expected`](crate::distance_ir_bricklet::DistanceIrBricklet::set_response_expected).
171 /// For setter functions it is disabled by default and can be enabled.
172 ///
173 /// Enabling the response expected flag for a setter function allows to detect timeouts
174 /// and other error conditions calls of this setter as well. The device will then send a response
175 /// for this purpose. If this flag is disabled for a setter function then no response is sent
176 /// and errors are silently ignored, because they cannot be detected.
177 ///
178 /// See [`set_response_expected`](crate::distance_ir_bricklet::DistanceIrBricklet::set_response_expected) for the list of function ID constants available for this function.
179 pub fn get_response_expected(&mut self, fun: DistanceIrBrickletFunction) -> Result<bool, GetResponseExpectedError> {
180 self.device.get_response_expected(u8::from(fun))
181 }
182
183 /// Changes the response expected flag of the function specified by the function ID parameter.
184 /// This flag can only be changed for setter (default value: false) and callback configuration
185 /// functions (default value: true). For getter functions it is always enabled.
186 ///
187 /// Enabling the response expected flag for a setter function allows to detect timeouts and
188 /// other error conditions calls of this setter as well. The device will then send a response
189 /// for this purpose. If this flag is disabled for a setter function then no response is sent
190 /// and errors are silently ignored, because they cannot be detected.
191 pub fn set_response_expected(
192 &mut self,
193 fun: DistanceIrBrickletFunction,
194 response_expected: bool,
195 ) -> Result<(), SetResponseExpectedError> {
196 self.device.set_response_expected(u8::from(fun), response_expected)
197 }
198
199 /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
200 pub fn set_response_expected_all(&mut self, response_expected: bool) { self.device.set_response_expected_all(response_expected) }
201
202 /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
203 /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
204 pub fn get_api_version(&self) -> [u8; 3] { self.device.api_version }
205
206 /// This receiver is triggered periodically with the period that is set by
207 /// [`set_distance_callback_period`]. The parameter is the distance of the
208 /// sensor.
209 ///
210 /// The [`get_distance_callback_receiver`] receiver is only triggered if the distance has changed since the
211 /// last triggering.
212 ///
213 /// [`set_distance_callback_period`]: #method.set_distance_callback_period
214 /// [`get_distance_callback_receiver`]: #method.get_distance_callback_receiver
215 pub fn get_distance_callback_receiver(&self) -> ConvertingCallbackReceiver<u16> {
216 self.device.get_callback_receiver(u8::from(DistanceIrBrickletFunction::CallbackDistance))
217 }
218
219 /// This receiver is triggered periodically with the period that is set by
220 /// [`set_analog_value_callback_period`]. The parameter is the analog value of the
221 /// sensor.
222 ///
223 /// The [`get_analog_value_callback_receiver`] receiver is only triggered if the analog value has changed
224 /// since the last triggering.
225 pub fn get_analog_value_callback_receiver(&self) -> ConvertingCallbackReceiver<u16> {
226 self.device.get_callback_receiver(u8::from(DistanceIrBrickletFunction::CallbackAnalogValue))
227 }
228
229 /// This receiver is triggered when the threshold as set by
230 /// [`set_distance_callback_threshold`] is reached.
231 /// The parameter is the distance of the sensor.
232 ///
233 /// If the threshold keeps being reached, the receiver is triggered periodically
234 /// with the period as set by [`set_debounce_period`].
235 pub fn get_distance_reached_callback_receiver(&self) -> ConvertingCallbackReceiver<u16> {
236 self.device.get_callback_receiver(u8::from(DistanceIrBrickletFunction::CallbackDistanceReached))
237 }
238
239 /// This receiver is triggered when the threshold as set by
240 /// [`set_analog_value_callback_threshold`] is reached.
241 /// The parameter is the analog value of the sensor.
242 ///
243 /// If the threshold keeps being reached, the receiver is triggered periodically
244 /// with the period as set by [`set_debounce_period`].
245 pub fn get_analog_value_reached_callback_receiver(&self) -> ConvertingCallbackReceiver<u16> {
246 self.device.get_callback_receiver(u8::from(DistanceIrBrickletFunction::CallbackAnalogValueReached))
247 }
248
249 /// Returns the distance measured by the sensor. Possible
250 /// distance ranges are 40 to 300, 100 to 800 and 200 to 1500, depending on the
251 /// selected IR sensor.
252 ///
253 /// If you want to get the distance periodically, it is recommended to use the
254 /// [`get_distance_callback_receiver`] receiver and set the period with
255 /// [`set_distance_callback_period`].
256 pub fn get_distance(&self) -> ConvertingReceiver<u16> {
257 let payload = vec![0; 0];
258
259 self.device.get(u8::from(DistanceIrBrickletFunction::GetDistance), payload)
260 }
261
262 /// Returns the value as read by a 12-bit analog-to-digital converter.
263 ///
264 /// # Note
265 /// The value returned by [`get_distance`] is averaged over several samples
266 /// to yield less noise, while [`get_analog_value`] gives back raw
267 /// unfiltered analog values. The only reason to use [`get_analog_value`] is,
268 /// if you need the full resolution of the analog-to-digital converter.
269 ///
270 /// If you want the analog value periodically, it is recommended to use the
271 /// [`get_analog_value_callback_receiver`] receiver and set the period with
272 /// [`set_analog_value_callback_period`].
273 pub fn get_analog_value(&self) -> ConvertingReceiver<u16> {
274 let payload = vec![0; 0];
275
276 self.device.get(u8::from(DistanceIrBrickletFunction::GetAnalogValue), payload)
277 }
278
279 /// Sets a sampling point value to a specific position of the lookup table.
280 /// The lookup table comprises 128 equidistant analog values with
281 /// corresponding distances.
282 ///
283 /// If you measure a distance of 50cm at the analog value 2048, you
284 /// should call this function with (64, 5000). The utilized analog-to-digital
285 /// converter has a resolution of 12 bit. With 128 sampling points on the
286 /// whole range, this means that every sampling point has a size of 32
287 /// analog values. Thus the analog value 2048 has the corresponding sampling
288 /// point 64 = 2048/32.
289 ///
290 /// Sampling points are saved on the EEPROM of the Distance IR Bricklet and
291 /// loaded again on startup.
292 ///
293 /// # Note
294 /// An easy way to calibrate the sampling points of the Distance IR Bricklet is
295 /// implemented in the Brick Viewer. If you want to calibrate your Bricklet it is
296 /// highly recommended to use this implementation.
297 pub fn set_sampling_point(&self, position: u8, distance: u16) -> ConvertingReceiver<()> {
298 let mut payload = vec![0; 3];
299 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(position));
300 payload[1..3].copy_from_slice(&<u16>::to_le_byte_vec(distance));
301
302 self.device.set(u8::from(DistanceIrBrickletFunction::SetSamplingPoint), payload)
303 }
304
305 /// Returns the distance to a sampling point position as set by
306 /// [`set_sampling_point`].
307 pub fn get_sampling_point(&self, position: u8) -> ConvertingReceiver<u16> {
308 let mut payload = vec![0; 1];
309 payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(position));
310
311 self.device.get(u8::from(DistanceIrBrickletFunction::GetSamplingPoint), payload)
312 }
313
314 /// Sets the period with which the [`get_distance_callback_receiver`] receiver is triggered
315 /// periodically. A value of 0 turns the receiver off.
316 ///
317 /// The [`get_distance_callback_receiver`] receiver is only triggered if the distance has changed since the
318 /// last triggering.
319 pub fn set_distance_callback_period(&self, period: u32) -> ConvertingReceiver<()> {
320 let mut payload = vec![0; 4];
321 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
322
323 self.device.set(u8::from(DistanceIrBrickletFunction::SetDistanceCallbackPeriod), payload)
324 }
325
326 /// Returns the period as set by [`set_distance_callback_period`].
327 pub fn get_distance_callback_period(&self) -> ConvertingReceiver<u32> {
328 let payload = vec![0; 0];
329
330 self.device.get(u8::from(DistanceIrBrickletFunction::GetDistanceCallbackPeriod), payload)
331 }
332
333 /// Sets the period with which the [`get_analog_value_callback_receiver`] receiver is triggered
334 /// periodically. A value of 0 turns the receiver off.
335 ///
336 /// The [`get_analog_value_callback_receiver`] receiver is only triggered if the analog value has
337 /// changed since the last triggering.
338 pub fn set_analog_value_callback_period(&self, period: u32) -> ConvertingReceiver<()> {
339 let mut payload = vec![0; 4];
340 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
341
342 self.device.set(u8::from(DistanceIrBrickletFunction::SetAnalogValueCallbackPeriod), payload)
343 }
344
345 /// Returns the period as set by [`set_analog_value_callback_period`].
346 pub fn get_analog_value_callback_period(&self) -> ConvertingReceiver<u32> {
347 let payload = vec![0; 0];
348
349 self.device.get(u8::from(DistanceIrBrickletFunction::GetAnalogValueCallbackPeriod), payload)
350 }
351
352 /// Sets the thresholds for the [`get_distance_reached_callback_receiver`] receiver.
353 ///
354 /// The following options are possible:
355 ///
356 /// Option| Description
357 /// --- | ---
358 /// 'x'| Receiver is turned off
359 /// 'o'| Receiver is triggered when the distance is *outside* the min and max values
360 /// 'i'| Receiver is triggered when the distance is *inside* the min and max values
361 /// '<'| Receiver is triggered when the distance is smaller than the min value (max is ignored)
362 /// '>'| Receiver is triggered when the distance is greater than the min value (max is ignored)
363 ///
364 /// Associated constants:
365 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_OFF
366 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_OUTSIDE
367 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_INSIDE
368 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_SMALLER
369 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_GREATER
370 pub fn set_distance_callback_threshold(&self, option: char, min: u16, max: u16) -> ConvertingReceiver<()> {
371 let mut payload = vec![0; 5];
372 payload[0..1].copy_from_slice(&<char>::to_le_byte_vec(option));
373 payload[1..3].copy_from_slice(&<u16>::to_le_byte_vec(min));
374 payload[3..5].copy_from_slice(&<u16>::to_le_byte_vec(max));
375
376 self.device.set(u8::from(DistanceIrBrickletFunction::SetDistanceCallbackThreshold), payload)
377 }
378
379 /// Returns the threshold as set by [`set_distance_callback_threshold`].
380 ///
381 /// Associated constants:
382 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_OFF
383 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_OUTSIDE
384 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_INSIDE
385 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_SMALLER
386 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_GREATER
387 pub fn get_distance_callback_threshold(&self) -> ConvertingReceiver<DistanceCallbackThreshold> {
388 let payload = vec![0; 0];
389
390 self.device.get(u8::from(DistanceIrBrickletFunction::GetDistanceCallbackThreshold), payload)
391 }
392
393 /// Sets the thresholds for the [`get_analog_value_reached_callback_receiver`] receiver.
394 ///
395 /// The following options are possible:
396 ///
397 /// Option| Description
398 /// --- | ---
399 /// 'x'| Receiver is turned off
400 /// 'o'| Receiver is triggered when the analog value is *outside* the min and max values
401 /// 'i'| Receiver is triggered when the analog value is *inside* the min and max values
402 /// '<'| Receiver is triggered when the analog value is smaller than the min value (max is ignored)
403 /// '>'| Receiver is triggered when the analog value is greater than the min value (max is ignored)
404 ///
405 /// Associated constants:
406 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_OFF
407 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_OUTSIDE
408 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_INSIDE
409 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_SMALLER
410 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_GREATER
411 pub fn set_analog_value_callback_threshold(&self, option: char, min: u16, max: u16) -> ConvertingReceiver<()> {
412 let mut payload = vec![0; 5];
413 payload[0..1].copy_from_slice(&<char>::to_le_byte_vec(option));
414 payload[1..3].copy_from_slice(&<u16>::to_le_byte_vec(min));
415 payload[3..5].copy_from_slice(&<u16>::to_le_byte_vec(max));
416
417 self.device.set(u8::from(DistanceIrBrickletFunction::SetAnalogValueCallbackThreshold), payload)
418 }
419
420 /// Returns the threshold as set by [`set_analog_value_callback_threshold`].
421 ///
422 /// Associated constants:
423 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_OFF
424 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_OUTSIDE
425 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_INSIDE
426 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_SMALLER
427 /// * DISTANCE_IR_BRICKLET_THRESHOLD_OPTION_GREATER
428 pub fn get_analog_value_callback_threshold(&self) -> ConvertingReceiver<AnalogValueCallbackThreshold> {
429 let payload = vec![0; 0];
430
431 self.device.get(u8::from(DistanceIrBrickletFunction::GetAnalogValueCallbackThreshold), payload)
432 }
433
434 /// Sets the period with which the threshold receivers
435 ///
436 /// * [`get_distance_reached_callback_receiver`],
437 /// * [`get_analog_value_reached_callback_receiver`]
438 ///
439 /// are triggered, if the thresholds
440 ///
441 /// * [`set_distance_callback_threshold`],
442 /// * [`set_analog_value_callback_threshold`]
443 ///
444 /// keep being reached.
445 pub fn set_debounce_period(&self, debounce: u32) -> ConvertingReceiver<()> {
446 let mut payload = vec![0; 4];
447 payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(debounce));
448
449 self.device.set(u8::from(DistanceIrBrickletFunction::SetDebouncePeriod), payload)
450 }
451
452 /// Returns the debounce period as set by [`set_debounce_period`].
453 pub fn get_debounce_period(&self) -> ConvertingReceiver<u32> {
454 let payload = vec![0; 0];
455
456 self.device.get(u8::from(DistanceIrBrickletFunction::GetDebouncePeriod), payload)
457 }
458
459 /// Returns the UID, the UID where the Bricklet is connected to,
460 /// the position, the hardware and firmware version as well as the
461 /// device identifier.
462 ///
463 /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
464 /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
465 /// position 'z'.
466 ///
467 /// The device identifier numbers can be found [here](device_identifier).
468 /// |device_identifier_constant|
469 pub fn get_identity(&self) -> ConvertingReceiver<Identity> {
470 let payload = vec![0; 0];
471
472 self.device.get(u8::from(DistanceIrBrickletFunction::GetIdentity), payload)
473 }
474}