tinkerforge/bindings/
accelerometer_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 acceleration in three axis.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/Accelerometer_Bricklet_Rust.html).
14use crate::{
15    byte_converter::*, converting_callback_receiver::ConvertingCallbackReceiver, converting_receiver::ConvertingReceiver, device::*,
16    ip_connection::GetRequestSender,
17};
18pub enum AccelerometerBrickletFunction {
19    GetAcceleration,
20    SetAccelerationCallbackPeriod,
21    GetAccelerationCallbackPeriod,
22    SetAccelerationCallbackThreshold,
23    GetAccelerationCallbackThreshold,
24    SetDebouncePeriod,
25    GetDebouncePeriod,
26    GetTemperature,
27    SetConfiguration,
28    GetConfiguration,
29    LedOn,
30    LedOff,
31    IsLedOn,
32    GetIdentity,
33    CallbackAcceleration,
34    CallbackAccelerationReached,
35}
36impl From<AccelerometerBrickletFunction> for u8 {
37    fn from(fun: AccelerometerBrickletFunction) -> Self {
38        match fun {
39            AccelerometerBrickletFunction::GetAcceleration => 1,
40            AccelerometerBrickletFunction::SetAccelerationCallbackPeriod => 2,
41            AccelerometerBrickletFunction::GetAccelerationCallbackPeriod => 3,
42            AccelerometerBrickletFunction::SetAccelerationCallbackThreshold => 4,
43            AccelerometerBrickletFunction::GetAccelerationCallbackThreshold => 5,
44            AccelerometerBrickletFunction::SetDebouncePeriod => 6,
45            AccelerometerBrickletFunction::GetDebouncePeriod => 7,
46            AccelerometerBrickletFunction::GetTemperature => 8,
47            AccelerometerBrickletFunction::SetConfiguration => 9,
48            AccelerometerBrickletFunction::GetConfiguration => 10,
49            AccelerometerBrickletFunction::LedOn => 11,
50            AccelerometerBrickletFunction::LedOff => 12,
51            AccelerometerBrickletFunction::IsLedOn => 13,
52            AccelerometerBrickletFunction::GetIdentity => 255,
53            AccelerometerBrickletFunction::CallbackAcceleration => 14,
54            AccelerometerBrickletFunction::CallbackAccelerationReached => 15,
55        }
56    }
57}
58pub const ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
59pub const ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
60pub const ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
61pub const ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
62pub const ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
63pub const ACCELEROMETER_BRICKLET_DATA_RATE_OFF: u8 = 0;
64pub const ACCELEROMETER_BRICKLET_DATA_RATE_3HZ: u8 = 1;
65pub const ACCELEROMETER_BRICKLET_DATA_RATE_6HZ: u8 = 2;
66pub const ACCELEROMETER_BRICKLET_DATA_RATE_12HZ: u8 = 3;
67pub const ACCELEROMETER_BRICKLET_DATA_RATE_25HZ: u8 = 4;
68pub const ACCELEROMETER_BRICKLET_DATA_RATE_50HZ: u8 = 5;
69pub const ACCELEROMETER_BRICKLET_DATA_RATE_100HZ: u8 = 6;
70pub const ACCELEROMETER_BRICKLET_DATA_RATE_400HZ: u8 = 7;
71pub const ACCELEROMETER_BRICKLET_DATA_RATE_800HZ: u8 = 8;
72pub const ACCELEROMETER_BRICKLET_DATA_RATE_1600HZ: u8 = 9;
73pub const ACCELEROMETER_BRICKLET_FULL_SCALE_2G: u8 = 0;
74pub const ACCELEROMETER_BRICKLET_FULL_SCALE_4G: u8 = 1;
75pub const ACCELEROMETER_BRICKLET_FULL_SCALE_6G: u8 = 2;
76pub const ACCELEROMETER_BRICKLET_FULL_SCALE_8G: u8 = 3;
77pub const ACCELEROMETER_BRICKLET_FULL_SCALE_16G: u8 = 4;
78pub const ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_800HZ: u8 = 0;
79pub const ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_400HZ: u8 = 1;
80pub const ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_200HZ: u8 = 2;
81pub const ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_50HZ: u8 = 3;
82
83#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
84pub struct Acceleration {
85    pub x: i16,
86    pub y: i16,
87    pub z: i16,
88}
89impl FromByteSlice for Acceleration {
90    fn bytes_expected() -> usize { 6 }
91    fn from_le_byte_slice(bytes: &[u8]) -> Acceleration {
92        Acceleration {
93            x: <i16>::from_le_byte_slice(&bytes[0..2]),
94            y: <i16>::from_le_byte_slice(&bytes[2..4]),
95            z: <i16>::from_le_byte_slice(&bytes[4..6]),
96        }
97    }
98}
99
100#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
101pub struct AccelerationCallbackThreshold {
102    pub option: char,
103    pub min_x: i16,
104    pub max_x: i16,
105    pub min_y: i16,
106    pub max_y: i16,
107    pub min_z: i16,
108    pub max_z: i16,
109}
110impl FromByteSlice for AccelerationCallbackThreshold {
111    fn bytes_expected() -> usize { 13 }
112    fn from_le_byte_slice(bytes: &[u8]) -> AccelerationCallbackThreshold {
113        AccelerationCallbackThreshold {
114            option: <char>::from_le_byte_slice(&bytes[0..1]),
115            min_x: <i16>::from_le_byte_slice(&bytes[1..3]),
116            max_x: <i16>::from_le_byte_slice(&bytes[3..5]),
117            min_y: <i16>::from_le_byte_slice(&bytes[5..7]),
118            max_y: <i16>::from_le_byte_slice(&bytes[7..9]),
119            min_z: <i16>::from_le_byte_slice(&bytes[9..11]),
120            max_z: <i16>::from_le_byte_slice(&bytes[11..13]),
121        }
122    }
123}
124
125#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
126pub struct Configuration {
127    pub data_rate: u8,
128    pub full_scale: u8,
129    pub filter_bandwidth: u8,
130}
131impl FromByteSlice for Configuration {
132    fn bytes_expected() -> usize { 3 }
133    fn from_le_byte_slice(bytes: &[u8]) -> Configuration {
134        Configuration {
135            data_rate: <u8>::from_le_byte_slice(&bytes[0..1]),
136            full_scale: <u8>::from_le_byte_slice(&bytes[1..2]),
137            filter_bandwidth: <u8>::from_le_byte_slice(&bytes[2..3]),
138        }
139    }
140}
141
142#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
143pub struct AccelerationEvent {
144    pub x: i16,
145    pub y: i16,
146    pub z: i16,
147}
148impl FromByteSlice for AccelerationEvent {
149    fn bytes_expected() -> usize { 6 }
150    fn from_le_byte_slice(bytes: &[u8]) -> AccelerationEvent {
151        AccelerationEvent {
152            x: <i16>::from_le_byte_slice(&bytes[0..2]),
153            y: <i16>::from_le_byte_slice(&bytes[2..4]),
154            z: <i16>::from_le_byte_slice(&bytes[4..6]),
155        }
156    }
157}
158
159#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
160pub struct AccelerationReachedEvent {
161    pub x: i16,
162    pub y: i16,
163    pub z: i16,
164}
165impl FromByteSlice for AccelerationReachedEvent {
166    fn bytes_expected() -> usize { 6 }
167    fn from_le_byte_slice(bytes: &[u8]) -> AccelerationReachedEvent {
168        AccelerationReachedEvent {
169            x: <i16>::from_le_byte_slice(&bytes[0..2]),
170            y: <i16>::from_le_byte_slice(&bytes[2..4]),
171            z: <i16>::from_le_byte_slice(&bytes[4..6]),
172        }
173    }
174}
175
176#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
177pub struct Identity {
178    pub uid: String,
179    pub connected_uid: String,
180    pub position: char,
181    pub hardware_version: [u8; 3],
182    pub firmware_version: [u8; 3],
183    pub device_identifier: u16,
184}
185impl FromByteSlice for Identity {
186    fn bytes_expected() -> usize { 25 }
187    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
188        Identity {
189            uid: <String>::from_le_byte_slice(&bytes[0..8]),
190            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
191            position: <char>::from_le_byte_slice(&bytes[16..17]),
192            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
193            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
194            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
195        }
196    }
197}
198
199/// Measures acceleration in three axis
200#[derive(Clone)]
201pub struct AccelerometerBricklet {
202    device: Device,
203}
204impl AccelerometerBricklet {
205    pub const DEVICE_IDENTIFIER: u16 = 250;
206    pub const DEVICE_DISPLAY_NAME: &'static str = "Accelerometer Bricklet";
207    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
208    pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> AccelerometerBricklet {
209        let mut result = AccelerometerBricklet { device: Device::new([2, 0, 1], uid, req_sender, 0) };
210        result.device.response_expected[u8::from(AccelerometerBrickletFunction::GetAcceleration) as usize] =
211            ResponseExpectedFlag::AlwaysTrue;
212        result.device.response_expected[u8::from(AccelerometerBrickletFunction::SetAccelerationCallbackPeriod) as usize] =
213            ResponseExpectedFlag::True;
214        result.device.response_expected[u8::from(AccelerometerBrickletFunction::GetAccelerationCallbackPeriod) as usize] =
215            ResponseExpectedFlag::AlwaysTrue;
216        result.device.response_expected[u8::from(AccelerometerBrickletFunction::SetAccelerationCallbackThreshold) as usize] =
217            ResponseExpectedFlag::True;
218        result.device.response_expected[u8::from(AccelerometerBrickletFunction::GetAccelerationCallbackThreshold) as usize] =
219            ResponseExpectedFlag::AlwaysTrue;
220        result.device.response_expected[u8::from(AccelerometerBrickletFunction::SetDebouncePeriod) as usize] = ResponseExpectedFlag::True;
221        result.device.response_expected[u8::from(AccelerometerBrickletFunction::GetDebouncePeriod) as usize] =
222            ResponseExpectedFlag::AlwaysTrue;
223        result.device.response_expected[u8::from(AccelerometerBrickletFunction::GetTemperature) as usize] =
224            ResponseExpectedFlag::AlwaysTrue;
225        result.device.response_expected[u8::from(AccelerometerBrickletFunction::SetConfiguration) as usize] = ResponseExpectedFlag::False;
226        result.device.response_expected[u8::from(AccelerometerBrickletFunction::GetConfiguration) as usize] =
227            ResponseExpectedFlag::AlwaysTrue;
228        result.device.response_expected[u8::from(AccelerometerBrickletFunction::LedOn) as usize] = ResponseExpectedFlag::False;
229        result.device.response_expected[u8::from(AccelerometerBrickletFunction::LedOff) as usize] = ResponseExpectedFlag::False;
230        result.device.response_expected[u8::from(AccelerometerBrickletFunction::IsLedOn) as usize] = ResponseExpectedFlag::AlwaysTrue;
231        result.device.response_expected[u8::from(AccelerometerBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
232        result
233    }
234
235    /// Returns the response expected flag for the function specified by the function ID parameter.
236    /// It is true if the function is expected to send a response, false otherwise.
237    ///
238    /// For getter functions this is enabled by default and cannot be disabled, because those
239    /// functions will always send a response. For callback configuration functions it is enabled
240    /// by default too, but can be disabled by [`set_response_expected`](crate::accelerometer_bricklet::AccelerometerBricklet::set_response_expected).
241    /// For setter functions it is disabled by default and can be enabled.
242    ///
243    /// Enabling the response expected flag for a setter function allows to detect timeouts
244    /// and other error conditions calls of this setter as well. The device will then send a response
245    /// for this purpose. If this flag is disabled for a setter function then no response is sent
246    /// and errors are silently ignored, because they cannot be detected.
247    ///
248    /// See [`set_response_expected`](crate::accelerometer_bricklet::AccelerometerBricklet::set_response_expected) for the list of function ID constants available for this function.
249    pub fn get_response_expected(&mut self, fun: AccelerometerBrickletFunction) -> Result<bool, GetResponseExpectedError> {
250        self.device.get_response_expected(u8::from(fun))
251    }
252
253    /// Changes the response expected flag of the function specified by the function ID parameter.
254    /// This flag can only be changed for setter (default value: false) and callback configuration
255    /// functions (default value: true). For getter functions it is always enabled.
256    ///
257    /// Enabling the response expected flag for a setter function allows to detect timeouts and
258    /// other error conditions calls of this setter as well. The device will then send a response
259    /// for this purpose. If this flag is disabled for a setter function then no response is sent
260    /// and errors are silently ignored, because they cannot be detected.
261    pub fn set_response_expected(
262        &mut self,
263        fun: AccelerometerBrickletFunction,
264        response_expected: bool,
265    ) -> Result<(), SetResponseExpectedError> {
266        self.device.set_response_expected(u8::from(fun), response_expected)
267    }
268
269    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
270    pub fn set_response_expected_all(&mut self, response_expected: bool) { self.device.set_response_expected_all(response_expected) }
271
272    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
273    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
274    pub fn get_api_version(&self) -> [u8; 3] { self.device.api_version }
275
276    /// This receiver is triggered periodically with the period that is set by
277    /// [`set_acceleration_callback_period`]. The parameters are the
278    /// X, Y and Z acceleration. The range is
279    /// configured with [`set_configuration`].
280    ///
281    /// The [`get_acceleration_callback_receiver`] receiver is only triggered if the acceleration has
282    /// changed since the last triggering.
283    ///
284    /// [`set_acceleration_callback_period`]: #method.set_acceleration_callback_period
285    /// [`set_configuration`]: #method.set_configuration
286    /// [`get_acceleration_callback_receiver`]: #method.get_acceleration_callback_receiver
287    pub fn get_acceleration_callback_receiver(&self) -> ConvertingCallbackReceiver<AccelerationEvent> {
288        self.device.get_callback_receiver(u8::from(AccelerometerBrickletFunction::CallbackAcceleration))
289    }
290
291    /// This receiver is triggered when the threshold as set by
292    /// [`set_acceleration_callback_threshold`] is reached.
293    /// The parameters are the X, Y and Z acceleration. The range is
294    /// configured with [`set_configuration`].
295    ///
296    /// If the threshold keeps being reached, the receiver is triggered periodically
297    /// with the period as set by [`set_debounce_period`].
298    pub fn get_acceleration_reached_callback_receiver(&self) -> ConvertingCallbackReceiver<AccelerationReachedEvent> {
299        self.device.get_callback_receiver(u8::from(AccelerometerBrickletFunction::CallbackAccelerationReached))
300    }
301
302    /// Returns the acceleration in x, y and z direction. The values
303    /// are given in gₙ/1000 (1gₙ = 9.80665m/s²). The range is
304    /// configured with [`set_configuration`].
305    ///
306    /// If you want to get the acceleration periodically, it is recommended
307    /// to use the [`get_acceleration_callback_receiver`] receiver and set the period with
308    /// [`set_acceleration_callback_period`].
309    pub fn get_acceleration(&self) -> ConvertingReceiver<Acceleration> {
310        let payload = vec![0; 0];
311
312        self.device.get(u8::from(AccelerometerBrickletFunction::GetAcceleration), payload)
313    }
314
315    /// Sets the period with which the [`get_acceleration_callback_receiver`] receiver is triggered
316    /// periodically. A value of 0 turns the receiver off.
317    ///
318    /// The [`get_acceleration_callback_receiver`] receiver is only triggered if the acceleration has
319    /// changed since the last triggering.
320    pub fn set_acceleration_callback_period(&self, period: u32) -> ConvertingReceiver<()> {
321        let mut payload = vec![0; 4];
322        payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
323
324        self.device.set(u8::from(AccelerometerBrickletFunction::SetAccelerationCallbackPeriod), payload)
325    }
326
327    /// Returns the period as set by [`set_acceleration_callback_period`].
328    pub fn get_acceleration_callback_period(&self) -> ConvertingReceiver<u32> {
329        let payload = vec![0; 0];
330
331        self.device.get(u8::from(AccelerometerBrickletFunction::GetAccelerationCallbackPeriod), payload)
332    }
333
334    /// Sets the thresholds for the [`get_acceleration_reached_callback_receiver`] receiver.
335    ///
336    /// The following options are possible:
337    ///
338    ///  Option| Description
339    ///  --- | ---
340    ///  'x'|    Receiver is turned off
341    ///  'o'|    Receiver is triggered when the acceleration is *outside* the min and max values
342    ///  'i'|    Receiver is triggered when the acceleration is *inside* the min and max values
343    ///  '<'|    Receiver is triggered when the acceleration is smaller than the min value (max is ignored)
344    ///  '>'|    Receiver is triggered when the acceleration is greater than the min value (max is ignored)
345    ///
346    /// Associated constants:
347    /// * ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_OFF
348    ///	* ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_OUTSIDE
349    ///	* ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_INSIDE
350    ///	* ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_SMALLER
351    ///	* ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_GREATER
352    pub fn set_acceleration_callback_threshold(
353        &self,
354        option: char,
355        min_x: i16,
356        max_x: i16,
357        min_y: i16,
358        max_y: i16,
359        min_z: i16,
360        max_z: i16,
361    ) -> ConvertingReceiver<()> {
362        let mut payload = vec![0; 13];
363        payload[0..1].copy_from_slice(&<char>::to_le_byte_vec(option));
364        payload[1..3].copy_from_slice(&<i16>::to_le_byte_vec(min_x));
365        payload[3..5].copy_from_slice(&<i16>::to_le_byte_vec(max_x));
366        payload[5..7].copy_from_slice(&<i16>::to_le_byte_vec(min_y));
367        payload[7..9].copy_from_slice(&<i16>::to_le_byte_vec(max_y));
368        payload[9..11].copy_from_slice(&<i16>::to_le_byte_vec(min_z));
369        payload[11..13].copy_from_slice(&<i16>::to_le_byte_vec(max_z));
370
371        self.device.set(u8::from(AccelerometerBrickletFunction::SetAccelerationCallbackThreshold), payload)
372    }
373
374    /// Returns the threshold as set by [`set_acceleration_callback_threshold`].
375    ///
376    /// Associated constants:
377    /// * ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_OFF
378    ///	* ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_OUTSIDE
379    ///	* ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_INSIDE
380    ///	* ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_SMALLER
381    ///	* ACCELEROMETER_BRICKLET_THRESHOLD_OPTION_GREATER
382    pub fn get_acceleration_callback_threshold(&self) -> ConvertingReceiver<AccelerationCallbackThreshold> {
383        let payload = vec![0; 0];
384
385        self.device.get(u8::from(AccelerometerBrickletFunction::GetAccelerationCallbackThreshold), payload)
386    }
387
388    /// Sets the period with which the threshold receiver
389    ///
390    /// * [`get_acceleration_reached_callback_receiver`]
391    ///
392    /// is triggered, if the threshold
393    ///
394    /// * [`set_acceleration_callback_threshold`]
395    ///
396    /// keeps being reached.
397    pub fn set_debounce_period(&self, debounce: u32) -> ConvertingReceiver<()> {
398        let mut payload = vec![0; 4];
399        payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(debounce));
400
401        self.device.set(u8::from(AccelerometerBrickletFunction::SetDebouncePeriod), payload)
402    }
403
404    /// Returns the debounce period as set by [`set_debounce_period`].
405    pub fn get_debounce_period(&self) -> ConvertingReceiver<u32> {
406        let payload = vec![0; 0];
407
408        self.device.get(u8::from(AccelerometerBrickletFunction::GetDebouncePeriod), payload)
409    }
410
411    /// Returns the temperature of the accelerometer.
412    pub fn get_temperature(&self) -> ConvertingReceiver<i16> {
413        let payload = vec![0; 0];
414
415        self.device.get(u8::from(AccelerometerBrickletFunction::GetTemperature), payload)
416    }
417
418    /// Configures the data rate, full scale range and filter bandwidth.
419    /// Possible values are:
420    ///
421    /// * Data rate of 0Hz to 1600Hz.
422    /// * Full scale range of ±2gₙ up to ±16gₙ.
423    /// * Filter bandwidth between 50Hz and 800Hz.
424    ///
425    /// Decreasing data rate or full scale range will also decrease the noise on
426    /// the data.
427    ///
428    /// Associated constants:
429    /// * ACCELEROMETER_BRICKLET_DATA_RATE_OFF
430    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_3HZ
431    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_6HZ
432    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_12HZ
433    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_25HZ
434    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_50HZ
435    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_100HZ
436    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_400HZ
437    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_800HZ
438    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_1600HZ
439    ///	* ACCELEROMETER_BRICKLET_FULL_SCALE_2G
440    ///	* ACCELEROMETER_BRICKLET_FULL_SCALE_4G
441    ///	* ACCELEROMETER_BRICKLET_FULL_SCALE_6G
442    ///	* ACCELEROMETER_BRICKLET_FULL_SCALE_8G
443    ///	* ACCELEROMETER_BRICKLET_FULL_SCALE_16G
444    ///	* ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_800HZ
445    ///	* ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_400HZ
446    ///	* ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_200HZ
447    ///	* ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_50HZ
448    pub fn set_configuration(&self, data_rate: u8, full_scale: u8, filter_bandwidth: u8) -> ConvertingReceiver<()> {
449        let mut payload = vec![0; 3];
450        payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(data_rate));
451        payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(full_scale));
452        payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(filter_bandwidth));
453
454        self.device.set(u8::from(AccelerometerBrickletFunction::SetConfiguration), payload)
455    }
456
457    /// Returns the configuration as set by [`set_configuration`].
458    ///
459    /// Associated constants:
460    /// * ACCELEROMETER_BRICKLET_DATA_RATE_OFF
461    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_3HZ
462    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_6HZ
463    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_12HZ
464    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_25HZ
465    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_50HZ
466    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_100HZ
467    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_400HZ
468    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_800HZ
469    ///	* ACCELEROMETER_BRICKLET_DATA_RATE_1600HZ
470    ///	* ACCELEROMETER_BRICKLET_FULL_SCALE_2G
471    ///	* ACCELEROMETER_BRICKLET_FULL_SCALE_4G
472    ///	* ACCELEROMETER_BRICKLET_FULL_SCALE_6G
473    ///	* ACCELEROMETER_BRICKLET_FULL_SCALE_8G
474    ///	* ACCELEROMETER_BRICKLET_FULL_SCALE_16G
475    ///	* ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_800HZ
476    ///	* ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_400HZ
477    ///	* ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_200HZ
478    ///	* ACCELEROMETER_BRICKLET_FILTER_BANDWIDTH_50HZ
479    pub fn get_configuration(&self) -> ConvertingReceiver<Configuration> {
480        let payload = vec![0; 0];
481
482        self.device.get(u8::from(AccelerometerBrickletFunction::GetConfiguration), payload)
483    }
484
485    /// Enables the LED on the Bricklet.
486    pub fn led_on(&self) -> ConvertingReceiver<()> {
487        let payload = vec![0; 0];
488
489        self.device.set(u8::from(AccelerometerBrickletFunction::LedOn), payload)
490    }
491
492    /// Disables the LED on the Bricklet.
493    pub fn led_off(&self) -> ConvertingReceiver<()> {
494        let payload = vec![0; 0];
495
496        self.device.set(u8::from(AccelerometerBrickletFunction::LedOff), payload)
497    }
498
499    /// Returns *true* if the LED is enabled, *false* otherwise.
500    pub fn is_led_on(&self) -> ConvertingReceiver<bool> {
501        let payload = vec![0; 0];
502
503        self.device.get(u8::from(AccelerometerBrickletFunction::IsLedOn), payload)
504    }
505
506    /// Returns the UID, the UID where the Bricklet is connected to,
507    /// the position, the hardware and firmware version as well as the
508    /// device identifier.
509    ///
510    /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
511    /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
512    /// position 'z'.
513    ///
514    /// The device identifier numbers can be found [here](device_identifier).
515    /// |device_identifier_constant|
516    pub fn get_identity(&self) -> ConvertingReceiver<Identity> {
517        let payload = vec![0; 0];
518
519        self.device.get(u8::from(AccelerometerBrickletFunction::GetIdentity), payload)
520    }
521}