tinkerforge_async/bindings/ambient_light_v2_bricklet.rs
1/* ***********************************************************
2 * This file was automatically generated on 2024-02-16. *
3 * *
4 * Rust Bindings Version 2.0.20 *
5 * *
6 * If you have a bugfix for this file and want to commit it, *
7 * please fix the bug in the generator. You can find a link *
8 * to the generators git repository on tinkerforge.com *
9 *************************************************************/
10
11//! Measures ambient light up to 64000lux.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/AmbientLightV2_Bricklet_Rust.html).
14#[allow(unused_imports)]
15use crate::{
16 base58::Uid, byte_converter::*, device::*, error::TinkerforgeError, ip_connection::async_io::AsyncIpConnection,
17 low_level_traits::LowLevelRead,
18};
19#[allow(unused_imports)]
20use futures_core::Stream;
21#[allow(unused_imports)]
22use tokio_stream::StreamExt;
23pub enum AmbientLightV2BrickletFunction {
24 GetIlluminance,
25 SetIlluminanceCallbackPeriod,
26 GetIlluminanceCallbackPeriod,
27 SetIlluminanceCallbackThreshold,
28 GetIlluminanceCallbackThreshold,
29 SetDebouncePeriod,
30 GetDebouncePeriod,
31 SetConfiguration,
32 GetConfiguration,
33 GetIdentity,
34 CallbackIlluminance,
35 CallbackIlluminanceReached,
36}
37impl From<AmbientLightV2BrickletFunction> for u8 {
38 fn from(fun: AmbientLightV2BrickletFunction) -> Self {
39 match fun {
40 AmbientLightV2BrickletFunction::GetIlluminance => 1,
41 AmbientLightV2BrickletFunction::SetIlluminanceCallbackPeriod => 2,
42 AmbientLightV2BrickletFunction::GetIlluminanceCallbackPeriod => 3,
43 AmbientLightV2BrickletFunction::SetIlluminanceCallbackThreshold => 4,
44 AmbientLightV2BrickletFunction::GetIlluminanceCallbackThreshold => 5,
45 AmbientLightV2BrickletFunction::SetDebouncePeriod => 6,
46 AmbientLightV2BrickletFunction::GetDebouncePeriod => 7,
47 AmbientLightV2BrickletFunction::SetConfiguration => 8,
48 AmbientLightV2BrickletFunction::GetConfiguration => 9,
49 AmbientLightV2BrickletFunction::GetIdentity => 255,
50 AmbientLightV2BrickletFunction::CallbackIlluminance => 10,
51 AmbientLightV2BrickletFunction::CallbackIlluminanceReached => 11,
52 }
53 }
54}
55pub const AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
56pub const AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
57pub const AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
58pub const AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
59pub const AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
60pub const AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_UNLIMITED: u8 = 6;
61pub const AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_64000LUX: u8 = 0;
62pub const AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_32000LUX: u8 = 1;
63pub const AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_16000LUX: u8 = 2;
64pub const AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_8000LUX: u8 = 3;
65pub const AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_1300LUX: u8 = 4;
66pub const AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_600LUX: u8 = 5;
67pub const AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_50MS: u8 = 0;
68pub const AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_100MS: u8 = 1;
69pub const AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_150MS: u8 = 2;
70pub const AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_200MS: u8 = 3;
71pub const AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_250MS: u8 = 4;
72pub const AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_300MS: u8 = 5;
73pub const AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_350MS: u8 = 6;
74pub const AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_400MS: u8 = 7;
75
76#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
77pub struct IlluminanceCallbackThreshold {
78 pub option: char,
79 pub min: u32,
80 pub max: u32,
81}
82impl FromByteSlice for IlluminanceCallbackThreshold {
83 fn bytes_expected() -> usize {
84 9
85 }
86 fn from_le_byte_slice(bytes: &[u8]) -> IlluminanceCallbackThreshold {
87 IlluminanceCallbackThreshold {
88 option: <char>::from_le_byte_slice(&bytes[0..1]),
89 min: <u32>::from_le_byte_slice(&bytes[1..5]),
90 max: <u32>::from_le_byte_slice(&bytes[5..9]),
91 }
92 }
93}
94
95#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
96pub struct Configuration {
97 pub illuminance_range: u8,
98 pub integration_time: u8,
99}
100impl FromByteSlice for Configuration {
101 fn bytes_expected() -> usize {
102 2
103 }
104 fn from_le_byte_slice(bytes: &[u8]) -> Configuration {
105 Configuration {
106 illuminance_range: <u8>::from_le_byte_slice(&bytes[0..1]),
107 integration_time: <u8>::from_le_byte_slice(&bytes[1..2]),
108 }
109 }
110}
111
112#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
113pub struct Identity {
114 pub uid: String,
115 pub connected_uid: String,
116 pub position: char,
117 pub hardware_version: [u8; 3],
118 pub firmware_version: [u8; 3],
119 pub device_identifier: u16,
120}
121impl FromByteSlice for Identity {
122 fn bytes_expected() -> usize {
123 25
124 }
125 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
126 Identity {
127 uid: <String>::from_le_byte_slice(&bytes[0..8]),
128 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
129 position: <char>::from_le_byte_slice(&bytes[16..17]),
130 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
131 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
132 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
133 }
134 }
135}
136
137/// Measures ambient light up to 64000lux
138#[derive(Clone)]
139pub struct AmbientLightV2Bricklet {
140 device: Device,
141}
142impl AmbientLightV2Bricklet {
143 pub const DEVICE_IDENTIFIER: u16 = 259;
144 pub const DEVICE_DISPLAY_NAME: &'static str = "Ambient Light Bricklet 2.0";
145 /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
146 pub fn new(uid: Uid, connection: AsyncIpConnection) -> AmbientLightV2Bricklet {
147 let mut result = AmbientLightV2Bricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
148 result.device.response_expected[u8::from(AmbientLightV2BrickletFunction::GetIlluminance) as usize] =
149 ResponseExpectedFlag::AlwaysTrue;
150 result.device.response_expected[u8::from(AmbientLightV2BrickletFunction::SetIlluminanceCallbackPeriod) as usize] =
151 ResponseExpectedFlag::True;
152 result.device.response_expected[u8::from(AmbientLightV2BrickletFunction::GetIlluminanceCallbackPeriod) as usize] =
153 ResponseExpectedFlag::AlwaysTrue;
154 result.device.response_expected[u8::from(AmbientLightV2BrickletFunction::SetIlluminanceCallbackThreshold) as usize] =
155 ResponseExpectedFlag::True;
156 result.device.response_expected[u8::from(AmbientLightV2BrickletFunction::GetIlluminanceCallbackThreshold) as usize] =
157 ResponseExpectedFlag::AlwaysTrue;
158 result.device.response_expected[u8::from(AmbientLightV2BrickletFunction::SetDebouncePeriod) as usize] = ResponseExpectedFlag::True;
159 result.device.response_expected[u8::from(AmbientLightV2BrickletFunction::GetDebouncePeriod) as usize] =
160 ResponseExpectedFlag::AlwaysTrue;
161 result.device.response_expected[u8::from(AmbientLightV2BrickletFunction::SetConfiguration) as usize] = ResponseExpectedFlag::False;
162 result.device.response_expected[u8::from(AmbientLightV2BrickletFunction::GetConfiguration) as usize] =
163 ResponseExpectedFlag::AlwaysTrue;
164 result.device.response_expected[u8::from(AmbientLightV2BrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
165 result
166 }
167
168 /// Returns the response expected flag for the function specified by the function ID parameter.
169 /// It is true if the function is expected to send a response, false otherwise.
170 ///
171 /// For getter functions this is enabled by default and cannot be disabled, because those
172 /// functions will always send a response. For callback configuration functions it is enabled
173 /// by default too, but can be disabled by [`set_response_expected`](crate::ambient_light_v2_bricklet::AmbientLightV2Bricklet::set_response_expected).
174 /// For setter functions it is disabled by default and can be enabled.
175 ///
176 /// Enabling the response expected flag for a setter function allows to detect timeouts
177 /// and other error conditions calls of this setter as well. The device will then send a response
178 /// for this purpose. If this flag is disabled for a setter function then no response is sent
179 /// and errors are silently ignored, because they cannot be detected.
180 ///
181 /// See [`set_response_expected`](crate::ambient_light_v2_bricklet::AmbientLightV2Bricklet::set_response_expected) for the list of function ID constants available for this function.
182 pub fn get_response_expected(&mut self, fun: AmbientLightV2BrickletFunction) -> Result<bool, GetResponseExpectedError> {
183 self.device.get_response_expected(u8::from(fun))
184 }
185
186 /// Changes the response expected flag of the function specified by the function ID parameter.
187 /// This flag can only be changed for setter (default value: false) and callback configuration
188 /// functions (default value: true). For getter functions it is always enabled.
189 ///
190 /// Enabling the response expected flag for a setter function allows to detect timeouts and
191 /// other error conditions calls of this setter as well. The device will then send a response
192 /// for this purpose. If this flag is disabled for a setter function then no response is sent
193 /// and errors are silently ignored, because they cannot be detected.
194 pub fn set_response_expected(
195 &mut self,
196 fun: AmbientLightV2BrickletFunction,
197 response_expected: bool,
198 ) -> Result<(), SetResponseExpectedError> {
199 self.device.set_response_expected(u8::from(fun), response_expected)
200 }
201
202 /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
203 pub fn set_response_expected_all(&mut self, response_expected: bool) {
204 self.device.set_response_expected_all(response_expected)
205 }
206
207 /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
208 /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
209 pub fn get_api_version(&self) -> [u8; 3] {
210 self.device.api_version
211 }
212
213 /// This receiver is triggered periodically with the period that is set by
214 /// [`set_illuminance_callback_period`]. The parameter is the illuminance of the
215 /// ambient light sensor.
216 ///
217 /// The [`get_illuminance_callback_receiver`] receiver is only triggered if the illuminance has changed since the
218 /// last triggering.
219 ///
220 /// [`set_illuminance_callback_period`]: #method.set_illuminance_callback_period
221 /// [`get_illuminance_callback_receiver`]: #method.get_illuminance_callback_receiver
222 pub async fn get_illuminance_callback_receiver(&mut self) -> impl Stream<Item = u32> {
223 self.device
224 .get_callback_receiver(u8::from(AmbientLightV2BrickletFunction::CallbackIlluminance))
225 .await
226 .map(|p| u32::from_le_byte_slice(p.body()))
227 }
228
229 /// This receiver is triggered when the threshold as set by
230 /// [`set_illuminance_callback_threshold`] is reached.
231 /// The parameter is the illuminance of the ambient light sensor.
232 ///
233 /// If the threshold keeps being reached, the receiver is triggered periodically
234 /// with the period as set by [`set_debounce_period`].
235 pub async fn get_illuminance_reached_callback_receiver(&mut self) -> impl Stream<Item = u32> {
236 self.device
237 .get_callback_receiver(u8::from(AmbientLightV2BrickletFunction::CallbackIlluminanceReached))
238 .await
239 .map(|p| u32::from_le_byte_slice(p.body()))
240 }
241
242 /// Returns the illuminance of the ambient light sensor. The measurement range goes
243 /// up to about 100000lux, but above 64000lux the precision starts to drop.
244 ///
245 /// .. versionchanged:: 2.0.2$nbsp;(Plugin)
246 /// An illuminance of 0lux indicates an error condition where the sensor cannot
247 /// perform a reasonable measurement. This can happen with very dim or very bright
248 /// light conditions. In bright light conditions this might indicate that the sensor
249 /// is saturated and the configuration should be modified ([`set_configuration`])
250 /// to better match the light conditions.
251 ///
252 /// If you want to get the illuminance periodically, it is recommended to use the
253 /// [`get_illuminance_callback_receiver`] receiver and set the period with
254 /// [`set_illuminance_callback_period`].
255 pub async fn get_illuminance(&mut self) -> Result<u32, TinkerforgeError> {
256 let payload = [0; 0];
257
258 #[allow(unused_variables)]
259 let result = self.device.get(u8::from(AmbientLightV2BrickletFunction::GetIlluminance), &payload).await?;
260 Ok(u32::from_le_byte_slice(result.body()))
261 }
262
263 /// Sets the period with which the [`get_illuminance_callback_receiver`] receiver is triggered
264 /// periodically. A value of 0 turns the receiver off.
265 ///
266 /// The [`get_illuminance_callback_receiver`] receiver is only triggered if the illuminance has changed
267 /// since the last triggering.
268 pub async fn set_illuminance_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
269 let mut payload = [0; 4];
270 period.write_to_slice(&mut payload[0..4]);
271
272 #[allow(unused_variables)]
273 let result = self.device.set(u8::from(AmbientLightV2BrickletFunction::SetIlluminanceCallbackPeriod), &payload).await?;
274 Ok(())
275 }
276
277 /// Returns the period as set by [`set_illuminance_callback_period`].
278 pub async fn get_illuminance_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
279 let payload = [0; 0];
280
281 #[allow(unused_variables)]
282 let result = self.device.get(u8::from(AmbientLightV2BrickletFunction::GetIlluminanceCallbackPeriod), &payload).await?;
283 Ok(u32::from_le_byte_slice(result.body()))
284 }
285
286 /// Sets the thresholds for the [`get_illuminance_reached_callback_receiver`] receiver.
287 ///
288 /// The following options are possible:
289 ///
290 /// Option| Description
291 /// --- | ---
292 /// 'x'| Receiver is turned off
293 /// 'o'| Receiver is triggered when the illuminance is *outside* the min and max values
294 /// 'i'| Receiver is triggered when the illuminance is *inside* the min and max values
295 /// '<'| Receiver is triggered when the illuminance is smaller than the min value (max is ignored)
296 /// '>'| Receiver is triggered when the illuminance is greater than the min value (max is ignored)
297 ///
298 /// Associated constants:
299 /// * AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_OFF
300 /// * AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
301 /// * AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
302 /// * AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
303 /// * AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_GREATER
304 pub async fn set_illuminance_callback_threshold(&mut self, option: char, min: u32, max: u32) -> Result<(), TinkerforgeError> {
305 let mut payload = [0; 9];
306 option.write_to_slice(&mut payload[0..1]);
307 min.write_to_slice(&mut payload[1..5]);
308 max.write_to_slice(&mut payload[5..9]);
309
310 #[allow(unused_variables)]
311 let result = self.device.set(u8::from(AmbientLightV2BrickletFunction::SetIlluminanceCallbackThreshold), &payload).await?;
312 Ok(())
313 }
314
315 /// Returns the threshold as set by [`set_illuminance_callback_threshold`].
316 ///
317 /// Associated constants:
318 /// * AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_OFF
319 /// * AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_OUTSIDE
320 /// * AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_INSIDE
321 /// * AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_SMALLER
322 /// * AMBIENT_LIGHT_V2_BRICKLET_THRESHOLD_OPTION_GREATER
323 pub async fn get_illuminance_callback_threshold(&mut self) -> Result<IlluminanceCallbackThreshold, TinkerforgeError> {
324 let payload = [0; 0];
325
326 #[allow(unused_variables)]
327 let result = self.device.get(u8::from(AmbientLightV2BrickletFunction::GetIlluminanceCallbackThreshold), &payload).await?;
328 Ok(IlluminanceCallbackThreshold::from_le_byte_slice(result.body()))
329 }
330
331 /// Sets the period with which the threshold receivers
332 ///
333 /// * [`get_illuminance_reached_callback_receiver`],
334 ///
335 /// are triggered, if the thresholds
336 ///
337 /// * [`set_illuminance_callback_threshold`],
338 ///
339 /// keep being reached.
340 pub async fn set_debounce_period(&mut self, debounce: u32) -> Result<(), TinkerforgeError> {
341 let mut payload = [0; 4];
342 debounce.write_to_slice(&mut payload[0..4]);
343
344 #[allow(unused_variables)]
345 let result = self.device.set(u8::from(AmbientLightV2BrickletFunction::SetDebouncePeriod), &payload).await?;
346 Ok(())
347 }
348
349 /// Returns the debounce period as set by [`set_debounce_period`].
350 pub async fn get_debounce_period(&mut self) -> Result<u32, TinkerforgeError> {
351 let payload = [0; 0];
352
353 #[allow(unused_variables)]
354 let result = self.device.get(u8::from(AmbientLightV2BrickletFunction::GetDebouncePeriod), &payload).await?;
355 Ok(u32::from_le_byte_slice(result.body()))
356 }
357
358 /// Sets the configuration. It is possible to configure an illuminance range
359 /// between 0-600lux and 0-64000lux and an integration time between 50ms and 400ms.
360 ///
361 /// .. versionadded:: 2.0.2$nbsp;(Plugin)
362 /// The unlimited illuminance range allows to measure up to about 100000lux, but
363 /// above 64000lux the precision starts to drop.
364 ///
365 /// A smaller illuminance range increases the resolution of the data. A longer
366 /// integration time will result in less noise on the data.
367 ///
368 /// .. versionchanged:: 2.0.2$nbsp;(Plugin)
369 /// If the actual measure illuminance is out-of-range then the current illuminance
370 /// range maximum +0.01lux is reported by [`get_illuminance`] and the
371 /// [`get_illuminance_callback_receiver`] receiver. For example, 800001 for the 0-8000lux range.
372 ///
373 /// .. versionchanged:: 2.0.2$nbsp;(Plugin)
374 /// With a long integration time the sensor might be saturated before the measured
375 /// value reaches the maximum of the selected illuminance range. In this case 0lux
376 /// is reported by [`get_illuminance`] and the [`get_illuminance_callback_receiver`] receiver.
377 ///
378 /// If the measurement is out-of-range or the sensor is saturated then you should
379 /// configure the next higher illuminance range. If the highest range is already
380 /// in use, then start to reduce the integration time.
381 ///
382 /// Associated constants:
383 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_UNLIMITED
384 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_64000LUX
385 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_32000LUX
386 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_16000LUX
387 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_8000LUX
388 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_1300LUX
389 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_600LUX
390 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_50MS
391 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_100MS
392 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_150MS
393 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_200MS
394 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_250MS
395 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_300MS
396 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_350MS
397 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_400MS
398 pub async fn set_configuration(&mut self, illuminance_range: u8, integration_time: u8) -> Result<(), TinkerforgeError> {
399 let mut payload = [0; 2];
400 illuminance_range.write_to_slice(&mut payload[0..1]);
401 integration_time.write_to_slice(&mut payload[1..2]);
402
403 #[allow(unused_variables)]
404 let result = self.device.set(u8::from(AmbientLightV2BrickletFunction::SetConfiguration), &payload).await?;
405 Ok(())
406 }
407
408 /// Returns the configuration as set by [`set_configuration`].
409 ///
410 /// Associated constants:
411 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_UNLIMITED
412 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_64000LUX
413 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_32000LUX
414 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_16000LUX
415 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_8000LUX
416 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_1300LUX
417 /// * AMBIENT_LIGHT_V2_BRICKLET_ILLUMINANCE_RANGE_600LUX
418 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_50MS
419 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_100MS
420 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_150MS
421 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_200MS
422 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_250MS
423 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_300MS
424 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_350MS
425 /// * AMBIENT_LIGHT_V2_BRICKLET_INTEGRATION_TIME_400MS
426 pub async fn get_configuration(&mut self) -> Result<Configuration, TinkerforgeError> {
427 let payload = [0; 0];
428
429 #[allow(unused_variables)]
430 let result = self.device.get(u8::from(AmbientLightV2BrickletFunction::GetConfiguration), &payload).await?;
431 Ok(Configuration::from_le_byte_slice(result.body()))
432 }
433
434 /// Returns the UID, the UID where the Bricklet is connected to,
435 /// the position, the hardware and firmware version as well as the
436 /// device identifier.
437 ///
438 /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
439 /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
440 /// position 'z'.
441 ///
442 /// The device identifier numbers can be found [here](device_identifier).
443 /// |device_identifier_constant|
444 pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
445 let payload = [0; 0];
446
447 #[allow(unused_variables)]
448 let result = self.device.get(u8::from(AmbientLightV2BrickletFunction::GetIdentity), &payload).await?;
449 Ok(Identity::from_le_byte_slice(result.body()))
450 }
451}