tinkerforge/bindings/
industrial_dual_analog_in_v2_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 two DC voltages between -35V and +35V with 24bit resolution each.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/IndustrialDualAnalogInV2_Bricklet_Rust.html).
14use crate::{
15    byte_converter::*, converting_callback_receiver::ConvertingCallbackReceiver, converting_receiver::ConvertingReceiver, device::*,
16    ip_connection::GetRequestSender,
17};
18pub enum IndustrialDualAnalogInV2BrickletFunction {
19    GetVoltage,
20    SetVoltageCallbackConfiguration,
21    GetVoltageCallbackConfiguration,
22    SetSampleRate,
23    GetSampleRate,
24    SetCalibration,
25    GetCalibration,
26    GetAdcValues,
27    SetChannelLedConfig,
28    GetChannelLedConfig,
29    SetChannelLedStatusConfig,
30    GetChannelLedStatusConfig,
31    GetAllVoltages,
32    SetAllVoltagesCallbackConfiguration,
33    GetAllVoltagesCallbackConfiguration,
34    GetSpitfpErrorCount,
35    SetBootloaderMode,
36    GetBootloaderMode,
37    SetWriteFirmwarePointer,
38    WriteFirmware,
39    SetStatusLedConfig,
40    GetStatusLedConfig,
41    GetChipTemperature,
42    Reset,
43    WriteUid,
44    ReadUid,
45    GetIdentity,
46    CallbackVoltage,
47    CallbackAllVoltages,
48}
49impl From<IndustrialDualAnalogInV2BrickletFunction> for u8 {
50    fn from(fun: IndustrialDualAnalogInV2BrickletFunction) -> Self {
51        match fun {
52            IndustrialDualAnalogInV2BrickletFunction::GetVoltage => 1,
53            IndustrialDualAnalogInV2BrickletFunction::SetVoltageCallbackConfiguration => 2,
54            IndustrialDualAnalogInV2BrickletFunction::GetVoltageCallbackConfiguration => 3,
55            IndustrialDualAnalogInV2BrickletFunction::SetSampleRate => 5,
56            IndustrialDualAnalogInV2BrickletFunction::GetSampleRate => 6,
57            IndustrialDualAnalogInV2BrickletFunction::SetCalibration => 7,
58            IndustrialDualAnalogInV2BrickletFunction::GetCalibration => 8,
59            IndustrialDualAnalogInV2BrickletFunction::GetAdcValues => 9,
60            IndustrialDualAnalogInV2BrickletFunction::SetChannelLedConfig => 10,
61            IndustrialDualAnalogInV2BrickletFunction::GetChannelLedConfig => 11,
62            IndustrialDualAnalogInV2BrickletFunction::SetChannelLedStatusConfig => 12,
63            IndustrialDualAnalogInV2BrickletFunction::GetChannelLedStatusConfig => 13,
64            IndustrialDualAnalogInV2BrickletFunction::GetAllVoltages => 14,
65            IndustrialDualAnalogInV2BrickletFunction::SetAllVoltagesCallbackConfiguration => 15,
66            IndustrialDualAnalogInV2BrickletFunction::GetAllVoltagesCallbackConfiguration => 16,
67            IndustrialDualAnalogInV2BrickletFunction::GetSpitfpErrorCount => 234,
68            IndustrialDualAnalogInV2BrickletFunction::SetBootloaderMode => 235,
69            IndustrialDualAnalogInV2BrickletFunction::GetBootloaderMode => 236,
70            IndustrialDualAnalogInV2BrickletFunction::SetWriteFirmwarePointer => 237,
71            IndustrialDualAnalogInV2BrickletFunction::WriteFirmware => 238,
72            IndustrialDualAnalogInV2BrickletFunction::SetStatusLedConfig => 239,
73            IndustrialDualAnalogInV2BrickletFunction::GetStatusLedConfig => 240,
74            IndustrialDualAnalogInV2BrickletFunction::GetChipTemperature => 242,
75            IndustrialDualAnalogInV2BrickletFunction::Reset => 243,
76            IndustrialDualAnalogInV2BrickletFunction::WriteUid => 248,
77            IndustrialDualAnalogInV2BrickletFunction::ReadUid => 249,
78            IndustrialDualAnalogInV2BrickletFunction::GetIdentity => 255,
79            IndustrialDualAnalogInV2BrickletFunction::CallbackVoltage => 4,
80            IndustrialDualAnalogInV2BrickletFunction::CallbackAllVoltages => 17,
81        }
82    }
83}
84pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
85pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
86pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
87pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
88pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
89pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_976_SPS: u8 = 0;
90pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_488_SPS: u8 = 1;
91pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_244_SPS: u8 = 2;
92pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_122_SPS: u8 = 3;
93pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_61_SPS: u8 = 4;
94pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_4_SPS: u8 = 5;
95pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_2_SPS: u8 = 6;
96pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_1_SPS: u8 = 7;
97pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_OFF: u8 = 0;
98pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_ON: u8 = 1;
99pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
100pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_SHOW_CHANNEL_STATUS: u8 = 3;
101pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_STATUS_CONFIG_THRESHOLD: u8 = 0;
102pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_STATUS_CONFIG_INTENSITY: u8 = 1;
103pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
104pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
105pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
106pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
107pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
108pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
109pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
110pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
111pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
112pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
113pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
114pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
115pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
116pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
117pub const INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
118
119#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
120pub struct VoltageCallbackConfiguration {
121    pub period: u32,
122    pub value_has_to_change: bool,
123    pub option: char,
124    pub min: i32,
125    pub max: i32,
126}
127impl FromByteSlice for VoltageCallbackConfiguration {
128    fn bytes_expected() -> usize { 14 }
129    fn from_le_byte_slice(bytes: &[u8]) -> VoltageCallbackConfiguration {
130        VoltageCallbackConfiguration {
131            period: <u32>::from_le_byte_slice(&bytes[0..4]),
132            value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
133            option: <char>::from_le_byte_slice(&bytes[5..6]),
134            min: <i32>::from_le_byte_slice(&bytes[6..10]),
135            max: <i32>::from_le_byte_slice(&bytes[10..14]),
136        }
137    }
138}
139
140#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
141pub struct VoltageEvent {
142    pub channel: u8,
143    pub voltage: i32,
144}
145impl FromByteSlice for VoltageEvent {
146    fn bytes_expected() -> usize { 5 }
147    fn from_le_byte_slice(bytes: &[u8]) -> VoltageEvent {
148        VoltageEvent { channel: <u8>::from_le_byte_slice(&bytes[0..1]), voltage: <i32>::from_le_byte_slice(&bytes[1..5]) }
149    }
150}
151
152#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
153pub struct Calibration {
154    pub offset: [i32; 2],
155    pub gain: [i32; 2],
156}
157impl FromByteSlice for Calibration {
158    fn bytes_expected() -> usize { 16 }
159    fn from_le_byte_slice(bytes: &[u8]) -> Calibration {
160        Calibration { offset: <[i32; 2]>::from_le_byte_slice(&bytes[0..8]), gain: <[i32; 2]>::from_le_byte_slice(&bytes[8..16]) }
161    }
162}
163
164#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
165pub struct ChannelLedStatusConfig {
166    pub min: i32,
167    pub max: i32,
168    pub config: u8,
169}
170impl FromByteSlice for ChannelLedStatusConfig {
171    fn bytes_expected() -> usize { 9 }
172    fn from_le_byte_slice(bytes: &[u8]) -> ChannelLedStatusConfig {
173        ChannelLedStatusConfig {
174            min: <i32>::from_le_byte_slice(&bytes[0..4]),
175            max: <i32>::from_le_byte_slice(&bytes[4..8]),
176            config: <u8>::from_le_byte_slice(&bytes[8..9]),
177        }
178    }
179}
180
181#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
182pub struct AllVoltagesCallbackConfiguration {
183    pub period: u32,
184    pub value_has_to_change: bool,
185}
186impl FromByteSlice for AllVoltagesCallbackConfiguration {
187    fn bytes_expected() -> usize { 5 }
188    fn from_le_byte_slice(bytes: &[u8]) -> AllVoltagesCallbackConfiguration {
189        AllVoltagesCallbackConfiguration {
190            period: <u32>::from_le_byte_slice(&bytes[0..4]),
191            value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
192        }
193    }
194}
195
196#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
197pub struct SpitfpErrorCount {
198    pub error_count_ack_checksum: u32,
199    pub error_count_message_checksum: u32,
200    pub error_count_frame: u32,
201    pub error_count_overflow: u32,
202}
203impl FromByteSlice for SpitfpErrorCount {
204    fn bytes_expected() -> usize { 16 }
205    fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
206        SpitfpErrorCount {
207            error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
208            error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
209            error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
210            error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
211        }
212    }
213}
214
215#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
216pub struct Identity {
217    pub uid: String,
218    pub connected_uid: String,
219    pub position: char,
220    pub hardware_version: [u8; 3],
221    pub firmware_version: [u8; 3],
222    pub device_identifier: u16,
223}
224impl FromByteSlice for Identity {
225    fn bytes_expected() -> usize { 25 }
226    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
227        Identity {
228            uid: <String>::from_le_byte_slice(&bytes[0..8]),
229            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
230            position: <char>::from_le_byte_slice(&bytes[16..17]),
231            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
232            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
233            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
234        }
235    }
236}
237
238/// Measures two DC voltages between -35V and +35V with 24bit resolution each
239#[derive(Clone)]
240pub struct IndustrialDualAnalogInV2Bricklet {
241    device: Device,
242}
243impl IndustrialDualAnalogInV2Bricklet {
244    pub const DEVICE_IDENTIFIER: u16 = 2121;
245    pub const DEVICE_DISPLAY_NAME: &'static str = "Industrial Dual Analog In Bricklet 2.0";
246    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
247    pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> IndustrialDualAnalogInV2Bricklet {
248        let mut result = IndustrialDualAnalogInV2Bricklet { device: Device::new([2, 0, 1], uid, req_sender, 0) };
249        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetVoltage) as usize] =
250            ResponseExpectedFlag::AlwaysTrue;
251        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::SetVoltageCallbackConfiguration) as usize] =
252            ResponseExpectedFlag::True;
253        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetVoltageCallbackConfiguration) as usize] =
254            ResponseExpectedFlag::AlwaysTrue;
255        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::SetSampleRate) as usize] =
256            ResponseExpectedFlag::False;
257        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetSampleRate) as usize] =
258            ResponseExpectedFlag::AlwaysTrue;
259        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::SetCalibration) as usize] =
260            ResponseExpectedFlag::False;
261        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetCalibration) as usize] =
262            ResponseExpectedFlag::AlwaysTrue;
263        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetAdcValues) as usize] =
264            ResponseExpectedFlag::AlwaysTrue;
265        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::SetChannelLedConfig) as usize] =
266            ResponseExpectedFlag::False;
267        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetChannelLedConfig) as usize] =
268            ResponseExpectedFlag::AlwaysTrue;
269        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::SetChannelLedStatusConfig) as usize] =
270            ResponseExpectedFlag::False;
271        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetChannelLedStatusConfig) as usize] =
272            ResponseExpectedFlag::AlwaysTrue;
273        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetAllVoltages) as usize] =
274            ResponseExpectedFlag::AlwaysTrue;
275        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::SetAllVoltagesCallbackConfiguration) as usize] =
276            ResponseExpectedFlag::True;
277        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetAllVoltagesCallbackConfiguration) as usize] =
278            ResponseExpectedFlag::AlwaysTrue;
279        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetSpitfpErrorCount) as usize] =
280            ResponseExpectedFlag::AlwaysTrue;
281        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::SetBootloaderMode) as usize] =
282            ResponseExpectedFlag::AlwaysTrue;
283        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetBootloaderMode) as usize] =
284            ResponseExpectedFlag::AlwaysTrue;
285        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::SetWriteFirmwarePointer) as usize] =
286            ResponseExpectedFlag::False;
287        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::WriteFirmware) as usize] =
288            ResponseExpectedFlag::AlwaysTrue;
289        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::SetStatusLedConfig) as usize] =
290            ResponseExpectedFlag::False;
291        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetStatusLedConfig) as usize] =
292            ResponseExpectedFlag::AlwaysTrue;
293        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetChipTemperature) as usize] =
294            ResponseExpectedFlag::AlwaysTrue;
295        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
296        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::WriteUid) as usize] =
297            ResponseExpectedFlag::False;
298        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::ReadUid) as usize] =
299            ResponseExpectedFlag::AlwaysTrue;
300        result.device.response_expected[u8::from(IndustrialDualAnalogInV2BrickletFunction::GetIdentity) as usize] =
301            ResponseExpectedFlag::AlwaysTrue;
302        result
303    }
304
305    /// Returns the response expected flag for the function specified by the function ID parameter.
306    /// It is true if the function is expected to send a response, false otherwise.
307    ///
308    /// For getter functions this is enabled by default and cannot be disabled, because those
309    /// functions will always send a response. For callback configuration functions it is enabled
310    /// by default too, but can be disabled by [`set_response_expected`](crate::industrial_dual_analog_in_v2_bricklet::IndustrialDualAnalogInV2Bricklet::set_response_expected).
311    /// For setter functions it is disabled by default and can be enabled.
312    ///
313    /// Enabling the response expected flag for a setter function allows to detect timeouts
314    /// and other error conditions calls of this setter as well. The device will then send a response
315    /// for this purpose. If this flag is disabled for a setter function then no response is sent
316    /// and errors are silently ignored, because they cannot be detected.
317    ///
318    /// See [`set_response_expected`](crate::industrial_dual_analog_in_v2_bricklet::IndustrialDualAnalogInV2Bricklet::set_response_expected) for the list of function ID constants available for this function.
319    pub fn get_response_expected(&mut self, fun: IndustrialDualAnalogInV2BrickletFunction) -> Result<bool, GetResponseExpectedError> {
320        self.device.get_response_expected(u8::from(fun))
321    }
322
323    /// Changes the response expected flag of the function specified by the function ID parameter.
324    /// This flag can only be changed for setter (default value: false) and callback configuration
325    /// functions (default value: true). For getter functions it is always enabled.
326    ///
327    /// Enabling the response expected flag for a setter function allows to detect timeouts and
328    /// other error conditions calls of this setter as well. The device will then send a response
329    /// for this purpose. If this flag is disabled for a setter function then no response is sent
330    /// and errors are silently ignored, because they cannot be detected.
331    pub fn set_response_expected(
332        &mut self,
333        fun: IndustrialDualAnalogInV2BrickletFunction,
334        response_expected: bool,
335    ) -> Result<(), SetResponseExpectedError> {
336        self.device.set_response_expected(u8::from(fun), response_expected)
337    }
338
339    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
340    pub fn set_response_expected_all(&mut self, response_expected: bool) { self.device.set_response_expected_all(response_expected) }
341
342    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
343    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
344    pub fn get_api_version(&self) -> [u8; 3] { self.device.api_version }
345
346    /// This receiver is triggered periodically according to the configuration set by
347    /// [`set_voltage_callback_configuration`].
348    ///
349    /// The parameter is the same as [`get_voltage`].
350    ///
351    /// [`get_voltage`]: #method.get_voltage
352    /// [`set_voltage_callback_configuration`]: #method.set_voltage_callback_configuration
353    pub fn get_voltage_callback_receiver(&self) -> ConvertingCallbackReceiver<VoltageEvent> {
354        self.device.get_callback_receiver(u8::from(IndustrialDualAnalogInV2BrickletFunction::CallbackVoltage))
355    }
356
357    /// This receiver is triggered periodically according to the configuration set by
358    /// [`set_all_voltages_callback_configuration`].
359    ///
360    /// The parameters are the same as [`get_all_voltages`].
361    ///
362    ///
363    /// .. versionadded:: 2.0.6$nbsp;(Plugin)
364    pub fn get_all_voltages_callback_receiver(&self) -> ConvertingCallbackReceiver<[i32; 2]> {
365        self.device.get_callback_receiver(u8::from(IndustrialDualAnalogInV2BrickletFunction::CallbackAllVoltages))
366    }
367
368    /// Returns the voltage for the given channel.
369    ///
370    ///
371    /// If you want to get the value periodically, it is recommended to use the
372    /// [`get_voltage_callback_receiver`] receiver. You can set the receiver configuration
373    /// with [`set_voltage_callback_configuration`].
374    pub fn get_voltage(&self, channel: u8) -> ConvertingReceiver<i32> {
375        let mut payload = vec![0; 1];
376        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(channel));
377
378        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetVoltage), payload)
379    }
380
381    /// The period is the period with which the [`get_voltage_callback_receiver`] receiver is triggered
382    /// periodically. A value of 0 turns the receiver off.
383    ///
384    /// If the `value has to change`-parameter is set to true, the receiver is only
385    /// triggered after the value has changed. If the value didn't change
386    /// within the period, the receiver is triggered immediately on change.
387    ///
388    /// If it is set to false, the receiver is continuously triggered with the period,
389    /// independent of the value.
390    ///
391    /// It is furthermore possible to constrain the receiver with thresholds.
392    ///
393    /// The `option`-parameter together with min/max sets a threshold for the [`get_voltage_callback_receiver`] receiver.
394    ///
395    /// The following options are possible:
396    ///
397    ///  Option| Description
398    ///  --- | ---
399    ///  'x'|    Threshold is turned off
400    ///  'o'|    Threshold is triggered when the value is *outside* the min and max values
401    ///  'i'|    Threshold is triggered when the value is *inside* or equal to the min and max values
402    ///  '<'|    Threshold is triggered when the value is smaller than the min value (max is ignored)
403    ///  '>'|    Threshold is triggered when the value is greater than the min value (max is ignored)
404    ///
405    /// If the option is set to 'x' (threshold turned off) the receiver is triggered with the fixed period.
406    ///
407    /// Associated constants:
408    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OFF
409    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
410    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
411    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
412    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_GREATER
413    pub fn set_voltage_callback_configuration(
414        &self,
415        channel: u8,
416        period: u32,
417        value_has_to_change: bool,
418        option: char,
419        min: i32,
420        max: i32,
421    ) -> ConvertingReceiver<()> {
422        let mut payload = vec![0; 15];
423        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(channel));
424        payload[1..5].copy_from_slice(&<u32>::to_le_byte_vec(period));
425        payload[5..6].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
426        payload[6..7].copy_from_slice(&<char>::to_le_byte_vec(option));
427        payload[7..11].copy_from_slice(&<i32>::to_le_byte_vec(min));
428        payload[11..15].copy_from_slice(&<i32>::to_le_byte_vec(max));
429
430        self.device.set(u8::from(IndustrialDualAnalogInV2BrickletFunction::SetVoltageCallbackConfiguration), payload)
431    }
432
433    /// Returns the receiver configuration as set by [`set_voltage_callback_configuration`].
434    ///
435    /// Associated constants:
436    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OFF
437    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
438    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
439    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
440    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_THRESHOLD_OPTION_GREATER
441    pub fn get_voltage_callback_configuration(&self, channel: u8) -> ConvertingReceiver<VoltageCallbackConfiguration> {
442        let mut payload = vec![0; 1];
443        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(channel));
444
445        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetVoltageCallbackConfiguration), payload)
446    }
447
448    /// Sets the sample rate. The sample rate can be between 1 sample per second
449    /// and 976 samples per second. Decreasing the sample rate will also decrease the
450    /// noise on the data.
451    ///
452    /// Associated constants:
453    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_976_SPS
454    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_488_SPS
455    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_244_SPS
456    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_122_SPS
457    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_61_SPS
458    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_4_SPS
459    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_2_SPS
460    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_1_SPS
461    pub fn set_sample_rate(&self, rate: u8) -> ConvertingReceiver<()> {
462        let mut payload = vec![0; 1];
463        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(rate));
464
465        self.device.set(u8::from(IndustrialDualAnalogInV2BrickletFunction::SetSampleRate), payload)
466    }
467
468    /// Returns the sample rate as set by [`set_sample_rate`].
469    ///
470    /// Associated constants:
471    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_976_SPS
472    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_488_SPS
473    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_244_SPS
474    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_122_SPS
475    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_61_SPS
476    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_4_SPS
477    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_2_SPS
478    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_SAMPLE_RATE_1_SPS
479    pub fn get_sample_rate(&self) -> ConvertingReceiver<u8> {
480        let payload = vec![0; 0];
481
482        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetSampleRate), payload)
483    }
484
485    /// Sets offset and gain of MCP3911 internal calibration registers.
486    ///
487    /// See MCP3911 datasheet 7.7 and 7.8. The Industrial Dual Analog In Bricklet 2.0
488    /// is already factory calibrated by Tinkerforge. It should not be necessary
489    /// for you to use this function
490    pub fn set_calibration(&self, offset: [i32; 2], gain: [i32; 2]) -> ConvertingReceiver<()> {
491        let mut payload = vec![0; 16];
492        payload[0..8].copy_from_slice(&<[i32; 2]>::to_le_byte_vec(offset));
493        payload[8..16].copy_from_slice(&<[i32; 2]>::to_le_byte_vec(gain));
494
495        self.device.set(u8::from(IndustrialDualAnalogInV2BrickletFunction::SetCalibration), payload)
496    }
497
498    /// Returns the calibration as set by [`set_calibration`].
499    pub fn get_calibration(&self) -> ConvertingReceiver<Calibration> {
500        let payload = vec![0; 0];
501
502        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetCalibration), payload)
503    }
504
505    /// Returns the ADC values as given by the MCP3911 IC. This function
506    /// is needed for proper calibration, see [`set_calibration`].
507    pub fn get_adc_values(&self) -> ConvertingReceiver<[i32; 2]> {
508        let payload = vec![0; 0];
509
510        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetAdcValues), payload)
511    }
512
513    /// Each channel has a corresponding LED. You can turn the LED off, on or show a
514    /// heartbeat. You can also set the LED to Channel Status. In this mode the
515    /// LED can either be turned on with a pre-defined threshold or the intensity
516    /// of the LED can change with the measured value.
517    ///
518    /// You can configure the channel status behavior with [`set_channel_led_status_config`].
519    ///
520    /// By default all channel LEDs are configured as Channel Status.
521    ///
522    /// Associated constants:
523    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_OFF
524    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_ON
525    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_SHOW_HEARTBEAT
526    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_SHOW_CHANNEL_STATUS
527    pub fn set_channel_led_config(&self, channel: u8, config: u8) -> ConvertingReceiver<()> {
528        let mut payload = vec![0; 2];
529        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(channel));
530        payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(config));
531
532        self.device.set(u8::from(IndustrialDualAnalogInV2BrickletFunction::SetChannelLedConfig), payload)
533    }
534
535    /// Returns the channel LED configuration as set by [`set_channel_led_config`]
536    ///
537    /// Associated constants:
538    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_OFF
539    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_ON
540    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_SHOW_HEARTBEAT
541    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_CONFIG_SHOW_CHANNEL_STATUS
542    pub fn get_channel_led_config(&self, channel: u8) -> ConvertingReceiver<u8> {
543        let mut payload = vec![0; 1];
544        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(channel));
545
546        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetChannelLedConfig), payload)
547    }
548
549    /// Sets the channel LED status config. This config is used if the channel LED is
550    /// configured as Channel Status, see [`set_channel_led_config`].
551    ///
552    /// For each channel you can choose between threshold and intensity mode.
553    ///
554    /// In threshold mode you can define a positive or a negative threshold.
555    /// For a positive threshold set the min parameter to the threshold value in mV
556    /// above which the LED should turn on and set the max parameter to 0. Example:
557    /// If you set a positive threshold of 10V, the LED will turn on as soon as the
558    /// voltage exceeds 10V and turn off again if it goes below 10V.
559    /// For a negative threshold set the max parameter to the threshold value in mV
560    /// below which the LED should turn on and set the min parameter to 0. Example:
561    /// If you set a negative threshold of 10V, the LED will turn on as soon as the
562    /// voltage goes below 10V and the LED will turn off when the voltage exceeds 10V.
563    ///
564    /// In intensity mode you can define a range in mV that is used to scale the brightness
565    /// of the LED. Example with min=4V, max=20V: The LED is off at 4V, on at 20V
566    /// and the brightness is linearly scaled between the values 4V and 20V. If the
567    /// min value is greater than the max value, the LED brightness is scaled the other
568    /// way around.
569    ///
570    /// Associated constants:
571    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_STATUS_CONFIG_THRESHOLD
572    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_STATUS_CONFIG_INTENSITY
573    pub fn set_channel_led_status_config(&self, channel: u8, min: i32, max: i32, config: u8) -> ConvertingReceiver<()> {
574        let mut payload = vec![0; 10];
575        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(channel));
576        payload[1..5].copy_from_slice(&<i32>::to_le_byte_vec(min));
577        payload[5..9].copy_from_slice(&<i32>::to_le_byte_vec(max));
578        payload[9..10].copy_from_slice(&<u8>::to_le_byte_vec(config));
579
580        self.device.set(u8::from(IndustrialDualAnalogInV2BrickletFunction::SetChannelLedStatusConfig), payload)
581    }
582
583    /// Returns the channel LED status configuration as set by
584    /// [`set_channel_led_status_config`].
585    ///
586    /// Associated constants:
587    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_STATUS_CONFIG_THRESHOLD
588    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_CHANNEL_LED_STATUS_CONFIG_INTENSITY
589    pub fn get_channel_led_status_config(&self, channel: u8) -> ConvertingReceiver<ChannelLedStatusConfig> {
590        let mut payload = vec![0; 1];
591        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(channel));
592
593        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetChannelLedStatusConfig), payload)
594    }
595
596    /// Returns the voltages for all channels.
597    ///
598    /// If you want to get the value periodically, it is recommended to use the
599    /// [`get_all_voltages_callback_receiver`] receiver. You can set the receiver configuration
600    /// with [`set_all_voltages_callback_configuration`].
601    ///
602    ///
603    /// .. versionadded:: 2.0.6$nbsp;(Plugin)
604    pub fn get_all_voltages(&self) -> ConvertingReceiver<[i32; 2]> {
605        let payload = vec![0; 0];
606
607        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetAllVoltages), payload)
608    }
609
610    /// The period is the period with which the [`get_all_voltages_callback_receiver`]
611    /// receiver is triggered periodically. A value of 0 turns the receiver off.
612    ///
613    /// If the `value has to change`-parameter is set to true, the receiver is only
614    /// triggered after at least one of the values has changed. If the values didn't
615    /// change within the period, the receiver is triggered immediately on change.
616    ///
617    /// If it is set to false, the receiver is continuously triggered with the period,
618    /// independent of the value.
619    ///
620    ///
621    /// .. versionadded:: 2.0.6$nbsp;(Plugin)
622    pub fn set_all_voltages_callback_configuration(&self, period: u32, value_has_to_change: bool) -> ConvertingReceiver<()> {
623        let mut payload = vec![0; 5];
624        payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
625        payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
626
627        self.device.set(u8::from(IndustrialDualAnalogInV2BrickletFunction::SetAllVoltagesCallbackConfiguration), payload)
628    }
629
630    /// Returns the receiver configuration as set by
631    /// [`set_all_voltages_callback_configuration`].
632    ///
633    ///
634    /// .. versionadded:: 2.0.6$nbsp;(Plugin)
635    pub fn get_all_voltages_callback_configuration(&self) -> ConvertingReceiver<AllVoltagesCallbackConfiguration> {
636        let payload = vec![0; 0];
637
638        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetAllVoltagesCallbackConfiguration), payload)
639    }
640
641    /// Returns the error count for the communication between Brick and Bricklet.
642    ///
643    /// The errors are divided into
644    ///
645    /// * ACK checksum errors,
646    /// * message checksum errors,
647    /// * framing errors and
648    /// * overflow errors.
649    ///
650    /// The errors counts are for errors that occur on the Bricklet side. All
651    /// Bricks have a similar function that returns the errors on the Brick side.
652    pub fn get_spitfp_error_count(&self) -> ConvertingReceiver<SpitfpErrorCount> {
653        let payload = vec![0; 0];
654
655        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetSpitfpErrorCount), payload)
656    }
657
658    /// Sets the bootloader mode and returns the status after the requested
659    /// mode change was instigated.
660    ///
661    /// You can change from bootloader mode to firmware mode and vice versa. A change
662    /// from bootloader mode to firmware mode will only take place if the entry function,
663    /// device identifier and CRC are present and correct.
664    ///
665    /// This function is used by Brick Viewer during flashing. It should not be
666    /// necessary to call it in a normal user program.
667    ///
668    /// Associated constants:
669    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
670    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE
671    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
672    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
673    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
674    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_OK
675    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE
676    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE
677    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT
678    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT
679    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH
680    pub fn set_bootloader_mode(&self, mode: u8) -> ConvertingReceiver<u8> {
681        let mut payload = vec![0; 1];
682        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(mode));
683
684        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::SetBootloaderMode), payload)
685    }
686
687    /// Returns the current bootloader mode, see [`set_bootloader_mode`].
688    ///
689    /// Associated constants:
690    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
691    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE
692    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
693    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
694    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
695    pub fn get_bootloader_mode(&self) -> ConvertingReceiver<u8> {
696        let payload = vec![0; 0];
697
698        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetBootloaderMode), payload)
699    }
700
701    /// Sets the firmware pointer for [`write_firmware`]. The pointer has
702    /// to be increased by chunks of size 64. The data is written to flash
703    /// every 4 chunks (which equals to one page of size 256).
704    ///
705    /// This function is used by Brick Viewer during flashing. It should not be
706    /// necessary to call it in a normal user program.
707    pub fn set_write_firmware_pointer(&self, pointer: u32) -> ConvertingReceiver<()> {
708        let mut payload = vec![0; 4];
709        payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(pointer));
710
711        self.device.set(u8::from(IndustrialDualAnalogInV2BrickletFunction::SetWriteFirmwarePointer), payload)
712    }
713
714    /// Writes 64 Bytes of firmware at the position as written by
715    /// [`set_write_firmware_pointer`] before. The firmware is written
716    /// to flash every 4 chunks.
717    ///
718    /// You can only write firmware in bootloader mode.
719    ///
720    /// This function is used by Brick Viewer during flashing. It should not be
721    /// necessary to call it in a normal user program.
722    pub fn write_firmware(&self, data: [u8; 64]) -> ConvertingReceiver<u8> {
723        let mut payload = vec![0; 64];
724        payload[0..64].copy_from_slice(&<[u8; 64]>::to_le_byte_vec(data));
725
726        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::WriteFirmware), payload)
727    }
728
729    /// Sets the status LED configuration. By default the LED shows
730    /// communication traffic between Brick and Bricklet, it flickers once
731    /// for every 10 received data packets.
732    ///
733    /// You can also turn the LED permanently on/off or show a heartbeat.
734    ///
735    /// If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
736    ///
737    /// Associated constants:
738    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_OFF
739    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_ON
740    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
741    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
742    pub fn set_status_led_config(&self, config: u8) -> ConvertingReceiver<()> {
743        let mut payload = vec![0; 1];
744        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(config));
745
746        self.device.set(u8::from(IndustrialDualAnalogInV2BrickletFunction::SetStatusLedConfig), payload)
747    }
748
749    /// Returns the configuration as set by [`set_status_led_config`]
750    ///
751    /// Associated constants:
752    /// * INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_OFF
753    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_ON
754    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
755    ///	* INDUSTRIAL_DUAL_ANALOG_IN_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
756    pub fn get_status_led_config(&self) -> ConvertingReceiver<u8> {
757        let payload = vec![0; 0];
758
759        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetStatusLedConfig), payload)
760    }
761
762    /// Returns the temperature as measured inside the microcontroller. The
763    /// value returned is not the ambient temperature!
764    ///
765    /// The temperature is only proportional to the real temperature and it has bad
766    /// accuracy. Practically it is only useful as an indicator for
767    /// temperature changes.
768    pub fn get_chip_temperature(&self) -> ConvertingReceiver<i16> {
769        let payload = vec![0; 0];
770
771        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetChipTemperature), payload)
772    }
773
774    /// Calling this function will reset the Bricklet. All configurations
775    /// will be lost.
776    ///
777    /// After a reset you have to create new device objects,
778    /// calling functions on the existing ones will result in
779    /// undefined behavior!
780    pub fn reset(&self) -> ConvertingReceiver<()> {
781        let payload = vec![0; 0];
782
783        self.device.set(u8::from(IndustrialDualAnalogInV2BrickletFunction::Reset), payload)
784    }
785
786    /// Writes a new UID into flash. If you want to set a new UID
787    /// you have to decode the Base58 encoded UID string into an
788    /// integer first.
789    ///
790    /// We recommend that you use Brick Viewer to change the UID.
791    pub fn write_uid(&self, uid: u32) -> ConvertingReceiver<()> {
792        let mut payload = vec![0; 4];
793        payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(uid));
794
795        self.device.set(u8::from(IndustrialDualAnalogInV2BrickletFunction::WriteUid), payload)
796    }
797
798    /// Returns the current UID as an integer. Encode as
799    /// Base58 to get the usual string version.
800    pub fn read_uid(&self) -> ConvertingReceiver<u32> {
801        let payload = vec![0; 0];
802
803        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::ReadUid), payload)
804    }
805
806    /// Returns the UID, the UID where the Bricklet is connected to,
807    /// the position, the hardware and firmware version as well as the
808    /// device identifier.
809    ///
810    /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
811    /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
812    /// position 'z'.
813    ///
814    /// The device identifier numbers can be found [here](device_identifier).
815    /// |device_identifier_constant|
816    pub fn get_identity(&self) -> ConvertingReceiver<Identity> {
817        let payload = vec![0; 0];
818
819        self.device.get(u8::from(IndustrialDualAnalogInV2BrickletFunction::GetIdentity), payload)
820    }
821}