tinkerforge/bindings/
barometer_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 air pressure and altitude changes.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/BarometerV2_Bricklet_Rust.html).
14use crate::{
15    byte_converter::*, converting_callback_receiver::ConvertingCallbackReceiver, converting_receiver::ConvertingReceiver, device::*,
16    ip_connection::GetRequestSender,
17};
18pub enum BarometerV2BrickletFunction {
19    GetAirPressure,
20    SetAirPressureCallbackConfiguration,
21    GetAirPressureCallbackConfiguration,
22    GetAltitude,
23    SetAltitudeCallbackConfiguration,
24    GetAltitudeCallbackConfiguration,
25    GetTemperature,
26    SetTemperatureCallbackConfiguration,
27    GetTemperatureCallbackConfiguration,
28    SetMovingAverageConfiguration,
29    GetMovingAverageConfiguration,
30    SetReferenceAirPressure,
31    GetReferenceAirPressure,
32    SetCalibration,
33    GetCalibration,
34    SetSensorConfiguration,
35    GetSensorConfiguration,
36    GetSpitfpErrorCount,
37    SetBootloaderMode,
38    GetBootloaderMode,
39    SetWriteFirmwarePointer,
40    WriteFirmware,
41    SetStatusLedConfig,
42    GetStatusLedConfig,
43    GetChipTemperature,
44    Reset,
45    WriteUid,
46    ReadUid,
47    GetIdentity,
48    CallbackAirPressure,
49    CallbackAltitude,
50    CallbackTemperature,
51}
52impl From<BarometerV2BrickletFunction> for u8 {
53    fn from(fun: BarometerV2BrickletFunction) -> Self {
54        match fun {
55            BarometerV2BrickletFunction::GetAirPressure => 1,
56            BarometerV2BrickletFunction::SetAirPressureCallbackConfiguration => 2,
57            BarometerV2BrickletFunction::GetAirPressureCallbackConfiguration => 3,
58            BarometerV2BrickletFunction::GetAltitude => 5,
59            BarometerV2BrickletFunction::SetAltitudeCallbackConfiguration => 6,
60            BarometerV2BrickletFunction::GetAltitudeCallbackConfiguration => 7,
61            BarometerV2BrickletFunction::GetTemperature => 9,
62            BarometerV2BrickletFunction::SetTemperatureCallbackConfiguration => 10,
63            BarometerV2BrickletFunction::GetTemperatureCallbackConfiguration => 11,
64            BarometerV2BrickletFunction::SetMovingAverageConfiguration => 13,
65            BarometerV2BrickletFunction::GetMovingAverageConfiguration => 14,
66            BarometerV2BrickletFunction::SetReferenceAirPressure => 15,
67            BarometerV2BrickletFunction::GetReferenceAirPressure => 16,
68            BarometerV2BrickletFunction::SetCalibration => 17,
69            BarometerV2BrickletFunction::GetCalibration => 18,
70            BarometerV2BrickletFunction::SetSensorConfiguration => 19,
71            BarometerV2BrickletFunction::GetSensorConfiguration => 20,
72            BarometerV2BrickletFunction::GetSpitfpErrorCount => 234,
73            BarometerV2BrickletFunction::SetBootloaderMode => 235,
74            BarometerV2BrickletFunction::GetBootloaderMode => 236,
75            BarometerV2BrickletFunction::SetWriteFirmwarePointer => 237,
76            BarometerV2BrickletFunction::WriteFirmware => 238,
77            BarometerV2BrickletFunction::SetStatusLedConfig => 239,
78            BarometerV2BrickletFunction::GetStatusLedConfig => 240,
79            BarometerV2BrickletFunction::GetChipTemperature => 242,
80            BarometerV2BrickletFunction::Reset => 243,
81            BarometerV2BrickletFunction::WriteUid => 248,
82            BarometerV2BrickletFunction::ReadUid => 249,
83            BarometerV2BrickletFunction::GetIdentity => 255,
84            BarometerV2BrickletFunction::CallbackAirPressure => 4,
85            BarometerV2BrickletFunction::CallbackAltitude => 8,
86            BarometerV2BrickletFunction::CallbackTemperature => 12,
87        }
88    }
89}
90pub const BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
91pub const BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
92pub const BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
93pub const BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
94pub const BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
95pub const BAROMETER_V2_BRICKLET_DATA_RATE_OFF: u8 = 0;
96pub const BAROMETER_V2_BRICKLET_DATA_RATE_1HZ: u8 = 1;
97pub const BAROMETER_V2_BRICKLET_DATA_RATE_10HZ: u8 = 2;
98pub const BAROMETER_V2_BRICKLET_DATA_RATE_25HZ: u8 = 3;
99pub const BAROMETER_V2_BRICKLET_DATA_RATE_50HZ: u8 = 4;
100pub const BAROMETER_V2_BRICKLET_DATA_RATE_75HZ: u8 = 5;
101pub const BAROMETER_V2_BRICKLET_LOW_PASS_FILTER_OFF: u8 = 0;
102pub const BAROMETER_V2_BRICKLET_LOW_PASS_FILTER_1_9TH: u8 = 1;
103pub const BAROMETER_V2_BRICKLET_LOW_PASS_FILTER_1_20TH: u8 = 2;
104pub const BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
105pub const BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
106pub const BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
107pub const BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
108pub const BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
109pub const BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
110pub const BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
111pub const BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
112pub const BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
113pub const BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
114pub const BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
115pub const BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
116pub const BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
117pub const BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
118pub const BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
119
120#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
121pub struct AirPressureCallbackConfiguration {
122    pub period: u32,
123    pub value_has_to_change: bool,
124    pub option: char,
125    pub min: i32,
126    pub max: i32,
127}
128impl FromByteSlice for AirPressureCallbackConfiguration {
129    fn bytes_expected() -> usize { 14 }
130    fn from_le_byte_slice(bytes: &[u8]) -> AirPressureCallbackConfiguration {
131        AirPressureCallbackConfiguration {
132            period: <u32>::from_le_byte_slice(&bytes[0..4]),
133            value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
134            option: <char>::from_le_byte_slice(&bytes[5..6]),
135            min: <i32>::from_le_byte_slice(&bytes[6..10]),
136            max: <i32>::from_le_byte_slice(&bytes[10..14]),
137        }
138    }
139}
140
141#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
142pub struct AltitudeCallbackConfiguration {
143    pub period: u32,
144    pub value_has_to_change: bool,
145    pub option: char,
146    pub min: i32,
147    pub max: i32,
148}
149impl FromByteSlice for AltitudeCallbackConfiguration {
150    fn bytes_expected() -> usize { 14 }
151    fn from_le_byte_slice(bytes: &[u8]) -> AltitudeCallbackConfiguration {
152        AltitudeCallbackConfiguration {
153            period: <u32>::from_le_byte_slice(&bytes[0..4]),
154            value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
155            option: <char>::from_le_byte_slice(&bytes[5..6]),
156            min: <i32>::from_le_byte_slice(&bytes[6..10]),
157            max: <i32>::from_le_byte_slice(&bytes[10..14]),
158        }
159    }
160}
161
162#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
163pub struct TemperatureCallbackConfiguration {
164    pub period: u32,
165    pub value_has_to_change: bool,
166    pub option: char,
167    pub min: i32,
168    pub max: i32,
169}
170impl FromByteSlice for TemperatureCallbackConfiguration {
171    fn bytes_expected() -> usize { 14 }
172    fn from_le_byte_slice(bytes: &[u8]) -> TemperatureCallbackConfiguration {
173        TemperatureCallbackConfiguration {
174            period: <u32>::from_le_byte_slice(&bytes[0..4]),
175            value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
176            option: <char>::from_le_byte_slice(&bytes[5..6]),
177            min: <i32>::from_le_byte_slice(&bytes[6..10]),
178            max: <i32>::from_le_byte_slice(&bytes[10..14]),
179        }
180    }
181}
182
183#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
184pub struct MovingAverageConfiguration {
185    pub moving_average_length_air_pressure: u16,
186    pub moving_average_length_temperature: u16,
187}
188impl FromByteSlice for MovingAverageConfiguration {
189    fn bytes_expected() -> usize { 4 }
190    fn from_le_byte_slice(bytes: &[u8]) -> MovingAverageConfiguration {
191        MovingAverageConfiguration {
192            moving_average_length_air_pressure: <u16>::from_le_byte_slice(&bytes[0..2]),
193            moving_average_length_temperature: <u16>::from_le_byte_slice(&bytes[2..4]),
194        }
195    }
196}
197
198#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
199pub struct Calibration {
200    pub measured_air_pressure: i32,
201    pub actual_air_pressure: i32,
202}
203impl FromByteSlice for Calibration {
204    fn bytes_expected() -> usize { 8 }
205    fn from_le_byte_slice(bytes: &[u8]) -> Calibration {
206        Calibration {
207            measured_air_pressure: <i32>::from_le_byte_slice(&bytes[0..4]),
208            actual_air_pressure: <i32>::from_le_byte_slice(&bytes[4..8]),
209        }
210    }
211}
212
213#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
214pub struct SensorConfiguration {
215    pub data_rate: u8,
216    pub air_pressure_low_pass_filter: u8,
217}
218impl FromByteSlice for SensorConfiguration {
219    fn bytes_expected() -> usize { 2 }
220    fn from_le_byte_slice(bytes: &[u8]) -> SensorConfiguration {
221        SensorConfiguration {
222            data_rate: <u8>::from_le_byte_slice(&bytes[0..1]),
223            air_pressure_low_pass_filter: <u8>::from_le_byte_slice(&bytes[1..2]),
224        }
225    }
226}
227
228#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
229pub struct SpitfpErrorCount {
230    pub error_count_ack_checksum: u32,
231    pub error_count_message_checksum: u32,
232    pub error_count_frame: u32,
233    pub error_count_overflow: u32,
234}
235impl FromByteSlice for SpitfpErrorCount {
236    fn bytes_expected() -> usize { 16 }
237    fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
238        SpitfpErrorCount {
239            error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
240            error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
241            error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
242            error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
243        }
244    }
245}
246
247#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
248pub struct Identity {
249    pub uid: String,
250    pub connected_uid: String,
251    pub position: char,
252    pub hardware_version: [u8; 3],
253    pub firmware_version: [u8; 3],
254    pub device_identifier: u16,
255}
256impl FromByteSlice for Identity {
257    fn bytes_expected() -> usize { 25 }
258    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
259        Identity {
260            uid: <String>::from_le_byte_slice(&bytes[0..8]),
261            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
262            position: <char>::from_le_byte_slice(&bytes[16..17]),
263            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
264            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
265            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
266        }
267    }
268}
269
270/// Measures air pressure and altitude changes
271#[derive(Clone)]
272pub struct BarometerV2Bricklet {
273    device: Device,
274}
275impl BarometerV2Bricklet {
276    pub const DEVICE_IDENTIFIER: u16 = 2117;
277    pub const DEVICE_DISPLAY_NAME: &'static str = "Barometer Bricklet 2.0";
278    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
279    pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> BarometerV2Bricklet {
280        let mut result = BarometerV2Bricklet { device: Device::new([2, 0, 0], uid, req_sender, 0) };
281        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetAirPressure) as usize] = ResponseExpectedFlag::AlwaysTrue;
282        result.device.response_expected[u8::from(BarometerV2BrickletFunction::SetAirPressureCallbackConfiguration) as usize] =
283            ResponseExpectedFlag::True;
284        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetAirPressureCallbackConfiguration) as usize] =
285            ResponseExpectedFlag::AlwaysTrue;
286        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetAltitude) as usize] = ResponseExpectedFlag::AlwaysTrue;
287        result.device.response_expected[u8::from(BarometerV2BrickletFunction::SetAltitudeCallbackConfiguration) as usize] =
288            ResponseExpectedFlag::True;
289        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetAltitudeCallbackConfiguration) as usize] =
290            ResponseExpectedFlag::AlwaysTrue;
291        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetTemperature) as usize] = ResponseExpectedFlag::AlwaysTrue;
292        result.device.response_expected[u8::from(BarometerV2BrickletFunction::SetTemperatureCallbackConfiguration) as usize] =
293            ResponseExpectedFlag::True;
294        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetTemperatureCallbackConfiguration) as usize] =
295            ResponseExpectedFlag::AlwaysTrue;
296        result.device.response_expected[u8::from(BarometerV2BrickletFunction::SetMovingAverageConfiguration) as usize] =
297            ResponseExpectedFlag::False;
298        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetMovingAverageConfiguration) as usize] =
299            ResponseExpectedFlag::AlwaysTrue;
300        result.device.response_expected[u8::from(BarometerV2BrickletFunction::SetReferenceAirPressure) as usize] =
301            ResponseExpectedFlag::False;
302        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetReferenceAirPressure) as usize] =
303            ResponseExpectedFlag::AlwaysTrue;
304        result.device.response_expected[u8::from(BarometerV2BrickletFunction::SetCalibration) as usize] = ResponseExpectedFlag::False;
305        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetCalibration) as usize] = ResponseExpectedFlag::AlwaysTrue;
306        result.device.response_expected[u8::from(BarometerV2BrickletFunction::SetSensorConfiguration) as usize] =
307            ResponseExpectedFlag::False;
308        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetSensorConfiguration) as usize] =
309            ResponseExpectedFlag::AlwaysTrue;
310        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetSpitfpErrorCount) as usize] =
311            ResponseExpectedFlag::AlwaysTrue;
312        result.device.response_expected[u8::from(BarometerV2BrickletFunction::SetBootloaderMode) as usize] =
313            ResponseExpectedFlag::AlwaysTrue;
314        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetBootloaderMode) as usize] =
315            ResponseExpectedFlag::AlwaysTrue;
316        result.device.response_expected[u8::from(BarometerV2BrickletFunction::SetWriteFirmwarePointer) as usize] =
317            ResponseExpectedFlag::False;
318        result.device.response_expected[u8::from(BarometerV2BrickletFunction::WriteFirmware) as usize] = ResponseExpectedFlag::AlwaysTrue;
319        result.device.response_expected[u8::from(BarometerV2BrickletFunction::SetStatusLedConfig) as usize] = ResponseExpectedFlag::False;
320        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetStatusLedConfig) as usize] =
321            ResponseExpectedFlag::AlwaysTrue;
322        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetChipTemperature) as usize] =
323            ResponseExpectedFlag::AlwaysTrue;
324        result.device.response_expected[u8::from(BarometerV2BrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
325        result.device.response_expected[u8::from(BarometerV2BrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
326        result.device.response_expected[u8::from(BarometerV2BrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
327        result.device.response_expected[u8::from(BarometerV2BrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
328        result
329    }
330
331    /// Returns the response expected flag for the function specified by the function ID parameter.
332    /// It is true if the function is expected to send a response, false otherwise.
333    ///
334    /// For getter functions this is enabled by default and cannot be disabled, because those
335    /// functions will always send a response. For callback configuration functions it is enabled
336    /// by default too, but can be disabled by [`set_response_expected`](crate::barometer_v2_bricklet::BarometerV2Bricklet::set_response_expected).
337    /// For setter functions it is disabled by default and can be enabled.
338    ///
339    /// Enabling the response expected flag for a setter function allows to detect timeouts
340    /// and other error conditions calls of this setter as well. The device will then send a response
341    /// for this purpose. If this flag is disabled for a setter function then no response is sent
342    /// and errors are silently ignored, because they cannot be detected.
343    ///
344    /// See [`set_response_expected`](crate::barometer_v2_bricklet::BarometerV2Bricklet::set_response_expected) for the list of function ID constants available for this function.
345    pub fn get_response_expected(&mut self, fun: BarometerV2BrickletFunction) -> Result<bool, GetResponseExpectedError> {
346        self.device.get_response_expected(u8::from(fun))
347    }
348
349    /// Changes the response expected flag of the function specified by the function ID parameter.
350    /// This flag can only be changed for setter (default value: false) and callback configuration
351    /// functions (default value: true). For getter functions it is always enabled.
352    ///
353    /// Enabling the response expected flag for a setter function allows to detect timeouts and
354    /// other error conditions calls of this setter as well. The device will then send a response
355    /// for this purpose. If this flag is disabled for a setter function then no response is sent
356    /// and errors are silently ignored, because they cannot be detected.
357    pub fn set_response_expected(
358        &mut self,
359        fun: BarometerV2BrickletFunction,
360        response_expected: bool,
361    ) -> Result<(), SetResponseExpectedError> {
362        self.device.set_response_expected(u8::from(fun), response_expected)
363    }
364
365    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
366    pub fn set_response_expected_all(&mut self, response_expected: bool) { self.device.set_response_expected_all(response_expected) }
367
368    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
369    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
370    pub fn get_api_version(&self) -> [u8; 3] { self.device.api_version }
371
372    /// This receiver is triggered periodically according to the configuration set by
373    /// [`set_air_pressure_callback_configuration`].
374    ///
375    /// The parameter is the same as [`get_air_pressure`].
376    ///
377    /// [`get_air_pressure`]: #method.get_air_pressure
378    /// [`set_air_pressure_callback_configuration`]: #method.set_air_pressure_callback_configuration
379    pub fn get_air_pressure_callback_receiver(&self) -> ConvertingCallbackReceiver<i32> {
380        self.device.get_callback_receiver(u8::from(BarometerV2BrickletFunction::CallbackAirPressure))
381    }
382
383    /// This receiver is triggered periodically according to the configuration set by
384    /// [`set_altitude_callback_configuration`].
385    ///
386    /// The parameter is the same as [`get_altitude`].
387    pub fn get_altitude_callback_receiver(&self) -> ConvertingCallbackReceiver<i32> {
388        self.device.get_callback_receiver(u8::from(BarometerV2BrickletFunction::CallbackAltitude))
389    }
390
391    /// This receiver is triggered periodically according to the configuration set by
392    /// [`set_temperature_callback_configuration`].
393    ///
394    /// The parameter is the same as [`get_temperature`].
395    pub fn get_temperature_callback_receiver(&self) -> ConvertingCallbackReceiver<i32> {
396        self.device.get_callback_receiver(u8::from(BarometerV2BrickletFunction::CallbackTemperature))
397    }
398
399    /// Returns the measured air pressure.
400    ///
401    ///
402    /// If you want to get the value periodically, it is recommended to use the
403    /// [`get_air_pressure_callback_receiver`] receiver. You can set the receiver configuration
404    /// with [`set_air_pressure_callback_configuration`].
405    pub fn get_air_pressure(&self) -> ConvertingReceiver<i32> {
406        let payload = vec![0; 0];
407
408        self.device.get(u8::from(BarometerV2BrickletFunction::GetAirPressure), payload)
409    }
410
411    /// The period is the period with which the [`get_air_pressure_callback_receiver`] receiver is triggered
412    /// periodically. A value of 0 turns the receiver off.
413    ///
414    /// If the `value has to change`-parameter is set to true, the receiver is only
415    /// triggered after the value has changed. If the value didn't change
416    /// within the period, the receiver is triggered immediately on change.
417    ///
418    /// If it is set to false, the receiver is continuously triggered with the period,
419    /// independent of the value.
420    ///
421    /// It is furthermore possible to constrain the receiver with thresholds.
422    ///
423    /// The `option`-parameter together with min/max sets a threshold for the [`get_air_pressure_callback_receiver`] receiver.
424    ///
425    /// The following options are possible:
426    ///
427    ///  Option| Description
428    ///  --- | ---
429    ///  'x'|    Threshold is turned off
430    ///  'o'|    Threshold is triggered when the value is *outside* the min and max values
431    ///  'i'|    Threshold is triggered when the value is *inside* or equal to the min and max values
432    ///  '<'|    Threshold is triggered when the value is smaller than the min value (max is ignored)
433    ///  '>'|    Threshold is triggered when the value is greater than the min value (max is ignored)
434    ///
435    /// If the option is set to 'x' (threshold turned off) the receiver is triggered with the fixed period.
436    ///
437    /// Associated constants:
438    /// * BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OFF
439    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
440    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
441    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
442    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_GREATER
443    pub fn set_air_pressure_callback_configuration(
444        &self,
445        period: u32,
446        value_has_to_change: bool,
447        option: char,
448        min: i32,
449        max: i32,
450    ) -> ConvertingReceiver<()> {
451        let mut payload = vec![0; 14];
452        payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
453        payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
454        payload[5..6].copy_from_slice(&<char>::to_le_byte_vec(option));
455        payload[6..10].copy_from_slice(&<i32>::to_le_byte_vec(min));
456        payload[10..14].copy_from_slice(&<i32>::to_le_byte_vec(max));
457
458        self.device.set(u8::from(BarometerV2BrickletFunction::SetAirPressureCallbackConfiguration), payload)
459    }
460
461    /// Returns the receiver configuration as set by [`set_air_pressure_callback_configuration`].
462    ///
463    /// Associated constants:
464    /// * BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OFF
465    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
466    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
467    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
468    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_GREATER
469    pub fn get_air_pressure_callback_configuration(&self) -> ConvertingReceiver<AirPressureCallbackConfiguration> {
470        let payload = vec![0; 0];
471
472        self.device.get(u8::from(BarometerV2BrickletFunction::GetAirPressureCallbackConfiguration), payload)
473    }
474
475    /// Returns the relative altitude of the air pressure sensor. The value
476    /// is calculated based on the difference between the
477    /// current air pressure and the reference air pressure that can be set
478    /// with [`set_reference_air_pressure`].
479    ///
480    ///
481    /// If you want to get the value periodically, it is recommended to use the
482    /// [`get_altitude_callback_receiver`] receiver. You can set the receiver configuration
483    /// with [`set_altitude_callback_configuration`].
484    pub fn get_altitude(&self) -> ConvertingReceiver<i32> {
485        let payload = vec![0; 0];
486
487        self.device.get(u8::from(BarometerV2BrickletFunction::GetAltitude), payload)
488    }
489
490    /// The period is the period with which the [`get_altitude_callback_receiver`] receiver is triggered
491    /// periodically. A value of 0 turns the receiver off.
492    ///
493    /// If the `value has to change`-parameter is set to true, the receiver is only
494    /// triggered after the value has changed. If the value didn't change
495    /// within the period, the receiver is triggered immediately on change.
496    ///
497    /// If it is set to false, the receiver is continuously triggered with the period,
498    /// independent of the value.
499    ///
500    /// It is furthermore possible to constrain the receiver with thresholds.
501    ///
502    /// The `option`-parameter together with min/max sets a threshold for the [`get_altitude_callback_receiver`] receiver.
503    ///
504    /// The following options are possible:
505    ///
506    ///  Option| Description
507    ///  --- | ---
508    ///  'x'|    Threshold is turned off
509    ///  'o'|    Threshold is triggered when the value is *outside* the min and max values
510    ///  'i'|    Threshold is triggered when the value is *inside* or equal to the min and max values
511    ///  '<'|    Threshold is triggered when the value is smaller than the min value (max is ignored)
512    ///  '>'|    Threshold is triggered when the value is greater than the min value (max is ignored)
513    ///
514    /// If the option is set to 'x' (threshold turned off) the receiver is triggered with the fixed period.
515    ///
516    /// Associated constants:
517    /// * BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OFF
518    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
519    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
520    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
521    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_GREATER
522    pub fn set_altitude_callback_configuration(
523        &self,
524        period: u32,
525        value_has_to_change: bool,
526        option: char,
527        min: i32,
528        max: i32,
529    ) -> ConvertingReceiver<()> {
530        let mut payload = vec![0; 14];
531        payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
532        payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
533        payload[5..6].copy_from_slice(&<char>::to_le_byte_vec(option));
534        payload[6..10].copy_from_slice(&<i32>::to_le_byte_vec(min));
535        payload[10..14].copy_from_slice(&<i32>::to_le_byte_vec(max));
536
537        self.device.set(u8::from(BarometerV2BrickletFunction::SetAltitudeCallbackConfiguration), payload)
538    }
539
540    /// Returns the receiver configuration as set by [`set_altitude_callback_configuration`].
541    ///
542    /// Associated constants:
543    /// * BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OFF
544    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
545    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
546    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
547    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_GREATER
548    pub fn get_altitude_callback_configuration(&self) -> ConvertingReceiver<AltitudeCallbackConfiguration> {
549        let payload = vec![0; 0];
550
551        self.device.get(u8::from(BarometerV2BrickletFunction::GetAltitudeCallbackConfiguration), payload)
552    }
553
554    /// Returns the temperature of the air pressure sensor.
555    ///
556    /// This temperature is used internally for temperature compensation
557    /// of the air pressure measurement. It is not as accurate as the
558    /// temperature measured by the `temperature_v2_bricklet` or the
559    /// `temperature_ir_v2_bricklet`.
560    ///
561    ///
562    /// If you want to get the value periodically, it is recommended to use the
563    /// [`get_temperature_callback_receiver`] receiver. You can set the receiver configuration
564    /// with [`set_temperature_callback_configuration`].
565    pub fn get_temperature(&self) -> ConvertingReceiver<i32> {
566        let payload = vec![0; 0];
567
568        self.device.get(u8::from(BarometerV2BrickletFunction::GetTemperature), payload)
569    }
570
571    /// The period is the period with which the [`get_temperature_callback_receiver`] receiver is triggered
572    /// periodically. A value of 0 turns the receiver off.
573    ///
574    /// If the `value has to change`-parameter is set to true, the receiver is only
575    /// triggered after the value has changed. If the value didn't change
576    /// within the period, the receiver is triggered immediately on change.
577    ///
578    /// If it is set to false, the receiver is continuously triggered with the period,
579    /// independent of the value.
580    ///
581    /// It is furthermore possible to constrain the receiver with thresholds.
582    ///
583    /// The `option`-parameter together with min/max sets a threshold for the [`get_temperature_callback_receiver`] receiver.
584    ///
585    /// The following options are possible:
586    ///
587    ///  Option| Description
588    ///  --- | ---
589    ///  'x'|    Threshold is turned off
590    ///  'o'|    Threshold is triggered when the value is *outside* the min and max values
591    ///  'i'|    Threshold is triggered when the value is *inside* or equal to the min and max values
592    ///  '<'|    Threshold is triggered when the value is smaller than the min value (max is ignored)
593    ///  '>'|    Threshold is triggered when the value is greater than the min value (max is ignored)
594    ///
595    /// If the option is set to 'x' (threshold turned off) the receiver is triggered with the fixed period.
596    ///
597    /// Associated constants:
598    /// * BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OFF
599    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
600    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
601    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
602    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_GREATER
603    pub fn set_temperature_callback_configuration(
604        &self,
605        period: u32,
606        value_has_to_change: bool,
607        option: char,
608        min: i32,
609        max: i32,
610    ) -> ConvertingReceiver<()> {
611        let mut payload = vec![0; 14];
612        payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
613        payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
614        payload[5..6].copy_from_slice(&<char>::to_le_byte_vec(option));
615        payload[6..10].copy_from_slice(&<i32>::to_le_byte_vec(min));
616        payload[10..14].copy_from_slice(&<i32>::to_le_byte_vec(max));
617
618        self.device.set(u8::from(BarometerV2BrickletFunction::SetTemperatureCallbackConfiguration), payload)
619    }
620
621    /// Returns the receiver configuration as set by [`set_temperature_callback_configuration`].
622    ///
623    /// Associated constants:
624    /// * BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OFF
625    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
626    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
627    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
628    ///	* BAROMETER_V2_BRICKLET_THRESHOLD_OPTION_GREATER
629    pub fn get_temperature_callback_configuration(&self) -> ConvertingReceiver<TemperatureCallbackConfiguration> {
630        let payload = vec![0; 0];
631
632        self.device.get(u8::from(BarometerV2BrickletFunction::GetTemperatureCallbackConfiguration), payload)
633    }
634
635    /// Sets the length of a [moving averaging](https://en.wikipedia.org/wiki/Moving_average)__
636    /// for the air pressure and temperature measurements.
637    ///
638    /// Setting the length to 1 will turn the averaging off. With less
639    /// averaging, there is more noise on the data.
640    ///
641    /// If you want to do long term measurements the longest moving average will give
642    /// the cleanest results.
643    pub fn set_moving_average_configuration(
644        &self,
645        moving_average_length_air_pressure: u16,
646        moving_average_length_temperature: u16,
647    ) -> ConvertingReceiver<()> {
648        let mut payload = vec![0; 4];
649        payload[0..2].copy_from_slice(&<u16>::to_le_byte_vec(moving_average_length_air_pressure));
650        payload[2..4].copy_from_slice(&<u16>::to_le_byte_vec(moving_average_length_temperature));
651
652        self.device.set(u8::from(BarometerV2BrickletFunction::SetMovingAverageConfiguration), payload)
653    }
654
655    /// Returns the moving average configuration as set by
656    /// [`set_moving_average_configuration`].
657    pub fn get_moving_average_configuration(&self) -> ConvertingReceiver<MovingAverageConfiguration> {
658        let payload = vec![0; 0];
659
660        self.device.get(u8::from(BarometerV2BrickletFunction::GetMovingAverageConfiguration), payload)
661    }
662
663    /// Sets the reference air pressure for the altitude calculation.
664    /// Setting the reference to the
665    /// current air pressure results in a calculated altitude of 0mm. Passing 0 is
666    /// a shortcut for passing the current air pressure as reference.
667    ///
668    /// Well known reference values are the Q codes
669    /// [QNH](https://en.wikipedia.org/wiki/QNH)__ and
670    /// [QFE](https://en.wikipedia.org/wiki/Mean_sea_level_pressure#Mean_sea_level_pressure)__
671    /// used in aviation.
672    pub fn set_reference_air_pressure(&self, air_pressure: i32) -> ConvertingReceiver<()> {
673        let mut payload = vec![0; 4];
674        payload[0..4].copy_from_slice(&<i32>::to_le_byte_vec(air_pressure));
675
676        self.device.set(u8::from(BarometerV2BrickletFunction::SetReferenceAirPressure), payload)
677    }
678
679    /// Returns the reference air pressure as set by [`set_reference_air_pressure`].
680    pub fn get_reference_air_pressure(&self) -> ConvertingReceiver<i32> {
681        let payload = vec![0; 0];
682
683        self.device.get(u8::from(BarometerV2BrickletFunction::GetReferenceAirPressure), payload)
684    }
685
686    /// Sets the one point calibration (OPC) values for the air pressure measurement.
687    ///
688    /// Before the Bricklet can be calibrated any previous calibration has to be removed
689    /// by setting ``measured air pressure`` and ``actual air pressure`` to 0.
690    ///
691    /// Then the current air pressure has to be measured using the Bricklet
692    /// (``measured air pressure``) and with an accurate reference barometer
693    /// (``actual air pressure``) at the same time and passed to this function.
694    ///
695    /// After proper calibration the air pressure measurement can achieve an accuracy
696    /// up to 0.2 hPa.
697    ///
698    /// The calibration is saved in the EEPROM of the Bricklet and only needs to be
699    /// configured once.
700    pub fn set_calibration(&self, measured_air_pressure: i32, actual_air_pressure: i32) -> ConvertingReceiver<()> {
701        let mut payload = vec![0; 8];
702        payload[0..4].copy_from_slice(&<i32>::to_le_byte_vec(measured_air_pressure));
703        payload[4..8].copy_from_slice(&<i32>::to_le_byte_vec(actual_air_pressure));
704
705        self.device.set(u8::from(BarometerV2BrickletFunction::SetCalibration), payload)
706    }
707
708    /// Returns the air pressure one point calibration values as set by
709    /// [`set_calibration`].
710    pub fn get_calibration(&self) -> ConvertingReceiver<Calibration> {
711        let payload = vec![0; 0];
712
713        self.device.get(u8::from(BarometerV2BrickletFunction::GetCalibration), payload)
714    }
715
716    /// Configures the data rate and air pressure low pass filter. The low pass filter
717    /// cut-off frequency (if enabled) can be set to 1/9th or 1/20th of the configure
718    /// data rate to decrease the noise on the air pressure data.
719    ///
720    /// The low pass filter configuration only applies to the air pressure measurement.
721    /// There is no low pass filter for the temperature measurement.
722    ///
723    /// A higher data rate will result in a less precise temperature because of
724    /// self-heating of the sensor. If the accuracy of the temperature reading is
725    /// important to you, we would recommend the 1Hz data rate.
726    ///
727    /// Associated constants:
728    /// * BAROMETER_V2_BRICKLET_DATA_RATE_OFF
729    ///	* BAROMETER_V2_BRICKLET_DATA_RATE_1HZ
730    ///	* BAROMETER_V2_BRICKLET_DATA_RATE_10HZ
731    ///	* BAROMETER_V2_BRICKLET_DATA_RATE_25HZ
732    ///	* BAROMETER_V2_BRICKLET_DATA_RATE_50HZ
733    ///	* BAROMETER_V2_BRICKLET_DATA_RATE_75HZ
734    ///	* BAROMETER_V2_BRICKLET_LOW_PASS_FILTER_OFF
735    ///	* BAROMETER_V2_BRICKLET_LOW_PASS_FILTER_1_9TH
736    ///	* BAROMETER_V2_BRICKLET_LOW_PASS_FILTER_1_20TH
737    pub fn set_sensor_configuration(&self, data_rate: u8, air_pressure_low_pass_filter: u8) -> ConvertingReceiver<()> {
738        let mut payload = vec![0; 2];
739        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(data_rate));
740        payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(air_pressure_low_pass_filter));
741
742        self.device.set(u8::from(BarometerV2BrickletFunction::SetSensorConfiguration), payload)
743    }
744
745    /// Returns the sensor configuration as set by [`set_sensor_configuration`].
746    ///
747    /// Associated constants:
748    /// * BAROMETER_V2_BRICKLET_DATA_RATE_OFF
749    ///	* BAROMETER_V2_BRICKLET_DATA_RATE_1HZ
750    ///	* BAROMETER_V2_BRICKLET_DATA_RATE_10HZ
751    ///	* BAROMETER_V2_BRICKLET_DATA_RATE_25HZ
752    ///	* BAROMETER_V2_BRICKLET_DATA_RATE_50HZ
753    ///	* BAROMETER_V2_BRICKLET_DATA_RATE_75HZ
754    ///	* BAROMETER_V2_BRICKLET_LOW_PASS_FILTER_OFF
755    ///	* BAROMETER_V2_BRICKLET_LOW_PASS_FILTER_1_9TH
756    ///	* BAROMETER_V2_BRICKLET_LOW_PASS_FILTER_1_20TH
757    pub fn get_sensor_configuration(&self) -> ConvertingReceiver<SensorConfiguration> {
758        let payload = vec![0; 0];
759
760        self.device.get(u8::from(BarometerV2BrickletFunction::GetSensorConfiguration), payload)
761    }
762
763    /// Returns the error count for the communication between Brick and Bricklet.
764    ///
765    /// The errors are divided into
766    ///
767    /// * ACK checksum errors,
768    /// * message checksum errors,
769    /// * framing errors and
770    /// * overflow errors.
771    ///
772    /// The errors counts are for errors that occur on the Bricklet side. All
773    /// Bricks have a similar function that returns the errors on the Brick side.
774    pub fn get_spitfp_error_count(&self) -> ConvertingReceiver<SpitfpErrorCount> {
775        let payload = vec![0; 0];
776
777        self.device.get(u8::from(BarometerV2BrickletFunction::GetSpitfpErrorCount), payload)
778    }
779
780    /// Sets the bootloader mode and returns the status after the requested
781    /// mode change was instigated.
782    ///
783    /// You can change from bootloader mode to firmware mode and vice versa. A change
784    /// from bootloader mode to firmware mode will only take place if the entry function,
785    /// device identifier and CRC are present and correct.
786    ///
787    /// This function is used by Brick Viewer during flashing. It should not be
788    /// necessary to call it in a normal user program.
789    ///
790    /// Associated constants:
791    /// * BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
792    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE
793    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
794    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
795    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
796    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_OK
797    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE
798    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE
799    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT
800    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT
801    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH
802    pub fn set_bootloader_mode(&self, mode: u8) -> ConvertingReceiver<u8> {
803        let mut payload = vec![0; 1];
804        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(mode));
805
806        self.device.get(u8::from(BarometerV2BrickletFunction::SetBootloaderMode), payload)
807    }
808
809    /// Returns the current bootloader mode, see [`set_bootloader_mode`].
810    ///
811    /// Associated constants:
812    /// * BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
813    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE
814    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
815    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
816    ///	* BAROMETER_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
817    pub fn get_bootloader_mode(&self) -> ConvertingReceiver<u8> {
818        let payload = vec![0; 0];
819
820        self.device.get(u8::from(BarometerV2BrickletFunction::GetBootloaderMode), payload)
821    }
822
823    /// Sets the firmware pointer for [`write_firmware`]. The pointer has
824    /// to be increased by chunks of size 64. The data is written to flash
825    /// every 4 chunks (which equals to one page of size 256).
826    ///
827    /// This function is used by Brick Viewer during flashing. It should not be
828    /// necessary to call it in a normal user program.
829    pub fn set_write_firmware_pointer(&self, pointer: u32) -> ConvertingReceiver<()> {
830        let mut payload = vec![0; 4];
831        payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(pointer));
832
833        self.device.set(u8::from(BarometerV2BrickletFunction::SetWriteFirmwarePointer), payload)
834    }
835
836    /// Writes 64 Bytes of firmware at the position as written by
837    /// [`set_write_firmware_pointer`] before. The firmware is written
838    /// to flash every 4 chunks.
839    ///
840    /// You can only write firmware in bootloader mode.
841    ///
842    /// This function is used by Brick Viewer during flashing. It should not be
843    /// necessary to call it in a normal user program.
844    pub fn write_firmware(&self, data: [u8; 64]) -> ConvertingReceiver<u8> {
845        let mut payload = vec![0; 64];
846        payload[0..64].copy_from_slice(&<[u8; 64]>::to_le_byte_vec(data));
847
848        self.device.get(u8::from(BarometerV2BrickletFunction::WriteFirmware), payload)
849    }
850
851    /// Sets the status LED configuration. By default the LED shows
852    /// communication traffic between Brick and Bricklet, it flickers once
853    /// for every 10 received data packets.
854    ///
855    /// You can also turn the LED permanently on/off or show a heartbeat.
856    ///
857    /// If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
858    ///
859    /// Associated constants:
860    /// * BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_OFF
861    ///	* BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_ON
862    ///	* BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
863    ///	* BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
864    pub fn set_status_led_config(&self, config: u8) -> ConvertingReceiver<()> {
865        let mut payload = vec![0; 1];
866        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(config));
867
868        self.device.set(u8::from(BarometerV2BrickletFunction::SetStatusLedConfig), payload)
869    }
870
871    /// Returns the configuration as set by [`set_status_led_config`]
872    ///
873    /// Associated constants:
874    /// * BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_OFF
875    ///	* BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_ON
876    ///	* BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
877    ///	* BAROMETER_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
878    pub fn get_status_led_config(&self) -> ConvertingReceiver<u8> {
879        let payload = vec![0; 0];
880
881        self.device.get(u8::from(BarometerV2BrickletFunction::GetStatusLedConfig), payload)
882    }
883
884    /// Returns the temperature as measured inside the microcontroller. The
885    /// value returned is not the ambient temperature!
886    ///
887    /// The temperature is only proportional to the real temperature and it has bad
888    /// accuracy. Practically it is only useful as an indicator for
889    /// temperature changes.
890    pub fn get_chip_temperature(&self) -> ConvertingReceiver<i16> {
891        let payload = vec![0; 0];
892
893        self.device.get(u8::from(BarometerV2BrickletFunction::GetChipTemperature), payload)
894    }
895
896    /// Calling this function will reset the Bricklet. All configurations
897    /// will be lost.
898    ///
899    /// After a reset you have to create new device objects,
900    /// calling functions on the existing ones will result in
901    /// undefined behavior!
902    pub fn reset(&self) -> ConvertingReceiver<()> {
903        let payload = vec![0; 0];
904
905        self.device.set(u8::from(BarometerV2BrickletFunction::Reset), payload)
906    }
907
908    /// Writes a new UID into flash. If you want to set a new UID
909    /// you have to decode the Base58 encoded UID string into an
910    /// integer first.
911    ///
912    /// We recommend that you use Brick Viewer to change the UID.
913    pub fn write_uid(&self, uid: u32) -> ConvertingReceiver<()> {
914        let mut payload = vec![0; 4];
915        payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(uid));
916
917        self.device.set(u8::from(BarometerV2BrickletFunction::WriteUid), payload)
918    }
919
920    /// Returns the current UID as an integer. Encode as
921    /// Base58 to get the usual string version.
922    pub fn read_uid(&self) -> ConvertingReceiver<u32> {
923        let payload = vec![0; 0];
924
925        self.device.get(u8::from(BarometerV2BrickletFunction::ReadUid), payload)
926    }
927
928    /// Returns the UID, the UID where the Bricklet is connected to,
929    /// the position, the hardware and firmware version as well as the
930    /// device identifier.
931    ///
932    /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
933    /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
934    /// position 'z'.
935    ///
936    /// The device identifier numbers can be found [here](device_identifier).
937    /// |device_identifier_constant|
938    pub fn get_identity(&self) -> ConvertingReceiver<Identity> {
939        let payload = vec![0; 0];
940
941        self.device.get(u8::from(BarometerV2BrickletFunction::GetIdentity), payload)
942    }
943}