tinkerforge_async/bindings/
analog_in_v2_bricklet.rs

1/* ***********************************************************
2 * This file was automatically generated on 2024-02-16.      *
3 *                                                           *
4 * Rust Bindings Version 2.0.20                              *
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 DC voltage between 0V and 42V.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/AnalogInV2_Bricklet_Rust.html).
14#[allow(unused_imports)]
15use crate::{
16    base58::Uid, byte_converter::*, device::*, error::TinkerforgeError, ip_connection::async_io::AsyncIpConnection,
17    low_level_traits::LowLevelRead,
18};
19#[allow(unused_imports)]
20use futures_core::Stream;
21#[allow(unused_imports)]
22use tokio_stream::StreamExt;
23pub enum AnalogInV2BrickletFunction {
24    GetVoltage,
25    GetAnalogValue,
26    SetVoltageCallbackPeriod,
27    GetVoltageCallbackPeriod,
28    SetAnalogValueCallbackPeriod,
29    GetAnalogValueCallbackPeriod,
30    SetVoltageCallbackThreshold,
31    GetVoltageCallbackThreshold,
32    SetAnalogValueCallbackThreshold,
33    GetAnalogValueCallbackThreshold,
34    SetDebouncePeriod,
35    GetDebouncePeriod,
36    SetMovingAverage,
37    GetMovingAverage,
38    GetIdentity,
39    CallbackVoltage,
40    CallbackAnalogValue,
41    CallbackVoltageReached,
42    CallbackAnalogValueReached,
43}
44impl From<AnalogInV2BrickletFunction> for u8 {
45    fn from(fun: AnalogInV2BrickletFunction) -> Self {
46        match fun {
47            AnalogInV2BrickletFunction::GetVoltage => 1,
48            AnalogInV2BrickletFunction::GetAnalogValue => 2,
49            AnalogInV2BrickletFunction::SetVoltageCallbackPeriod => 3,
50            AnalogInV2BrickletFunction::GetVoltageCallbackPeriod => 4,
51            AnalogInV2BrickletFunction::SetAnalogValueCallbackPeriod => 5,
52            AnalogInV2BrickletFunction::GetAnalogValueCallbackPeriod => 6,
53            AnalogInV2BrickletFunction::SetVoltageCallbackThreshold => 7,
54            AnalogInV2BrickletFunction::GetVoltageCallbackThreshold => 8,
55            AnalogInV2BrickletFunction::SetAnalogValueCallbackThreshold => 9,
56            AnalogInV2BrickletFunction::GetAnalogValueCallbackThreshold => 10,
57            AnalogInV2BrickletFunction::SetDebouncePeriod => 11,
58            AnalogInV2BrickletFunction::GetDebouncePeriod => 12,
59            AnalogInV2BrickletFunction::SetMovingAverage => 13,
60            AnalogInV2BrickletFunction::GetMovingAverage => 14,
61            AnalogInV2BrickletFunction::GetIdentity => 255,
62            AnalogInV2BrickletFunction::CallbackVoltage => 15,
63            AnalogInV2BrickletFunction::CallbackAnalogValue => 16,
64            AnalogInV2BrickletFunction::CallbackVoltageReached => 17,
65            AnalogInV2BrickletFunction::CallbackAnalogValueReached => 18,
66        }
67    }
68}
69pub const ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
70pub const ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
71pub const ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
72pub const ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
73pub const ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
74
75#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
76pub struct VoltageCallbackThreshold {
77    pub option: char,
78    pub min: u16,
79    pub max: u16,
80}
81impl FromByteSlice for VoltageCallbackThreshold {
82    fn bytes_expected() -> usize {
83        5
84    }
85    fn from_le_byte_slice(bytes: &[u8]) -> VoltageCallbackThreshold {
86        VoltageCallbackThreshold {
87            option: <char>::from_le_byte_slice(&bytes[0..1]),
88            min: <u16>::from_le_byte_slice(&bytes[1..3]),
89            max: <u16>::from_le_byte_slice(&bytes[3..5]),
90        }
91    }
92}
93
94#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
95pub struct AnalogValueCallbackThreshold {
96    pub option: char,
97    pub min: u16,
98    pub max: u16,
99}
100impl FromByteSlice for AnalogValueCallbackThreshold {
101    fn bytes_expected() -> usize {
102        5
103    }
104    fn from_le_byte_slice(bytes: &[u8]) -> AnalogValueCallbackThreshold {
105        AnalogValueCallbackThreshold {
106            option: <char>::from_le_byte_slice(&bytes[0..1]),
107            min: <u16>::from_le_byte_slice(&bytes[1..3]),
108            max: <u16>::from_le_byte_slice(&bytes[3..5]),
109        }
110    }
111}
112
113#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
114pub struct Identity {
115    pub uid: String,
116    pub connected_uid: String,
117    pub position: char,
118    pub hardware_version: [u8; 3],
119    pub firmware_version: [u8; 3],
120    pub device_identifier: u16,
121}
122impl FromByteSlice for Identity {
123    fn bytes_expected() -> usize {
124        25
125    }
126    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
127        Identity {
128            uid: <String>::from_le_byte_slice(&bytes[0..8]),
129            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
130            position: <char>::from_le_byte_slice(&bytes[16..17]),
131            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
132            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
133            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
134        }
135    }
136}
137
138/// Measures DC voltage between 0V and 42V
139#[derive(Clone)]
140pub struct AnalogInV2Bricklet {
141    device: Device,
142}
143impl AnalogInV2Bricklet {
144    pub const DEVICE_IDENTIFIER: u16 = 251;
145    pub const DEVICE_DISPLAY_NAME: &'static str = "Analog In Bricklet 2.0";
146    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
147    pub fn new(uid: Uid, connection: AsyncIpConnection) -> AnalogInV2Bricklet {
148        let mut result = AnalogInV2Bricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
149        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::GetVoltage) as usize] = ResponseExpectedFlag::AlwaysTrue;
150        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::GetAnalogValue) as usize] = ResponseExpectedFlag::AlwaysTrue;
151        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::SetVoltageCallbackPeriod) as usize] =
152            ResponseExpectedFlag::True;
153        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::GetVoltageCallbackPeriod) as usize] =
154            ResponseExpectedFlag::AlwaysTrue;
155        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::SetAnalogValueCallbackPeriod) as usize] =
156            ResponseExpectedFlag::True;
157        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::GetAnalogValueCallbackPeriod) as usize] =
158            ResponseExpectedFlag::AlwaysTrue;
159        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::SetVoltageCallbackThreshold) as usize] =
160            ResponseExpectedFlag::True;
161        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::GetVoltageCallbackThreshold) as usize] =
162            ResponseExpectedFlag::AlwaysTrue;
163        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::SetAnalogValueCallbackThreshold) as usize] =
164            ResponseExpectedFlag::True;
165        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::GetAnalogValueCallbackThreshold) as usize] =
166            ResponseExpectedFlag::AlwaysTrue;
167        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::SetDebouncePeriod) as usize] = ResponseExpectedFlag::True;
168        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::GetDebouncePeriod) as usize] =
169            ResponseExpectedFlag::AlwaysTrue;
170        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::SetMovingAverage) as usize] = ResponseExpectedFlag::False;
171        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::GetMovingAverage) as usize] = ResponseExpectedFlag::AlwaysTrue;
172        result.device.response_expected[u8::from(AnalogInV2BrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
173        result
174    }
175
176    /// Returns the response expected flag for the function specified by the function ID parameter.
177    /// It is true if the function is expected to send a response, false otherwise.
178    ///
179    /// For getter functions this is enabled by default and cannot be disabled, because those
180    /// functions will always send a response. For callback configuration functions it is enabled
181    /// by default too, but can be disabled by [`set_response_expected`](crate::analog_in_v2_bricklet::AnalogInV2Bricklet::set_response_expected).
182    /// For setter functions it is disabled by default and can be enabled.
183    ///
184    /// Enabling the response expected flag for a setter function allows to detect timeouts
185    /// and other error conditions calls of this setter as well. The device will then send a response
186    /// for this purpose. If this flag is disabled for a setter function then no response is sent
187    /// and errors are silently ignored, because they cannot be detected.
188    ///
189    /// See [`set_response_expected`](crate::analog_in_v2_bricklet::AnalogInV2Bricklet::set_response_expected) for the list of function ID constants available for this function.
190    pub fn get_response_expected(&mut self, fun: AnalogInV2BrickletFunction) -> Result<bool, GetResponseExpectedError> {
191        self.device.get_response_expected(u8::from(fun))
192    }
193
194    /// Changes the response expected flag of the function specified by the function ID parameter.
195    /// This flag can only be changed for setter (default value: false) and callback configuration
196    /// functions (default value: true). For getter functions it is always enabled.
197    ///
198    /// Enabling the response expected flag for a setter function allows to detect timeouts and
199    /// other error conditions calls of this setter as well. The device will then send a response
200    /// for this purpose. If this flag is disabled for a setter function then no response is sent
201    /// and errors are silently ignored, because they cannot be detected.
202    pub fn set_response_expected(
203        &mut self,
204        fun: AnalogInV2BrickletFunction,
205        response_expected: bool,
206    ) -> Result<(), SetResponseExpectedError> {
207        self.device.set_response_expected(u8::from(fun), response_expected)
208    }
209
210    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
211    pub fn set_response_expected_all(&mut self, response_expected: bool) {
212        self.device.set_response_expected_all(response_expected)
213    }
214
215    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
216    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
217    pub fn get_api_version(&self) -> [u8; 3] {
218        self.device.api_version
219    }
220
221    /// This receiver is triggered periodically with the period that is set by
222    /// [`set_voltage_callback_period`]. The parameter is the voltage of the
223    /// sensor.
224    ///
225    /// Der [`get_voltage_callback_receiver`] receiver is only triggered if the voltage has changed since
226    /// the last triggering.
227    ///
228    /// [`set_voltage_callback_period`]: #method.set_voltage_callback_period
229    /// [`get_voltage_callback_receiver`]: #method.get_voltage_callback_receiver
230    pub async fn get_voltage_callback_receiver(&mut self) -> impl Stream<Item = u16> {
231        self.device
232            .get_callback_receiver(u8::from(AnalogInV2BrickletFunction::CallbackVoltage))
233            .await
234            .map(|p| u16::from_le_byte_slice(p.body()))
235    }
236
237    /// This receiver is triggered periodically with the period that is set by
238    /// [`set_analog_value_callback_period`]. The parameter is the analog
239    /// value of the sensor.
240    ///
241    /// The [`get_analog_value_callback_receiver`] receiver is only triggered if the voltage has changed
242    /// since the last triggering.
243    pub async fn get_analog_value_callback_receiver(&mut self) -> impl Stream<Item = u16> {
244        self.device
245            .get_callback_receiver(u8::from(AnalogInV2BrickletFunction::CallbackAnalogValue))
246            .await
247            .map(|p| u16::from_le_byte_slice(p.body()))
248    }
249
250    /// This receiver is triggered when the threshold as set by
251    /// [`set_voltage_callback_threshold`] is reached.
252    /// The parameter is the voltage of the sensor.
253    ///
254    /// If the threshold keeps being reached, the receiver is triggered periodically
255    /// with the period as set by [`set_debounce_period`].
256    pub async fn get_voltage_reached_callback_receiver(&mut self) -> impl Stream<Item = u16> {
257        self.device
258            .get_callback_receiver(u8::from(AnalogInV2BrickletFunction::CallbackVoltageReached))
259            .await
260            .map(|p| u16::from_le_byte_slice(p.body()))
261    }
262
263    /// This receiver is triggered when the threshold as set by
264    /// [`set_analog_value_callback_threshold`] is reached.
265    /// The parameter is the analog value of the sensor.
266    ///
267    /// If the threshold keeps being reached, the receiver is triggered periodically
268    /// with the period as set by [`set_debounce_period`].
269    pub async fn get_analog_value_reached_callback_receiver(&mut self) -> impl Stream<Item = u16> {
270        self.device
271            .get_callback_receiver(u8::from(AnalogInV2BrickletFunction::CallbackAnalogValueReached))
272            .await
273            .map(|p| u16::from_le_byte_slice(p.body()))
274    }
275
276    /// Returns the measured voltage. The resolution is approximately 10mV.
277    ///
278    /// If you want to get the voltage periodically, it is recommended to use the
279    /// [`get_voltage_callback_receiver`] receiver and set the period with
280    /// [`set_voltage_callback_period`].
281    pub async fn get_voltage(&mut self) -> Result<u16, TinkerforgeError> {
282        let payload = [0; 0];
283
284        #[allow(unused_variables)]
285        let result = self.device.get(u8::from(AnalogInV2BrickletFunction::GetVoltage), &payload).await?;
286        Ok(u16::from_le_byte_slice(result.body()))
287    }
288
289    /// Returns the value as read by a 12-bit analog-to-digital converter.
290    ///
291    /// If you want the analog value periodically, it is recommended to use the
292    /// [`get_analog_value_callback_receiver`] receiver and set the period with
293    /// [`set_analog_value_callback_period`].
294    pub async fn get_analog_value(&mut self) -> Result<u16, TinkerforgeError> {
295        let payload = [0; 0];
296
297        #[allow(unused_variables)]
298        let result = self.device.get(u8::from(AnalogInV2BrickletFunction::GetAnalogValue), &payload).await?;
299        Ok(u16::from_le_byte_slice(result.body()))
300    }
301
302    /// Sets the period with which the [`get_voltage_callback_receiver`] receiver is triggered
303    /// periodically. A value of 0 turns the receiver off.
304    ///
305    /// The [`get_voltage_callback_receiver`] receiver is only triggered if the voltage has changed since
306    /// the last triggering.
307    pub async fn set_voltage_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
308        let mut payload = [0; 4];
309        period.write_to_slice(&mut payload[0..4]);
310
311        #[allow(unused_variables)]
312        let result = self.device.set(u8::from(AnalogInV2BrickletFunction::SetVoltageCallbackPeriod), &payload).await?;
313        Ok(())
314    }
315
316    /// Returns the period as set by [`set_voltage_callback_period`].
317    pub async fn get_voltage_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
318        let payload = [0; 0];
319
320        #[allow(unused_variables)]
321        let result = self.device.get(u8::from(AnalogInV2BrickletFunction::GetVoltageCallbackPeriod), &payload).await?;
322        Ok(u32::from_le_byte_slice(result.body()))
323    }
324
325    /// Sets the period with which the [`get_analog_value_callback_receiver`] receiver is triggered
326    /// periodically. A value of 0 turns the receiver off.
327    ///
328    /// The [`get_analog_value_callback_receiver`] receiver is only triggered if the analog value has
329    /// changed since the last triggering.
330    pub async fn set_analog_value_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
331        let mut payload = [0; 4];
332        period.write_to_slice(&mut payload[0..4]);
333
334        #[allow(unused_variables)]
335        let result = self.device.set(u8::from(AnalogInV2BrickletFunction::SetAnalogValueCallbackPeriod), &payload).await?;
336        Ok(())
337    }
338
339    /// Returns the period as set by [`set_analog_value_callback_period`].
340    pub async fn get_analog_value_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
341        let payload = [0; 0];
342
343        #[allow(unused_variables)]
344        let result = self.device.get(u8::from(AnalogInV2BrickletFunction::GetAnalogValueCallbackPeriod), &payload).await?;
345        Ok(u32::from_le_byte_slice(result.body()))
346    }
347
348    /// Sets the thresholds for the [`get_voltage_reached_callback_receiver`] receiver.
349    ///
350    /// The following options are possible:
351    ///
352    ///  Option| Description
353    ///  --- | ---
354    ///  'x'|    Receiver is turned off
355    ///  'o'|    Receiver is triggered when the voltage is *outside* the min and max values
356    ///  'i'|    Receiver is triggered when the voltage is *inside* the min and max values
357    ///  '<'|    Receiver is triggered when the voltage is smaller than the min value (max is ignored)
358    ///  '>'|    Receiver is triggered when the voltage is greater than the min value (max is ignored)
359    ///
360    /// Associated constants:
361    /// * ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OFF
362    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
363    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
364    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
365    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_GREATER
366    pub async fn set_voltage_callback_threshold(&mut self, option: char, min: u16, max: u16) -> Result<(), TinkerforgeError> {
367        let mut payload = [0; 5];
368        option.write_to_slice(&mut payload[0..1]);
369        min.write_to_slice(&mut payload[1..3]);
370        max.write_to_slice(&mut payload[3..5]);
371
372        #[allow(unused_variables)]
373        let result = self.device.set(u8::from(AnalogInV2BrickletFunction::SetVoltageCallbackThreshold), &payload).await?;
374        Ok(())
375    }
376
377    /// Returns the threshold as set by [`set_voltage_callback_threshold`].
378    ///
379    /// Associated constants:
380    /// * ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OFF
381    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
382    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
383    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
384    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_GREATER
385    pub async fn get_voltage_callback_threshold(&mut self) -> Result<VoltageCallbackThreshold, TinkerforgeError> {
386        let payload = [0; 0];
387
388        #[allow(unused_variables)]
389        let result = self.device.get(u8::from(AnalogInV2BrickletFunction::GetVoltageCallbackThreshold), &payload).await?;
390        Ok(VoltageCallbackThreshold::from_le_byte_slice(result.body()))
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    /// * ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OFF
407    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
408    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
409    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
410    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_GREATER
411    pub async fn set_analog_value_callback_threshold(&mut self, option: char, min: u16, max: u16) -> Result<(), TinkerforgeError> {
412        let mut payload = [0; 5];
413        option.write_to_slice(&mut payload[0..1]);
414        min.write_to_slice(&mut payload[1..3]);
415        max.write_to_slice(&mut payload[3..5]);
416
417        #[allow(unused_variables)]
418        let result = self.device.set(u8::from(AnalogInV2BrickletFunction::SetAnalogValueCallbackThreshold), &payload).await?;
419        Ok(())
420    }
421
422    /// Returns the threshold as set by [`set_analog_value_callback_threshold`].
423    ///
424    /// Associated constants:
425    /// * ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OFF
426    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
427    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
428    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
429    ///	* ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_GREATER
430    pub async fn get_analog_value_callback_threshold(&mut self) -> Result<AnalogValueCallbackThreshold, TinkerforgeError> {
431        let payload = [0; 0];
432
433        #[allow(unused_variables)]
434        let result = self.device.get(u8::from(AnalogInV2BrickletFunction::GetAnalogValueCallbackThreshold), &payload).await?;
435        Ok(AnalogValueCallbackThreshold::from_le_byte_slice(result.body()))
436    }
437
438    /// Sets the period with which the threshold receivers
439    ///
440    /// * [`get_voltage_reached_callback_receiver`],
441    /// * [`get_analog_value_reached_callback_receiver`]
442    ///
443    /// are triggered, if the thresholds
444    ///
445    /// * [`set_voltage_callback_threshold`],
446    /// * [`set_analog_value_callback_threshold`]
447    ///
448    /// keep being reached.
449    pub async fn set_debounce_period(&mut self, debounce: u32) -> Result<(), TinkerforgeError> {
450        let mut payload = [0; 4];
451        debounce.write_to_slice(&mut payload[0..4]);
452
453        #[allow(unused_variables)]
454        let result = self.device.set(u8::from(AnalogInV2BrickletFunction::SetDebouncePeriod), &payload).await?;
455        Ok(())
456    }
457
458    /// Returns the debounce period as set by [`set_debounce_period`].
459    pub async fn get_debounce_period(&mut self) -> Result<u32, TinkerforgeError> {
460        let payload = [0; 0];
461
462        #[allow(unused_variables)]
463        let result = self.device.get(u8::from(AnalogInV2BrickletFunction::GetDebouncePeriod), &payload).await?;
464        Ok(u32::from_le_byte_slice(result.body()))
465    }
466
467    /// Sets the length of a [moving averaging](https://en.wikipedia.org/wiki/Moving_average)__
468    /// for the voltage.
469    ///
470    /// Setting the length to 1 will turn the averaging off. With less
471    /// averaging, there is more noise on the data.
472    pub async fn set_moving_average(&mut self, average: u8) -> Result<(), TinkerforgeError> {
473        let mut payload = [0; 1];
474        average.write_to_slice(&mut payload[0..1]);
475
476        #[allow(unused_variables)]
477        let result = self.device.set(u8::from(AnalogInV2BrickletFunction::SetMovingAverage), &payload).await?;
478        Ok(())
479    }
480
481    /// Returns the length of the moving average as set by [`set_moving_average`].
482    pub async fn get_moving_average(&mut self) -> Result<u8, TinkerforgeError> {
483        let payload = [0; 0];
484
485        #[allow(unused_variables)]
486        let result = self.device.get(u8::from(AnalogInV2BrickletFunction::GetMovingAverage), &payload).await?;
487        Ok(u8::from_le_byte_slice(result.body()))
488    }
489
490    /// Returns the UID, the UID where the Bricklet is connected to,
491    /// the position, the hardware and firmware version as well as the
492    /// device identifier.
493    ///
494    /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
495    /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
496    /// position 'z'.
497    ///
498    /// The device identifier numbers can be found [here](device_identifier).
499    /// |device_identifier_constant|
500    pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
501        let payload = [0; 0];
502
503        #[allow(unused_variables)]
504        let result = self.device.get(u8::from(AnalogInV2BrickletFunction::GetIdentity), &payload).await?;
505        Ok(Identity::from_le_byte_slice(result.body()))
506    }
507}