#[allow(unused_imports)]
use crate::{
byte_converter::*, converting_high_level_callback_receiver::ConvertingHighLevelCallbackReceiver,
converting_receiver::BrickletRecvTimeoutError, device::*, error::TinkerforgeError, ip_connection::async_io::AsyncIpConnection,
low_level_traits::LowLevelRead,
};
#[allow(unused_imports)]
use futures_core::Stream;
#[allow(unused_imports)]
use tokio_stream::StreamExt;
pub enum ThermalImagingBrickletFunction {
GetHighContrastImageLowLevel,
GetTemperatureImageLowLevel,
GetStatistics,
SetResolution,
GetResolution,
SetSpotmeterConfig,
GetSpotmeterConfig,
SetHighContrastConfig,
GetHighContrastConfig,
SetImageTransferConfig,
GetImageTransferConfig,
SetFluxLinearParameters,
GetFluxLinearParameters,
SetFfcShutterMode,
GetFfcShutterMode,
RunFfcNormalization,
GetSpitfpErrorCount,
SetBootloaderMode,
GetBootloaderMode,
SetWriteFirmwarePointer,
WriteFirmware,
SetStatusLedConfig,
GetStatusLedConfig,
GetChipTemperature,
Reset,
WriteUid,
ReadUid,
GetIdentity,
CallbackHighContrastImageLowLevel,
CallbackTemperatureImageLowLevel,
}
impl From<ThermalImagingBrickletFunction> for u8 {
fn from(fun: ThermalImagingBrickletFunction) -> Self {
match fun {
ThermalImagingBrickletFunction::GetHighContrastImageLowLevel => 1,
ThermalImagingBrickletFunction::GetTemperatureImageLowLevel => 2,
ThermalImagingBrickletFunction::GetStatistics => 3,
ThermalImagingBrickletFunction::SetResolution => 4,
ThermalImagingBrickletFunction::GetResolution => 5,
ThermalImagingBrickletFunction::SetSpotmeterConfig => 6,
ThermalImagingBrickletFunction::GetSpotmeterConfig => 7,
ThermalImagingBrickletFunction::SetHighContrastConfig => 8,
ThermalImagingBrickletFunction::GetHighContrastConfig => 9,
ThermalImagingBrickletFunction::SetImageTransferConfig => 10,
ThermalImagingBrickletFunction::GetImageTransferConfig => 11,
ThermalImagingBrickletFunction::SetFluxLinearParameters => 14,
ThermalImagingBrickletFunction::GetFluxLinearParameters => 15,
ThermalImagingBrickletFunction::SetFfcShutterMode => 16,
ThermalImagingBrickletFunction::GetFfcShutterMode => 17,
ThermalImagingBrickletFunction::RunFfcNormalization => 18,
ThermalImagingBrickletFunction::GetSpitfpErrorCount => 234,
ThermalImagingBrickletFunction::SetBootloaderMode => 235,
ThermalImagingBrickletFunction::GetBootloaderMode => 236,
ThermalImagingBrickletFunction::SetWriteFirmwarePointer => 237,
ThermalImagingBrickletFunction::WriteFirmware => 238,
ThermalImagingBrickletFunction::SetStatusLedConfig => 239,
ThermalImagingBrickletFunction::GetStatusLedConfig => 240,
ThermalImagingBrickletFunction::GetChipTemperature => 242,
ThermalImagingBrickletFunction::Reset => 243,
ThermalImagingBrickletFunction::WriteUid => 248,
ThermalImagingBrickletFunction::ReadUid => 249,
ThermalImagingBrickletFunction::GetIdentity => 255,
ThermalImagingBrickletFunction::CallbackHighContrastImageLowLevel => 12,
ThermalImagingBrickletFunction::CallbackTemperatureImageLowLevel => 13,
}
}
}
pub const THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_6553_KELVIN: u8 = 0;
pub const THERMAL_IMAGING_BRICKLET_RESOLUTION_0_TO_655_KELVIN: u8 = 1;
pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_NEVER_COMMANDED: u8 = 0;
pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_IMMINENT: u8 = 1;
pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_IN_PROGRESS: u8 = 2;
pub const THERMAL_IMAGING_BRICKLET_FFC_STATUS_COMPLETE: u8 = 3;
pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_MANUAL_HIGH_CONTRAST_IMAGE: u8 = 0;
pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_MANUAL_TEMPERATURE_IMAGE: u8 = 1;
pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_CALLBACK_HIGH_CONTRAST_IMAGE: u8 = 2;
pub const THERMAL_IMAGING_BRICKLET_IMAGE_TRANSFER_CALLBACK_TEMPERATURE_IMAGE: u8 = 3;
pub const THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_MANUAL: u8 = 0;
pub const THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_AUTO: u8 = 1;
pub const THERMAL_IMAGING_BRICKLET_SHUTTER_MODE_EXTERNAL: u8 = 2;
pub const THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_INACTIVE: u8 = 0;
pub const THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_HIGH: u8 = 1;
pub const THERMAL_IMAGING_BRICKLET_SHUTTER_LOCKOUT_LOW: u8 = 2;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
pub const THERMAL_IMAGING_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
pub const THERMAL_IMAGING_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
#[derive(Clone, Copy)]
pub struct HighContrastImageLowLevel {
pub image_chunk_offset: u16,
pub image_chunk_data: [u8; 62],
}
impl FromByteSlice for HighContrastImageLowLevel {
fn bytes_expected() -> usize {
64
}
fn from_le_byte_slice(bytes: &[u8]) -> HighContrastImageLowLevel {
HighContrastImageLowLevel {
image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
image_chunk_data: <[u8; 62]>::from_le_byte_slice(&bytes[2..64]),
}
}
}
impl LowLevelRead<u8, HighContrastImageResult> for HighContrastImageLowLevel {
fn ll_message_length(&self) -> usize {
4800
}
fn ll_message_chunk_offset(&self) -> usize {
self.image_chunk_offset as usize
}
fn ll_message_chunk_data(&self) -> &[u8] {
&self.image_chunk_data
}
fn get_result(&self) -> HighContrastImageResult {
HighContrastImageResult {}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct TemperatureImageLowLevel {
pub image_chunk_offset: u16,
pub image_chunk_data: [u16; 31],
}
impl FromByteSlice for TemperatureImageLowLevel {
fn bytes_expected() -> usize {
64
}
fn from_le_byte_slice(bytes: &[u8]) -> TemperatureImageLowLevel {
TemperatureImageLowLevel {
image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
image_chunk_data: <[u16; 31]>::from_le_byte_slice(&bytes[2..64]),
}
}
}
impl LowLevelRead<u16, TemperatureImageResult> for TemperatureImageLowLevel {
fn ll_message_length(&self) -> usize {
4800
}
fn ll_message_chunk_offset(&self) -> usize {
self.image_chunk_offset as usize
}
fn ll_message_chunk_data(&self) -> &[u16] {
&self.image_chunk_data
}
fn get_result(&self) -> TemperatureImageResult {
TemperatureImageResult {}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Statistics {
pub spotmeter_statistics: [u16; 4],
pub temperatures: [u16; 4],
pub resolution: u8,
pub ffc_status: u8,
pub temperature_warning: [bool; 2],
}
impl FromByteSlice for Statistics {
fn bytes_expected() -> usize {
19
}
fn from_le_byte_slice(bytes: &[u8]) -> Statistics {
Statistics {
spotmeter_statistics: <[u16; 4]>::from_le_byte_slice(&bytes[0..8]),
temperatures: <[u16; 4]>::from_le_byte_slice(&bytes[8..16]),
resolution: <u8>::from_le_byte_slice(&bytes[16..17]),
ffc_status: <u8>::from_le_byte_slice(&bytes[17..18]),
temperature_warning: <[bool; 2]>::from_le_byte_slice(&bytes[18..19]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct HighContrastConfig {
pub region_of_interest: [u8; 4],
pub dampening_factor: u16,
pub clip_limit: [u16; 2],
pub empty_counts: u16,
}
impl FromByteSlice for HighContrastConfig {
fn bytes_expected() -> usize {
12
}
fn from_le_byte_slice(bytes: &[u8]) -> HighContrastConfig {
HighContrastConfig {
region_of_interest: <[u8; 4]>::from_le_byte_slice(&bytes[0..4]),
dampening_factor: <u16>::from_le_byte_slice(&bytes[4..6]),
clip_limit: <[u16; 2]>::from_le_byte_slice(&bytes[6..10]),
empty_counts: <u16>::from_le_byte_slice(&bytes[10..12]),
}
}
}
#[derive(Clone, Copy)]
pub struct HighContrastImageLowLevelEvent {
pub image_chunk_offset: u16,
pub image_chunk_data: [u8; 62],
}
impl FromByteSlice for HighContrastImageLowLevelEvent {
fn bytes_expected() -> usize {
64
}
fn from_le_byte_slice(bytes: &[u8]) -> HighContrastImageLowLevelEvent {
HighContrastImageLowLevelEvent {
image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
image_chunk_data: <[u8; 62]>::from_le_byte_slice(&bytes[2..64]),
}
}
}
impl LowLevelRead<u8, HighContrastImageResult> for HighContrastImageLowLevelEvent {
fn ll_message_length(&self) -> usize {
4800
}
fn ll_message_chunk_offset(&self) -> usize {
self.image_chunk_offset as usize
}
fn ll_message_chunk_data(&self) -> &[u8] {
&self.image_chunk_data
}
fn get_result(&self) -> HighContrastImageResult {
HighContrastImageResult {}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct TemperatureImageLowLevelEvent {
pub image_chunk_offset: u16,
pub image_chunk_data: [u16; 31],
}
impl FromByteSlice for TemperatureImageLowLevelEvent {
fn bytes_expected() -> usize {
64
}
fn from_le_byte_slice(bytes: &[u8]) -> TemperatureImageLowLevelEvent {
TemperatureImageLowLevelEvent {
image_chunk_offset: <u16>::from_le_byte_slice(&bytes[0..2]),
image_chunk_data: <[u16; 31]>::from_le_byte_slice(&bytes[2..64]),
}
}
}
impl LowLevelRead<u16, TemperatureImageResult> for TemperatureImageLowLevelEvent {
fn ll_message_length(&self) -> usize {
4800
}
fn ll_message_chunk_offset(&self) -> usize {
self.image_chunk_offset as usize
}
fn ll_message_chunk_data(&self) -> &[u16] {
&self.image_chunk_data
}
fn get_result(&self) -> TemperatureImageResult {
TemperatureImageResult {}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct FluxLinearParameters {
pub scene_emissivity: u16,
pub temperature_background: u16,
pub tau_window: u16,
pub temperatur_window: u16,
pub tau_atmosphere: u16,
pub temperature_atmosphere: u16,
pub reflection_window: u16,
pub temperature_reflection: u16,
}
impl FromByteSlice for FluxLinearParameters {
fn bytes_expected() -> usize {
16
}
fn from_le_byte_slice(bytes: &[u8]) -> FluxLinearParameters {
FluxLinearParameters {
scene_emissivity: <u16>::from_le_byte_slice(&bytes[0..2]),
temperature_background: <u16>::from_le_byte_slice(&bytes[2..4]),
tau_window: <u16>::from_le_byte_slice(&bytes[4..6]),
temperatur_window: <u16>::from_le_byte_slice(&bytes[6..8]),
tau_atmosphere: <u16>::from_le_byte_slice(&bytes[8..10]),
temperature_atmosphere: <u16>::from_le_byte_slice(&bytes[10..12]),
reflection_window: <u16>::from_le_byte_slice(&bytes[12..14]),
temperature_reflection: <u16>::from_le_byte_slice(&bytes[14..16]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct FfcShutterMode {
pub shutter_mode: u8,
pub temp_lockout_state: u8,
pub video_freeze_during_ffc: bool,
pub ffc_desired: bool,
pub elapsed_time_since_last_ffc: u32,
pub desired_ffc_period: u32,
pub explicit_cmd_to_open: bool,
pub desired_ffc_temp_delta: u16,
pub imminent_delay: u16,
}
impl FromByteSlice for FfcShutterMode {
fn bytes_expected() -> usize {
17
}
fn from_le_byte_slice(bytes: &[u8]) -> FfcShutterMode {
FfcShutterMode {
shutter_mode: <u8>::from_le_byte_slice(&bytes[0..1]),
temp_lockout_state: <u8>::from_le_byte_slice(&bytes[1..2]),
video_freeze_during_ffc: <bool>::from_le_byte_slice(&bytes[2..3]),
ffc_desired: <bool>::from_le_byte_slice(&bytes[3..4]),
elapsed_time_since_last_ffc: <u32>::from_le_byte_slice(&bytes[4..8]),
desired_ffc_period: <u32>::from_le_byte_slice(&bytes[8..12]),
explicit_cmd_to_open: <bool>::from_le_byte_slice(&bytes[12..13]),
desired_ffc_temp_delta: <u16>::from_le_byte_slice(&bytes[13..15]),
imminent_delay: <u16>::from_le_byte_slice(&bytes[15..17]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct SpitfpErrorCount {
pub error_count_ack_checksum: u32,
pub error_count_message_checksum: u32,
pub error_count_frame: u32,
pub error_count_overflow: u32,
}
impl FromByteSlice for SpitfpErrorCount {
fn bytes_expected() -> usize {
16
}
fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
SpitfpErrorCount {
error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
}
}
}
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct Identity {
pub uid: String,
pub connected_uid: String,
pub position: char,
pub hardware_version: [u8; 3],
pub firmware_version: [u8; 3],
pub device_identifier: u16,
}
impl FromByteSlice for Identity {
fn bytes_expected() -> usize {
25
}
fn from_le_byte_slice(bytes: &[u8]) -> Identity {
Identity {
uid: <String>::from_le_byte_slice(&bytes[0..8]),
connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
position: <char>::from_le_byte_slice(&bytes[16..17]),
hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct HighContrastImageResult {}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct TemperatureImageResult {}
#[derive(Clone)]
pub struct ThermalImagingBricklet {
device: Device,
}
impl ThermalImagingBricklet {
pub const DEVICE_IDENTIFIER: u16 = 278;
pub const DEVICE_DISPLAY_NAME: &'static str = "Thermal Imaging Bricklet";
pub fn new(uid: &str, connection: AsyncIpConnection) -> ThermalImagingBricklet {
let mut result = ThermalImagingBricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetHighContrastImageLowLevel) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetTemperatureImageLowLevel) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetStatistics) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetResolution) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetResolution) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetSpotmeterConfig) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetSpotmeterConfig) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetHighContrastConfig) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetHighContrastConfig) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetImageTransferConfig) as usize] =
ResponseExpectedFlag::True;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetImageTransferConfig) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetFluxLinearParameters) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetFluxLinearParameters) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetFfcShutterMode) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetFfcShutterMode) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::RunFfcNormalization) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetSpitfpErrorCount) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetBootloaderMode) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetBootloaderMode) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetWriteFirmwarePointer) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::WriteFirmware) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::SetStatusLedConfig) as usize] =
ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetStatusLedConfig) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetChipTemperature) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ThermalImagingBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
result
}
pub fn get_response_expected(&mut self, fun: ThermalImagingBrickletFunction) -> Result<bool, GetResponseExpectedError> {
self.device.get_response_expected(u8::from(fun))
}
pub fn set_response_expected(
&mut self,
fun: ThermalImagingBrickletFunction,
response_expected: bool,
) -> Result<(), SetResponseExpectedError> {
self.device.set_response_expected(u8::from(fun), response_expected)
}
pub fn set_response_expected_all(&mut self, response_expected: bool) {
self.device.set_response_expected_all(response_expected)
}
pub fn get_api_version(&self) -> [u8; 3] {
self.device.api_version
}
pub async fn get_high_contrast_image_low_level_callback_receiver(&mut self) -> impl Stream<Item = HighContrastImageLowLevelEvent> {
self.device
.get_callback_receiver(u8::from(ThermalImagingBrickletFunction::CallbackHighContrastImageLowLevel))
.await
.map(|p| HighContrastImageLowLevelEvent::from_le_byte_slice(p.body()))
}
pub async fn get_temperature_image_low_level_callback_receiver(&mut self) -> impl Stream<Item = TemperatureImageLowLevelEvent> {
self.device
.get_callback_receiver(u8::from(ThermalImagingBrickletFunction::CallbackTemperatureImageLowLevel))
.await
.map(|p| TemperatureImageLowLevelEvent::from_le_byte_slice(p.body()))
}
pub async fn get_high_contrast_image_low_level(&mut self) -> Result<HighContrastImageLowLevel, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetHighContrastImageLowLevel), &payload).await?;
Ok(HighContrastImageLowLevel::from_le_byte_slice(result.body()))
}
pub async fn get_temperature_image_low_level(&mut self) -> Result<TemperatureImageLowLevel, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetTemperatureImageLowLevel), &payload).await?;
Ok(TemperatureImageLowLevel::from_le_byte_slice(result.body()))
}
pub async fn get_statistics(&mut self) -> Result<Statistics, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetStatistics), &payload).await?;
Ok(Statistics::from_le_byte_slice(result.body()))
}
pub async fn set_resolution(&mut self, resolution: u8) -> Result<(), TinkerforgeError> {
let mut payload = [0; 1];
resolution.write_to_slice(&mut payload[0..1]);
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetResolution), &payload).await?;
Ok(())
}
pub async fn get_resolution(&mut self) -> Result<u8, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetResolution), &payload).await?;
Ok(u8::from_le_byte_slice(result.body()))
}
pub async fn set_spotmeter_config(&mut self, region_of_interest: &[u8; 4]) -> Result<(), TinkerforgeError> {
let mut payload = [0; 4];
region_of_interest.write_to_slice(&mut payload[0..4]);
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetSpotmeterConfig), &payload).await?;
Ok(())
}
pub async fn get_spotmeter_config(&mut self) -> Result<Box<[u8; 4]>, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetSpotmeterConfig), &payload).await?;
Ok(Box::<[u8; 4]>::from_le_byte_slice(result.body()))
}
pub async fn set_high_contrast_config(
&mut self,
region_of_interest: &[u8; 4],
dampening_factor: u16,
clip_limit: &[u16; 2],
empty_counts: u16,
) -> Result<(), TinkerforgeError> {
let mut payload = [0; 12];
region_of_interest.write_to_slice(&mut payload[0..4]);
dampening_factor.write_to_slice(&mut payload[4..6]);
clip_limit.write_to_slice(&mut payload[6..10]);
empty_counts.write_to_slice(&mut payload[10..12]);
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetHighContrastConfig), &payload).await?;
Ok(())
}
pub async fn get_high_contrast_config(&mut self) -> Result<HighContrastConfig, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetHighContrastConfig), &payload).await?;
Ok(HighContrastConfig::from_le_byte_slice(result.body()))
}
pub async fn set_image_transfer_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
let mut payload = [0; 1];
config.write_to_slice(&mut payload[0..1]);
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetImageTransferConfig), &payload).await?;
Ok(())
}
pub async fn get_image_transfer_config(&mut self) -> Result<u8, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetImageTransferConfig), &payload).await?;
Ok(u8::from_le_byte_slice(result.body()))
}
pub async fn set_flux_linear_parameters(
&mut self,
scene_emissivity: u16,
temperature_background: u16,
tau_window: u16,
temperatur_window: u16,
tau_atmosphere: u16,
temperature_atmosphere: u16,
reflection_window: u16,
temperature_reflection: u16,
) -> Result<(), TinkerforgeError> {
let mut payload = [0; 16];
scene_emissivity.write_to_slice(&mut payload[0..2]);
temperature_background.write_to_slice(&mut payload[2..4]);
tau_window.write_to_slice(&mut payload[4..6]);
temperatur_window.write_to_slice(&mut payload[6..8]);
tau_atmosphere.write_to_slice(&mut payload[8..10]);
temperature_atmosphere.write_to_slice(&mut payload[10..12]);
reflection_window.write_to_slice(&mut payload[12..14]);
temperature_reflection.write_to_slice(&mut payload[14..16]);
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetFluxLinearParameters), &payload).await?;
Ok(())
}
pub async fn get_flux_linear_parameters(&mut self) -> Result<FluxLinearParameters, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetFluxLinearParameters), &payload).await?;
Ok(FluxLinearParameters::from_le_byte_slice(result.body()))
}
pub async fn set_ffc_shutter_mode(
&mut self,
shutter_mode: u8,
temp_lockout_state: u8,
video_freeze_during_ffc: bool,
ffc_desired: bool,
elapsed_time_since_last_ffc: u32,
desired_ffc_period: u32,
explicit_cmd_to_open: bool,
desired_ffc_temp_delta: u16,
imminent_delay: u16,
) -> Result<(), TinkerforgeError> {
let mut payload = [0; 17];
shutter_mode.write_to_slice(&mut payload[0..1]);
temp_lockout_state.write_to_slice(&mut payload[1..2]);
video_freeze_during_ffc.write_to_slice(&mut payload[2..3]);
ffc_desired.write_to_slice(&mut payload[3..4]);
elapsed_time_since_last_ffc.write_to_slice(&mut payload[4..8]);
desired_ffc_period.write_to_slice(&mut payload[8..12]);
explicit_cmd_to_open.write_to_slice(&mut payload[12..13]);
desired_ffc_temp_delta.write_to_slice(&mut payload[13..15]);
imminent_delay.write_to_slice(&mut payload[15..17]);
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetFfcShutterMode), &payload).await?;
Ok(())
}
pub async fn get_ffc_shutter_mode(&mut self) -> Result<FfcShutterMode, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetFfcShutterMode), &payload).await?;
Ok(FfcShutterMode::from_le_byte_slice(result.body()))
}
pub async fn run_ffc_normalization(&mut self) -> Result<(), TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::RunFfcNormalization), &payload).await?;
Ok(())
}
pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetSpitfpErrorCount), &payload).await?;
Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
}
pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
let mut payload = [0; 1];
mode.write_to_slice(&mut payload[0..1]);
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::SetBootloaderMode), &payload).await?;
Ok(u8::from_le_byte_slice(result.body()))
}
pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetBootloaderMode), &payload).await?;
Ok(u8::from_le_byte_slice(result.body()))
}
pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
let mut payload = [0; 4];
pointer.write_to_slice(&mut payload[0..4]);
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetWriteFirmwarePointer), &payload).await?;
Ok(())
}
pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
let mut payload = [0; 64];
data.write_to_slice(&mut payload[0..64]);
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::WriteFirmware), &payload).await?;
Ok(u8::from_le_byte_slice(result.body()))
}
pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
let mut payload = [0; 1];
config.write_to_slice(&mut payload[0..1]);
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::SetStatusLedConfig), &payload).await?;
Ok(())
}
pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetStatusLedConfig), &payload).await?;
Ok(u8::from_le_byte_slice(result.body()))
}
pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetChipTemperature), &payload).await?;
Ok(i16::from_le_byte_slice(result.body()))
}
pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::Reset), &payload).await?;
Ok(())
}
pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
let mut payload = [0; 4];
uid.write_to_slice(&mut payload[0..4]);
#[allow(unused_variables)]
let result = self.device.set(u8::from(ThermalImagingBrickletFunction::WriteUid), &payload).await?;
Ok(())
}
pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::ReadUid), &payload).await?;
Ok(u32::from_le_byte_slice(result.body()))
}
pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
let payload = [0; 0];
#[allow(unused_variables)]
let result = self.device.get(u8::from(ThermalImagingBrickletFunction::GetIdentity), &payload).await?;
Ok(Identity::from_le_byte_slice(result.body()))
}
}