tinkerforge_async/bindings/
thermal_imaging_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//! 80x60 pixel thermal imaging camera.
12//!
13//! See also the documentation [here](https://www.tinkerforge.com/en/doc/Software/Bricklets/ThermalImaging_Bricklet_Rust.html).
14#[allow(unused_imports)]
15use crate::{
16    base58::Uid, byte_converter::*, converting_high_level_callback_receiver::ConvertingHighLevelCallbackReceiver,
17    converting_receiver::BrickletRecvTimeoutError, device::*, error::TinkerforgeError, ip_connection::async_io::AsyncIpConnection,
18    low_level_traits::LowLevelRead,
19};
20#[allow(unused_imports)]
21use futures_core::Stream;
22#[allow(unused_imports)]
23use tokio_stream::StreamExt;
24pub enum ThermalImagingBrickletFunction {
25    GetHighContrastImageLowLevel,
26    GetTemperatureImageLowLevel,
27    GetStatistics,
28    SetResolution,
29    GetResolution,
30    SetSpotmeterConfig,
31    GetSpotmeterConfig,
32    SetHighContrastConfig,
33    GetHighContrastConfig,
34    SetImageTransferConfig,
35    GetImageTransferConfig,
36    SetFluxLinearParameters,
37    GetFluxLinearParameters,
38    SetFfcShutterMode,
39    GetFfcShutterMode,
40    RunFfcNormalization,
41    GetSpitfpErrorCount,
42    SetBootloaderMode,
43    GetBootloaderMode,
44    SetWriteFirmwarePointer,
45    WriteFirmware,
46    SetStatusLedConfig,
47    GetStatusLedConfig,
48    GetChipTemperature,
49    Reset,
50    WriteUid,
51    ReadUid,
52    GetIdentity,
53    CallbackHighContrastImageLowLevel,
54    CallbackTemperatureImageLowLevel,
55}
56impl From<ThermalImagingBrickletFunction> for u8 {
57    fn from(fun: ThermalImagingBrickletFunction) -> Self {
58        match fun {
59            ThermalImagingBrickletFunction::GetHighContrastImageLowLevel => 1,
60            ThermalImagingBrickletFunction::GetTemperatureImageLowLevel => 2,
61            ThermalImagingBrickletFunction::GetStatistics => 3,
62            ThermalImagingBrickletFunction::SetResolution => 4,
63            ThermalImagingBrickletFunction::GetResolution => 5,
64            ThermalImagingBrickletFunction::SetSpotmeterConfig => 6,
65            ThermalImagingBrickletFunction::GetSpotmeterConfig => 7,
66            ThermalImagingBrickletFunction::SetHighContrastConfig => 8,
67            ThermalImagingBrickletFunction::GetHighContrastConfig => 9,
68            ThermalImagingBrickletFunction::SetImageTransferConfig => 10,
69            ThermalImagingBrickletFunction::GetImageTransferConfig => 11,
70            ThermalImagingBrickletFunction::SetFluxLinearParameters => 14,
71            ThermalImagingBrickletFunction::GetFluxLinearParameters => 15,
72            ThermalImagingBrickletFunction::SetFfcShutterMode => 16,
73            ThermalImagingBrickletFunction::GetFfcShutterMode => 17,
74            ThermalImagingBrickletFunction::RunFfcNormalization => 18,
75            ThermalImagingBrickletFunction::GetSpitfpErrorCount => 234,
76            ThermalImagingBrickletFunction::SetBootloaderMode => 235,
77            ThermalImagingBrickletFunction::GetBootloaderMode => 236,
78            ThermalImagingBrickletFunction::SetWriteFirmwarePointer => 237,
79            ThermalImagingBrickletFunction::WriteFirmware => 238,
80            ThermalImagingBrickletFunction::SetStatusLedConfig => 239,
81            ThermalImagingBrickletFunction::GetStatusLedConfig => 240,
82            ThermalImagingBrickletFunction::GetChipTemperature => 242,
83            ThermalImagingBrickletFunction::Reset => 243,
84            ThermalImagingBrickletFunction::WriteUid => 248,
85            ThermalImagingBrickletFunction::ReadUid => 249,
86            ThermalImagingBrickletFunction::GetIdentity => 255,
87            ThermalImagingBrickletFunction::CallbackHighContrastImageLowLevel => 12,
88            ThermalImagingBrickletFunction::CallbackTemperatureImageLowLevel => 13,
89        }
90    }
91}
92pub const THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_6553_KELVIN: u8 = 0;
93pub const THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_655_KELVIN: u8 = 1;
94pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_NEVER_COMMANDED: u8 = 0;
95pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_IMMINENT: u8 = 1;
96pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_IN_PROGRESS: u8 = 2;
97pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_COMPLETE: u8 = 3;
98pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_MANUAL_HIGH_CONTRAST_IMAGE: u8 = 0;
99pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_MANUAL_TEMPERATURE_IMAGE: u8 = 1;
100pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_CALLBACK_HIGH_CONTRAST_IMAGE: u8 = 2;
101pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_CALLBACK_TEMPERATURE_IMAGE: u8 = 3;
102pub const THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_MANUAL: u8 = 0;
103pub const THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_AUTO: u8 = 1;
104pub const THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_EXTERNAL: u8 = 2;
105pub const THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_INACTIVE: u8 = 0;
106pub const THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_HIGH: u8 = 1;
107pub const THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_LOW: u8 = 2;
108pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
109pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
110pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
111pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
112pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
113pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
114pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
115pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
116pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
117pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
118pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
119pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
120pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
121pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
122pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
123
124#[derive(Clone, Copy)]
125pub struct HighContrastImageLowLevel {
126    pub image_chunk_offset: u16,
127    pub image_chunk_data: [u8; 62],
128}
129impl FromByteSlice for HighContrastImageLowLevel {
130    fn bytes_expected() -> usize {
131        64
132    }
133    fn from_le_byte_slice(bytes: &[u8]) -> HighContrastImageLowLevel {
134        HighContrastImageLowLevel {
135            image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
136            image_chunk_data: <[u8; 62]>::from_le_byte_slice(&bytes[2..64]),
137        }
138    }
139}
140impl LowLevelRead<u8, HighContrastImageResult> for HighContrastImageLowLevel {
141    fn ll_message_length(&self) -> usize {
142        4800
143    }
144
145    fn ll_message_chunk_offset(&self) -> usize {
146        self.image_chunk_offset as usize
147    }
148
149    fn ll_message_chunk_data(&self) -> &[u8] {
150        &self.image_chunk_data
151    }
152
153    fn get_result(&self) -> HighContrastImageResult {
154        HighContrastImageResult {}
155    }
156}
157
158#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
159pub struct TemperatureImageLowLevel {
160    pub image_chunk_offset: u16,
161    pub image_chunk_data: [u16; 31],
162}
163impl FromByteSlice for TemperatureImageLowLevel {
164    fn bytes_expected() -> usize {
165        64
166    }
167    fn from_le_byte_slice(bytes: &[u8]) -> TemperatureImageLowLevel {
168        TemperatureImageLowLevel {
169            image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
170            image_chunk_data: <[u16; 31]>::from_le_byte_slice(&bytes[2..64]),
171        }
172    }
173}
174impl LowLevelRead<u16, TemperatureImageResult> for TemperatureImageLowLevel {
175    fn ll_message_length(&self) -> usize {
176        4800
177    }
178
179    fn ll_message_chunk_offset(&self) -> usize {
180        self.image_chunk_offset as usize
181    }
182
183    fn ll_message_chunk_data(&self) -> &[u16] {
184        &self.image_chunk_data
185    }
186
187    fn get_result(&self) -> TemperatureImageResult {
188        TemperatureImageResult {}
189    }
190}
191
192#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
193pub struct Statistics {
194    pub spotmeter_statistics: [u16; 4],
195    pub temperatures: [u16; 4],
196    pub resolution: u8,
197    pub ffc_status: u8,
198    pub temperature_warning: [bool; 2],
199}
200impl FromByteSlice for Statistics {
201    fn bytes_expected() -> usize {
202        19
203    }
204    fn from_le_byte_slice(bytes: &[u8]) -> Statistics {
205        Statistics {
206            spotmeter_statistics: <[u16; 4]>::from_le_byte_slice(&bytes[0..8]),
207            temperatures: <[u16; 4]>::from_le_byte_slice(&bytes[8..16]),
208            resolution: <u8>::from_le_byte_slice(&bytes[16..17]),
209            ffc_status: <u8>::from_le_byte_slice(&bytes[17..18]),
210            temperature_warning: <[bool; 2]>::from_le_byte_slice(&bytes[18..19]),
211        }
212    }
213}
214
215#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
216pub struct HighContrastConfig {
217    pub region_of_interest: [u8; 4],
218    pub dampening_factor: u16,
219    pub clip_limit: [u16; 2],
220    pub empty_counts: u16,
221}
222impl FromByteSlice for HighContrastConfig {
223    fn bytes_expected() -> usize {
224        12
225    }
226    fn from_le_byte_slice(bytes: &[u8]) -> HighContrastConfig {
227        HighContrastConfig {
228            region_of_interest: <[u8; 4]>::from_le_byte_slice(&bytes[0..4]),
229            dampening_factor: <u16>::from_le_byte_slice(&bytes[4..6]),
230            clip_limit: <[u16; 2]>::from_le_byte_slice(&bytes[6..10]),
231            empty_counts: <u16>::from_le_byte_slice(&bytes[10..12]),
232        }
233    }
234}
235
236#[derive(Clone, Copy)]
237pub struct HighContrastImageLowLevelEvent {
238    pub image_chunk_offset: u16,
239    pub image_chunk_data: [u8; 62],
240}
241impl FromByteSlice for HighContrastImageLowLevelEvent {
242    fn bytes_expected() -> usize {
243        64
244    }
245    fn from_le_byte_slice(bytes: &[u8]) -> HighContrastImageLowLevelEvent {
246        HighContrastImageLowLevelEvent {
247            image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
248            image_chunk_data: <[u8; 62]>::from_le_byte_slice(&bytes[2..64]),
249        }
250    }
251}
252impl LowLevelRead<u8, HighContrastImageResult> for HighContrastImageLowLevelEvent {
253    fn ll_message_length(&self) -> usize {
254        4800
255    }
256
257    fn ll_message_chunk_offset(&self) -> usize {
258        self.image_chunk_offset as usize
259    }
260
261    fn ll_message_chunk_data(&self) -> &[u8] {
262        &self.image_chunk_data
263    }
264
265    fn get_result(&self) -> HighContrastImageResult {
266        HighContrastImageResult {}
267    }
268}
269
270#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
271pub struct TemperatureImageLowLevelEvent {
272    pub image_chunk_offset: u16,
273    pub image_chunk_data: [u16; 31],
274}
275impl FromByteSlice for TemperatureImageLowLevelEvent {
276    fn bytes_expected() -> usize {
277        64
278    }
279    fn from_le_byte_slice(bytes: &[u8]) -> TemperatureImageLowLevelEvent {
280        TemperatureImageLowLevelEvent {
281            image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
282            image_chunk_data: <[u16; 31]>::from_le_byte_slice(&bytes[2..64]),
283        }
284    }
285}
286impl LowLevelRead<u16, TemperatureImageResult> for TemperatureImageLowLevelEvent {
287    fn ll_message_length(&self) -> usize {
288        4800
289    }
290
291    fn ll_message_chunk_offset(&self) -> usize {
292        self.image_chunk_offset as usize
293    }
294
295    fn ll_message_chunk_data(&self) -> &[u16] {
296        &self.image_chunk_data
297    }
298
299    fn get_result(&self) -> TemperatureImageResult {
300        TemperatureImageResult {}
301    }
302}
303
304#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
305pub struct FluxLinearParameters {
306    pub scene_emissivity: u16,
307    pub temperature_background: u16,
308    pub tau_window: u16,
309    pub temperatur_window: u16,
310    pub tau_atmosphere: u16,
311    pub temperature_atmosphere: u16,
312    pub reflection_window: u16,
313    pub temperature_reflection: u16,
314}
315impl FromByteSlice for FluxLinearParameters {
316    fn bytes_expected() -> usize {
317        16
318    }
319    fn from_le_byte_slice(bytes: &[u8]) -> FluxLinearParameters {
320        FluxLinearParameters {
321            scene_emissivity: <u16>::from_le_byte_slice(&bytes[0..2]),
322            temperature_background: <u16>::from_le_byte_slice(&bytes[2..4]),
323            tau_window: <u16>::from_le_byte_slice(&bytes[4..6]),
324            temperatur_window: <u16>::from_le_byte_slice(&bytes[6..8]),
325            tau_atmosphere: <u16>::from_le_byte_slice(&bytes[8..10]),
326            temperature_atmosphere: <u16>::from_le_byte_slice(&bytes[10..12]),
327            reflection_window: <u16>::from_le_byte_slice(&bytes[12..14]),
328            temperature_reflection: <u16>::from_le_byte_slice(&bytes[14..16]),
329        }
330    }
331}
332
333#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
334pub struct FfcShutterMode {
335    pub shutter_mode: u8,
336    pub temp_lockout_state: u8,
337    pub video_freeze_during_ffc: bool,
338    pub ffc_desired: bool,
339    pub elapsed_time_since_last_ffc: u32,
340    pub desired_ffc_period: u32,
341    pub explicit_cmd_to_open: bool,
342    pub desired_ffc_temp_delta: u16,
343    pub imminent_delay: u16,
344}
345impl FromByteSlice for FfcShutterMode {
346    fn bytes_expected() -> usize {
347        17
348    }
349    fn from_le_byte_slice(bytes: &[u8]) -> FfcShutterMode {
350        FfcShutterMode {
351            shutter_mode: <u8>::from_le_byte_slice(&bytes[0..1]),
352            temp_lockout_state: <u8>::from_le_byte_slice(&bytes[1..2]),
353            video_freeze_during_ffc: <bool>::from_le_byte_slice(&bytes[2..3]),
354            ffc_desired: <bool>::from_le_byte_slice(&bytes[3..4]),
355            elapsed_time_since_last_ffc: <u32>::from_le_byte_slice(&bytes[4..8]),
356            desired_ffc_period: <u32>::from_le_byte_slice(&bytes[8..12]),
357            explicit_cmd_to_open: <bool>::from_le_byte_slice(&bytes[12..13]),
358            desired_ffc_temp_delta: <u16>::from_le_byte_slice(&bytes[13..15]),
359            imminent_delay: <u16>::from_le_byte_slice(&bytes[15..17]),
360        }
361    }
362}
363
364#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
365pub struct SpitfpErrorCount {
366    pub error_count_ack_checksum: u32,
367    pub error_count_message_checksum: u32,
368    pub error_count_frame: u32,
369    pub error_count_overflow: u32,
370}
371impl FromByteSlice for SpitfpErrorCount {
372    fn bytes_expected() -> usize {
373        16
374    }
375    fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
376        SpitfpErrorCount {
377            error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
378            error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
379            error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
380            error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
381        }
382    }
383}
384
385#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
386pub struct Identity {
387    pub uid: String,
388    pub connected_uid: String,
389    pub position: char,
390    pub hardware_version: [u8; 3],
391    pub firmware_version: [u8; 3],
392    pub device_identifier: u16,
393}
394impl FromByteSlice for Identity {
395    fn bytes_expected() -> usize {
396        25
397    }
398    fn from_le_byte_slice(bytes: &[u8]) -> Identity {
399        Identity {
400            uid: <String>::from_le_byte_slice(&bytes[0..8]),
401            connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
402            position: <char>::from_le_byte_slice(&bytes[16..17]),
403            hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
404            firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
405            device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
406        }
407    }
408}
409
410#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
411pub struct HighContrastImageResult {}
412
413#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
414pub struct TemperatureImageResult {}
415
416/// 80x60 pixel thermal imaging camera
417#[derive(Clone)]
418pub struct ThermalImagingBricklet {
419    device: Device,
420}
421impl ThermalImagingBricklet {
422    pub const DEVICE_IDENTIFIER: u16 = 278;
423    pub const DEVICE_DISPLAY_NAME: &'static str = "Thermal Imaging Bricklet";
424    /// Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ip_connection` is connected.
425    pub fn new(uid: Uid, connection: AsyncIpConnection) -> ThermalImagingBricklet {
426        let mut result = ThermalImagingBricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
427        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetHighContrastImageLowLevel) as usize] =
428            ResponseExpectedFlag::AlwaysTrue;
429        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetTemperatureImageLowLevel) as usize] =
430            ResponseExpectedFlag::AlwaysTrue;
431        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetStatistics) as usize] =
432            ResponseExpectedFlag::AlwaysTrue;
433        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetResolution) as usize] = ResponseExpectedFlag::False;
434        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetResolution) as usize] =
435            ResponseExpectedFlag::AlwaysTrue;
436        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetSpotmeterConfig) as usize] =
437            ResponseExpectedFlag::False;
438        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetSpotmeterConfig) as usize] =
439            ResponseExpectedFlag::AlwaysTrue;
440        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetHighContrastConfig) as usize] =
441            ResponseExpectedFlag::False;
442        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetHighContrastConfig) as usize] =
443            ResponseExpectedFlag::AlwaysTrue;
444        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetImageTransferConfig) as usize] =
445            ResponseExpectedFlag::True;
446        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetImageTransferConfig) as usize] =
447            ResponseExpectedFlag::AlwaysTrue;
448        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetFluxLinearParameters) as usize] =
449            ResponseExpectedFlag::False;
450        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetFluxLinearParameters) as usize] =
451            ResponseExpectedFlag::AlwaysTrue;
452        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetFfcShutterMode) as usize] = ResponseExpectedFlag::False;
453        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetFfcShutterMode) as usize] =
454            ResponseExpectedFlag::AlwaysTrue;
455        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::RunFfcNormalization) as usize] =
456            ResponseExpectedFlag::False;
457        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetSpitfpErrorCount) as usize] =
458            ResponseExpectedFlag::AlwaysTrue;
459        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetBootloaderMode) as usize] =
460            ResponseExpectedFlag::AlwaysTrue;
461        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetBootloaderMode) as usize] =
462            ResponseExpectedFlag::AlwaysTrue;
463        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetWriteFirmwarePointer) as usize] =
464            ResponseExpectedFlag::False;
465        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::WriteFirmware) as usize] =
466            ResponseExpectedFlag::AlwaysTrue;
467        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetStatusLedConfig) as usize] =
468            ResponseExpectedFlag::False;
469        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetStatusLedConfig) as usize] =
470            ResponseExpectedFlag::AlwaysTrue;
471        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetChipTemperature) as usize] =
472            ResponseExpectedFlag::AlwaysTrue;
473        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
474        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
475        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
476        result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
477        result
478    }
479
480    /// Returns the response expected flag for the function specified by the function ID parameter.
481    /// It is true if the function is expected to send a response, false otherwise.
482    ///
483    /// For getter functions this is enabled by default and cannot be disabled, because those
484    /// functions will always send a response. For callback configuration functions it is enabled
485    /// by default too, but can be disabled by [`set_response_expected`](crate::thermal_imaging_bricklet::ThermalImagingBricklet::set_response_expected).
486    /// For setter functions it is disabled by default and can be enabled.
487    ///
488    /// Enabling the response expected flag for a setter function allows to detect timeouts
489    /// and other error conditions calls of this setter as well. The device will then send a response
490    /// for this purpose. If this flag is disabled for a setter function then no response is sent
491    /// and errors are silently ignored, because they cannot be detected.
492    ///
493    /// See [`set_response_expected`](crate::thermal_imaging_bricklet::ThermalImagingBricklet::set_response_expected) for the list of function ID constants available for this function.
494    pub fn get_response_expected(&mut self, fun: ThermalImagingBrickletFunction) -> Result<bool, GetResponseExpectedError> {
495        self.device.get_response_expected(u8::from(fun))
496    }
497
498    /// Changes the response expected flag of the function specified by the function ID parameter.
499    /// This flag can only be changed for setter (default value: false) and callback configuration
500    /// functions (default value: true). For getter functions it is always enabled.
501    ///
502    /// Enabling the response expected flag for a setter function allows to detect timeouts and
503    /// other error conditions calls of this setter as well. The device will then send a response
504    /// for this purpose. If this flag is disabled for a setter function then no response is sent
505    /// and errors are silently ignored, because they cannot be detected.
506    pub fn set_response_expected(
507        &mut self,
508        fun: ThermalImagingBrickletFunction,
509        response_expected: bool,
510    ) -> Result<(), SetResponseExpectedError> {
511        self.device.set_response_expected(u8::from(fun), response_expected)
512    }
513
514    /// Changes the response expected flag for all setter and callback configuration functions of this device at once.
515    pub fn set_response_expected_all(&mut self, response_expected: bool) {
516        self.device.set_response_expected_all(response_expected)
517    }
518
519    /// Returns the version of the API definition (major, minor, revision) implemented by this API bindings.
520    /// This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
521    pub fn get_api_version(&self) -> [u8; 3] {
522        self.device.api_version
523    }
524
525    /// See [`get_high_contrast_image_callback_receiver`](crate::thermal_imaging::ThermalImaging::get_high_contrast_image_callback_receiver)
526    pub async fn get_high_contrast_image_low_level_callback_receiver(&mut self) -> impl Stream<Item = HighContrastImageLowLevelEvent> {
527        self.device
528            .get_callback_receiver(u8::from(ThermalImagingBrickletFunction::CallbackHighContrastImageLowLevel))
529            .await
530            .map(|p| HighContrastImageLowLevelEvent::from_le_byte_slice(p.body()))
531    }
532
533    /// See [`get_temperature_image_callback_receiver`](crate::thermal_imaging::ThermalImaging::get_temperature_image_callback_receiver)
534    pub async fn get_temperature_image_low_level_callback_receiver(&mut self) -> impl Stream<Item = TemperatureImageLowLevelEvent> {
535        self.device
536            .get_callback_receiver(u8::from(ThermalImagingBrickletFunction::CallbackTemperatureImageLowLevel))
537            .await
538            .map(|p| TemperatureImageLowLevelEvent::from_le_byte_slice(p.body()))
539    }
540
541    /// Returns the current high contrast image. See [here](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Thermal_Imaging.html#high-contrast-image-vs-temperature-image)__
542    /// for the difference between
543    /// High Contrast and Temperature Image. If you don't know what to use
544    /// the High Contrast Image is probably right for you.
545    ///
546    /// The data is organized as a 8-bit value 80x60 pixel matrix linearized in
547    /// a one-dimensional array. The data is arranged line by line from top left to
548    /// bottom right.
549    ///
550    /// Each 8-bit value represents one gray-scale image pixel that can directly be
551    /// shown to a user on a display.
552    ///
553    /// Before you can use this function you have to enable it with
554    /// [`set_image_transfer_config`].
555    ///
556    /// [`set_image_transfer_config`]: #method.set_image_transfer_config
557    pub async fn get_high_contrast_image_low_level(&mut self) -> Result<HighContrastImageLowLevel, TinkerforgeError> {
558        let payload = [0; 0];
559
560        #[allow(unused_variables)]
561        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetHighContrastImageLowLevel), &payload).await?;
562        Ok(HighContrastImageLowLevel::from_le_byte_slice(result.body()))
563    }
564
565    /// Returns the current temperature image. See [here](https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Thermal_Imaging.html#high-contrast-image-vs-temperature-image)__
566    /// for the difference between High Contrast and Temperature Image.
567    /// If you don't know what to use the High Contrast Image is probably right for you.
568    ///
569    /// The data is organized as a 16-bit value 80x60 pixel matrix linearized in
570    /// a one-dimensional array. The data is arranged line by line from top left to
571    /// bottom right.
572    ///
573    /// Each 16-bit value represents one temperature measurement in either
574    /// Kelvin/10 or Kelvin/100 (depending on the resolution set with [`set_resolution`]).
575    ///
576    /// Before you can use this function you have to enable it with
577    /// [`set_image_transfer_config`].
578    pub async fn get_temperature_image_low_level(&mut self) -> Result<TemperatureImageLowLevel, TinkerforgeError> {
579        let payload = [0; 0];
580
581        #[allow(unused_variables)]
582        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetTemperatureImageLowLevel), &payload).await?;
583        Ok(TemperatureImageLowLevel::from_le_byte_slice(result.body()))
584    }
585
586    /// Returns the spotmeter statistics, various temperatures, current resolution and status bits.
587    ///
588    /// The spotmeter statistics are:
589    ///
590    /// * Index 0: Mean Temperature.
591    /// * Index 1: Maximum Temperature.
592    /// * Index 2: Minimum Temperature.
593    /// * Index 3: Pixel Count of spotmeter region of interest.
594    ///
595    /// The temperatures are:
596    ///
597    /// * Index 0: Focal Plain Array temperature.
598    /// * Index 1: Focal Plain Array temperature at last FFC (Flat Field Correction).
599    /// * Index 2: Housing temperature.
600    /// * Index 3: Housing temperature at last FFC.
601    ///
602    /// The resolution is either `0 to 6553 Kelvin` or `0 to 655 Kelvin`. If the resolution is the former,
603    /// the temperatures are in Kelvin/10, if it is the latter the temperatures are in Kelvin/100.
604    ///
605    /// FFC (Flat Field Correction) Status:
606    ///
607    /// * FFC Never Commanded: Only seen on startup before first FFC.
608    /// * FFC Imminent: This state is entered 2 seconds prior to initiating FFC.
609    /// * FFC In Progress: Flat field correction is started (shutter moves in front of lens and back). Takes about 1 second.
610    /// * FFC Complete: Shutter is in waiting position again, FFC done.
611    ///
612    /// Temperature warning bits:
613    ///
614    /// * Index 0: Shutter lockout (if true shutter is locked out because temperature is outside -10°C to +65°C)
615    /// * Index 1: Overtemperature shut down imminent (goes true 10 seconds before shutdown)
616    ///
617    /// Associated constants:
618    /// * THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_6553_KELVIN
619    ///	* THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_655_KELVIN
620    ///	* THERMAL_IMAGING_BRICKLET_FFC_STATUS_NEVER_COMMANDED
621    ///	* THERMAL_IMAGING_BRICKLET_FFC_STATUS_IMMINENT
622    ///	* THERMAL_IMAGING_BRICKLET_FFC_STATUS_IN_PROGRESS
623    ///	* THERMAL_IMAGING_BRICKLET_FFC_STATUS_COMPLETE
624    pub async fn get_statistics(&mut self) -> Result<Statistics, TinkerforgeError> {
625        let payload = [0; 0];
626
627        #[allow(unused_variables)]
628        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetStatistics), &payload).await?;
629        Ok(Statistics::from_le_byte_slice(result.body()))
630    }
631
632    /// Sets the resolution. The Thermal Imaging Bricklet can either measure
633    ///
634    /// * from 0 to 6553 Kelvin (-273.15°C to +6279.85°C) with 0.1°C resolution or
635    /// * from 0 to 655 Kelvin (-273.15°C to +381.85°C) with 0.01°C resolution.
636    ///
637    /// The accuracy is specified for -10°C to 450°C in the
638    /// first range and -10°C and 140°C in the second range.
639    ///
640    /// Associated constants:
641    /// * THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_6553_KELVIN
642    ///	* THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_655_KELVIN
643    pub async fn set_resolution(&mut self, resolution: u8) -> Result<(), TinkerforgeError> {
644        let mut payload = [0; 1];
645        resolution.write_to_slice(&mut payload[0..1]);
646
647        #[allow(unused_variables)]
648        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetResolution), &payload).await?;
649        Ok(())
650    }
651
652    /// Returns the resolution as set by [`set_resolution`].
653    ///
654    /// Associated constants:
655    /// * THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_6553_KELVIN
656    ///	* THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_655_KELVIN
657    pub async fn get_resolution(&mut self) -> Result<u8, TinkerforgeError> {
658        let payload = [0; 0];
659
660        #[allow(unused_variables)]
661        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetResolution), &payload).await?;
662        Ok(u8::from_le_byte_slice(result.body()))
663    }
664
665    /// Sets the spotmeter region of interest. The 4 values are
666    ///
667    /// * Index 0: Column start (has to be smaller then Column end).
668    /// * Index 1: Row start (has to be smaller then Row end).
669    /// * Index 2: Column end (has to be smaller then 80).
670    /// * Index 3: Row end (has to be smaller then 60).
671    ///
672    /// The spotmeter statistics can be read out with [`get_statistics`].
673    pub async fn set_spotmeter_config(&mut self, region_of_interest: &[u8; 4]) -> Result<(), TinkerforgeError> {
674        let mut payload = [0; 4];
675        region_of_interest.write_to_slice(&mut payload[0..4]);
676
677        #[allow(unused_variables)]
678        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetSpotmeterConfig), &payload).await?;
679        Ok(())
680    }
681
682    /// Returns the spotmeter config as set by [`set_spotmeter_config`].
683    pub async fn get_spotmeter_config(&mut self) -> Result<Box<[u8; 4]>, TinkerforgeError> {
684        let payload = [0; 0];
685
686        #[allow(unused_variables)]
687        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetSpotmeterConfig), &payload).await?;
688        Ok(Box::<[u8; 4]>::from_le_byte_slice(result.body()))
689    }
690
691    /// Sets the high contrast region of interest, dampening factor, clip limit and empty counts.
692    /// This config is only used in high contrast mode (see [`set_image_transfer_config`]).
693    ///
694    /// The high contrast region of interest consists of four values:
695    ///
696    /// * Index 0: Column start (has to be smaller or equal then Column end).
697    /// * Index 1: Row start (has to be smaller then Row end).
698    /// * Index 2: Column end (has to be smaller then 80).
699    /// * Index 3: Row end (has to be smaller then 60).
700    ///
701    /// The algorithm to generate the high contrast image is applied to this region.
702    ///
703    /// Dampening Factor: This parameter is the amount of temporal dampening applied to the HEQ
704    /// (history equalization) transformation function. An IIR filter of the form::
705    ///
706    ///  (N / 256) * previous + ((256 - N) / 256) * current
707    ///
708    /// is applied, and the HEQ dampening factor
709    /// represents the value N in the equation, i.e., a value that applies to the amount of
710    /// influence the previous HEQ transformation function has on the current function. The
711    /// lower the value of N the higher the influence of the current video frame whereas
712    /// the higher the value of N the more influence the previous damped transfer function has.
713    ///
714    /// Clip Limit Index 0 (AGC HEQ Clip Limit High): This parameter defines the maximum number of pixels allowed
715    /// to accumulate in any given histogram bin. Any additional pixels in a given bin are clipped.
716    /// The effect of this parameter is to limit the influence of highly-populated bins on the
717    /// resulting HEQ transformation function.
718    ///
719    /// Clip Limit Index 1 (AGC HEQ Clip Limit Low): This parameter defines an artificial population that is added to
720    /// every non-empty histogram bin. In other words, if the Clip Limit Low is set to L, a bin
721    /// with an actual population of X will have an effective population of L + X. Any empty bin
722    /// that is nearby a populated bin will be given an artificial population of L. The effect of
723    /// higher values is to provide a more linear transfer function; lower values provide a more
724    /// non-linear (equalized) transfer function.
725    ///
726    /// Empty Counts: This parameter specifies the maximum number of pixels in a bin that will be
727    /// interpreted as an empty bin. Histogram bins with this number of pixels or less will be
728    /// processed as an empty bin.
729    pub async fn set_high_contrast_config(
730        &mut self,
731        region_of_interest: &[u8; 4],
732        dampening_factor: u16,
733        clip_limit: &[u16; 2],
734        empty_counts: u16,
735    ) -> Result<(), TinkerforgeError> {
736        let mut payload = [0; 12];
737        region_of_interest.write_to_slice(&mut payload[0..4]);
738        dampening_factor.write_to_slice(&mut payload[4..6]);
739        clip_limit.write_to_slice(&mut payload[6..10]);
740        empty_counts.write_to_slice(&mut payload[10..12]);
741
742        #[allow(unused_variables)]
743        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetHighContrastConfig), &payload).await?;
744        Ok(())
745    }
746
747    /// Returns the high contrast config as set by [`set_high_contrast_config`].
748    pub async fn get_high_contrast_config(&mut self) -> Result<HighContrastConfig, TinkerforgeError> {
749        let payload = [0; 0];
750
751        #[allow(unused_variables)]
752        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetHighContrastConfig), &payload).await?;
753        Ok(HighContrastConfig::from_le_byte_slice(result.body()))
754    }
755
756    /// The necessary bandwidth of this Bricklet is too high to use getter/receiver or
757    /// high contrast/temperature image at the same time. You have to configure the one
758    /// you want to use, the Bricklet will optimize the internal configuration accordingly.
759    ///
760    /// Corresponding functions:
761    ///
762    /// * Manual High Contrast Image: [`get_high_contrast_image`].
763    /// * Manual Temperature Image: [`get_temperature_image`].
764    /// * Receiver High Contrast Image: [`get_high_contrast_image_callback_receiver`] receiver.
765    /// * Receiver Temperature Image: [`get_temperature_image_callback_receiver`] receiver.
766    ///
767    /// Associated constants:
768    /// * THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_MANUAL_HIGH_CONTRAST_IMAGE
769    ///	* THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_MANUAL_TEMPERATURE_IMAGE
770    ///	* THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_CALLBACK_HIGH_CONTRAST_IMAGE
771    ///	* THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_CALLBACK_TEMPERATURE_IMAGE
772    pub async fn set_image_transfer_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
773        let mut payload = [0; 1];
774        config.write_to_slice(&mut payload[0..1]);
775
776        #[allow(unused_variables)]
777        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetImageTransferConfig), &payload).await?;
778        Ok(())
779    }
780
781    /// Returns the image transfer config, as set by [`set_image_transfer_config`].
782    ///
783    /// Associated constants:
784    /// * THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_MANUAL_HIGH_CONTRAST_IMAGE
785    ///	* THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_MANUAL_TEMPERATURE_IMAGE
786    ///	* THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_CALLBACK_HIGH_CONTRAST_IMAGE
787    ///	* THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_CALLBACK_TEMPERATURE_IMAGE
788    pub async fn get_image_transfer_config(&mut self) -> Result<u8, TinkerforgeError> {
789        let payload = [0; 0];
790
791        #[allow(unused_variables)]
792        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetImageTransferConfig), &payload).await?;
793        Ok(u8::from_le_byte_slice(result.body()))
794    }
795
796    /// Sets the flux linear parameters that can be used for radiometry calibration.
797    ///
798    /// See FLIR document 102-PS245-100-01 for more details.
799    ///
800    ///
801    /// .. versionadded:: 2.0.5$nbsp;(Plugin)
802    pub async fn set_flux_linear_parameters(
803        &mut self,
804        scene_emissivity: u16,
805        temperature_background: u16,
806        tau_window: u16,
807        temperatur_window: u16,
808        tau_atmosphere: u16,
809        temperature_atmosphere: u16,
810        reflection_window: u16,
811        temperature_reflection: u16,
812    ) -> Result<(), TinkerforgeError> {
813        let mut payload = [0; 16];
814        scene_emissivity.write_to_slice(&mut payload[0..2]);
815        temperature_background.write_to_slice(&mut payload[2..4]);
816        tau_window.write_to_slice(&mut payload[4..6]);
817        temperatur_window.write_to_slice(&mut payload[6..8]);
818        tau_atmosphere.write_to_slice(&mut payload[8..10]);
819        temperature_atmosphere.write_to_slice(&mut payload[10..12]);
820        reflection_window.write_to_slice(&mut payload[12..14]);
821        temperature_reflection.write_to_slice(&mut payload[14..16]);
822
823        #[allow(unused_variables)]
824        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetFluxLinearParameters), &payload).await?;
825        Ok(())
826    }
827
828    /// Returns the flux linear parameters, as set by [`set_flux_linear_parameters`].
829    ///
830    ///
831    /// .. versionadded:: 2.0.5$nbsp;(Plugin)
832    pub async fn get_flux_linear_parameters(&mut self) -> Result<FluxLinearParameters, TinkerforgeError> {
833        let payload = [0; 0];
834
835        #[allow(unused_variables)]
836        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetFluxLinearParameters), &payload).await?;
837        Ok(FluxLinearParameters::from_le_byte_slice(result.body()))
838    }
839
840    /// Sets the FFC shutter mode parameters.
841    ///
842    /// See FLIR document 110-0144-03 4.5.15 for more details.
843    ///
844    ///
845    /// .. versionadded:: 2.0.6$nbsp;(Plugin)
846    ///
847    /// Associated constants:
848    /// * THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_MANUAL
849    ///	* THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_AUTO
850    ///	* THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_EXTERNAL
851    ///	* THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_INACTIVE
852    ///	* THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_HIGH
853    ///	* THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_LOW
854    pub async fn set_ffc_shutter_mode(
855        &mut self,
856        shutter_mode: u8,
857        temp_lockout_state: u8,
858        video_freeze_during_ffc: bool,
859        ffc_desired: bool,
860        elapsed_time_since_last_ffc: u32,
861        desired_ffc_period: u32,
862        explicit_cmd_to_open: bool,
863        desired_ffc_temp_delta: u16,
864        imminent_delay: u16,
865    ) -> Result<(), TinkerforgeError> {
866        let mut payload = [0; 17];
867        shutter_mode.write_to_slice(&mut payload[0..1]);
868        temp_lockout_state.write_to_slice(&mut payload[1..2]);
869        video_freeze_during_ffc.write_to_slice(&mut payload[2..3]);
870        ffc_desired.write_to_slice(&mut payload[3..4]);
871        elapsed_time_since_last_ffc.write_to_slice(&mut payload[4..8]);
872        desired_ffc_period.write_to_slice(&mut payload[8..12]);
873        explicit_cmd_to_open.write_to_slice(&mut payload[12..13]);
874        desired_ffc_temp_delta.write_to_slice(&mut payload[13..15]);
875        imminent_delay.write_to_slice(&mut payload[15..17]);
876
877        #[allow(unused_variables)]
878        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetFfcShutterMode), &payload).await?;
879        Ok(())
880    }
881
882    /// Sets the FFC shutter mode parameters.
883    ///
884    /// See FLIR document 110-0144-03 4.5.15 for more details.
885    ///
886    ///
887    /// .. versionadded:: 2.0.6$nbsp;(Plugin)
888    ///
889    /// Associated constants:
890    /// * THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_MANUAL
891    ///	* THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_AUTO
892    ///	* THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_EXTERNAL
893    ///	* THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_INACTIVE
894    ///	* THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_HIGH
895    ///	* THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_LOW
896    pub async fn get_ffc_shutter_mode(&mut self) -> Result<FfcShutterMode, TinkerforgeError> {
897        let payload = [0; 0];
898
899        #[allow(unused_variables)]
900        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetFfcShutterMode), &payload).await?;
901        Ok(FfcShutterMode::from_le_byte_slice(result.body()))
902    }
903
904    /// Starts the Flat-Field Correction (FFC) normalization.
905    ///
906    /// See FLIR document 110-0144-03 4.5.16 for more details.
907    ///
908    ///
909    /// .. versionadded:: 2.0.6$nbsp;(Plugin)
910    pub async fn run_ffc_normalization(&mut self) -> Result<(), TinkerforgeError> {
911        let payload = [0; 0];
912
913        #[allow(unused_variables)]
914        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::RunFfcNormalization), &payload).await?;
915        Ok(())
916    }
917
918    /// Returns the error count for the communication between Brick and Bricklet.
919    ///
920    /// The errors are divided into
921    ///
922    /// * ACK checksum errors,
923    /// * message checksum errors,
924    /// * framing errors and
925    /// * overflow errors.
926    ///
927    /// The errors counts are for errors that occur on the Bricklet side. All
928    /// Bricks have a similar function that returns the errors on the Brick side.
929    pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
930        let payload = [0; 0];
931
932        #[allow(unused_variables)]
933        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetSpitfpErrorCount), &payload).await?;
934        Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
935    }
936
937    /// Sets the bootloader mode and returns the status after the requested
938    /// mode change was instigated.
939    ///
940    /// You can change from bootloader mode to firmware mode and vice versa. A change
941    /// from bootloader mode to firmware mode will only take place if the entry function,
942    /// device identifier and CRC are present and correct.
943    ///
944    /// This function is used by Brick Viewer during flashing. It should not be
945    /// necessary to call it in a normal user program.
946    ///
947    /// Associated constants:
948    /// * THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
949    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE
950    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
951    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
952    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
953    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_OK
954    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE
955    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE
956    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT
957    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT
958    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH
959    pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
960        let mut payload = [0; 1];
961        mode.write_to_slice(&mut payload[0..1]);
962
963        #[allow(unused_variables)]
964        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::SetBootloaderMode), &payload).await?;
965        Ok(u8::from_le_byte_slice(result.body()))
966    }
967
968    /// Returns the current bootloader mode, see [`set_bootloader_mode`].
969    ///
970    /// Associated constants:
971    /// * THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
972    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE
973    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
974    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
975    ///	* THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
976    pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
977        let payload = [0; 0];
978
979        #[allow(unused_variables)]
980        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetBootloaderMode), &payload).await?;
981        Ok(u8::from_le_byte_slice(result.body()))
982    }
983
984    /// Sets the firmware pointer for [`write_firmware`]. The pointer has
985    /// to be increased by chunks of size 64. The data is written to flash
986    /// every 4 chunks (which equals to one page of size 256).
987    ///
988    /// This function is used by Brick Viewer during flashing. It should not be
989    /// necessary to call it in a normal user program.
990    pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
991        let mut payload = [0; 4];
992        pointer.write_to_slice(&mut payload[0..4]);
993
994        #[allow(unused_variables)]
995        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetWriteFirmwarePointer), &payload).await?;
996        Ok(())
997    }
998
999    /// Writes 64 Bytes of firmware at the position as written by
1000    /// [`set_write_firmware_pointer`] before. The firmware is written
1001    /// to flash every 4 chunks.
1002    ///
1003    /// You can only write firmware in bootloader mode.
1004    ///
1005    /// This function is used by Brick Viewer during flashing. It should not be
1006    /// necessary to call it in a normal user program.
1007    pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
1008        let mut payload = [0; 64];
1009        data.write_to_slice(&mut payload[0..64]);
1010
1011        #[allow(unused_variables)]
1012        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::WriteFirmware), &payload).await?;
1013        Ok(u8::from_le_byte_slice(result.body()))
1014    }
1015
1016    /// Sets the status LED configuration. By default the LED shows
1017    /// communication traffic between Brick and Bricklet, it flickers once
1018    /// for every 10 received data packets.
1019    ///
1020    /// You can also turn the LED permanently on/off or show a heartbeat.
1021    ///
1022    /// If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
1023    ///
1024    /// Associated constants:
1025    /// * THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_OFF
1026    ///	* THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_ON
1027    ///	* THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
1028    ///	* THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
1029    pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
1030        let mut payload = [0; 1];
1031        config.write_to_slice(&mut payload[0..1]);
1032
1033        #[allow(unused_variables)]
1034        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetStatusLedConfig), &payload).await?;
1035        Ok(())
1036    }
1037
1038    /// Returns the configuration as set by [`set_status_led_config`]
1039    ///
1040    /// Associated constants:
1041    /// * THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_OFF
1042    ///	* THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_ON
1043    ///	* THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
1044    ///	* THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
1045    pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
1046        let payload = [0; 0];
1047
1048        #[allow(unused_variables)]
1049        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetStatusLedConfig), &payload).await?;
1050        Ok(u8::from_le_byte_slice(result.body()))
1051    }
1052
1053    /// Returns the temperature as measured inside the microcontroller. The
1054    /// value returned is not the ambient temperature!
1055    ///
1056    /// The temperature is only proportional to the real temperature and it has bad
1057    /// accuracy. Practically it is only useful as an indicator for
1058    /// temperature changes.
1059    pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
1060        let payload = [0; 0];
1061
1062        #[allow(unused_variables)]
1063        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetChipTemperature), &payload).await?;
1064        Ok(i16::from_le_byte_slice(result.body()))
1065    }
1066
1067    /// Calling this function will reset the Bricklet. All configurations
1068    /// will be lost.
1069    ///
1070    /// After a reset you have to create new device objects,
1071    /// calling functions on the existing ones will result in
1072    /// undefined behavior!
1073    pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
1074        let payload = [0; 0];
1075
1076        #[allow(unused_variables)]
1077        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::Reset), &payload).await?;
1078        Ok(())
1079    }
1080
1081    /// Writes a new UID into flash. If you want to set a new UID
1082    /// you have to decode the Base58 encoded UID string into an
1083    /// integer first.
1084    ///
1085    /// We recommend that you use Brick Viewer to change the UID.
1086    pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
1087        let mut payload = [0; 4];
1088        uid.write_to_slice(&mut payload[0..4]);
1089
1090        #[allow(unused_variables)]
1091        let result = self.device.set(u8::from(ThermalImagingBrickletFunction::WriteUid), &payload).await?;
1092        Ok(())
1093    }
1094
1095    /// Returns the current UID as an integer. Encode as
1096    /// Base58 to get the usual string version.
1097    pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
1098        let payload = [0; 0];
1099
1100        #[allow(unused_variables)]
1101        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::ReadUid), &payload).await?;
1102        Ok(u32::from_le_byte_slice(result.body()))
1103    }
1104
1105    /// Returns the UID, the UID where the Bricklet is connected to,
1106    /// the position, the hardware and firmware version as well as the
1107    /// device identifier.
1108    ///
1109    /// The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
1110    /// A Bricklet connected to an [Isolator Bricklet](isolator_bricklet) is always at
1111    /// position 'z'.
1112    ///
1113    /// The device identifier numbers can be found [here](device_identifier).
1114    /// |device_identifier_constant|
1115    pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
1116        let payload = [0; 0];
1117
1118        #[allow(unused_variables)]
1119        let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetIdentity), &payload).await?;
1120        Ok(Identity::from_le_byte_slice(result.body()))
1121    }
1122}