use crate::{
byte_converter::*, converting_callback_receiver::ConvertingCallbackReceiver, converting_receiver::ConvertingReceiver, device::*,
ip_connection::GetRequestSender,
};
pub enum ImuV3BrickletFunction {
GetAcceleration,
GetMagneticField,
GetAngularVelocity,
GetTemperature,
GetOrientation,
GetLinearAcceleration,
GetGravityVector,
GetQuaternion,
GetAllData,
SaveCalibration,
SetSensorConfiguration,
GetSensorConfiguration,
SetSensorFusionMode,
GetSensorFusionMode,
SetAccelerationCallbackConfiguration,
GetAccelerationCallbackConfiguration,
SetMagneticFieldCallbackConfiguration,
GetMagneticFieldCallbackConfiguration,
SetAngularVelocityCallbackConfiguration,
GetAngularVelocityCallbackConfiguration,
SetTemperatureCallbackConfiguration,
GetTemperatureCallbackConfiguration,
SetOrientationCallbackConfiguration,
GetOrientationCallbackConfiguration,
SetLinearAccelerationCallbackConfiguration,
GetLinearAccelerationCallbackConfiguration,
SetGravityVectorCallbackConfiguration,
GetGravityVectorCallbackConfiguration,
SetQuaternionCallbackConfiguration,
GetQuaternionCallbackConfiguration,
SetAllDataCallbackConfiguration,
GetAllDataCallbackConfiguration,
GetSpitfpErrorCount,
SetBootloaderMode,
GetBootloaderMode,
SetWriteFirmwarePointer,
WriteFirmware,
SetStatusLedConfig,
GetStatusLedConfig,
GetChipTemperature,
Reset,
WriteUid,
ReadUid,
GetIdentity,
CallbackAcceleration,
CallbackMagneticField,
CallbackAngularVelocity,
CallbackTemperature,
CallbackLinearAcceleration,
CallbackGravityVector,
CallbackOrientation,
CallbackQuaternion,
CallbackAllData,
}
impl From<ImuV3BrickletFunction> for u8 {
fn from(fun: ImuV3BrickletFunction) -> Self {
match fun {
ImuV3BrickletFunction::GetAcceleration => 1,
ImuV3BrickletFunction::GetMagneticField => 2,
ImuV3BrickletFunction::GetAngularVelocity => 3,
ImuV3BrickletFunction::GetTemperature => 4,
ImuV3BrickletFunction::GetOrientation => 5,
ImuV3BrickletFunction::GetLinearAcceleration => 6,
ImuV3BrickletFunction::GetGravityVector => 7,
ImuV3BrickletFunction::GetQuaternion => 8,
ImuV3BrickletFunction::GetAllData => 9,
ImuV3BrickletFunction::SaveCalibration => 10,
ImuV3BrickletFunction::SetSensorConfiguration => 11,
ImuV3BrickletFunction::GetSensorConfiguration => 12,
ImuV3BrickletFunction::SetSensorFusionMode => 13,
ImuV3BrickletFunction::GetSensorFusionMode => 14,
ImuV3BrickletFunction::SetAccelerationCallbackConfiguration => 15,
ImuV3BrickletFunction::GetAccelerationCallbackConfiguration => 16,
ImuV3BrickletFunction::SetMagneticFieldCallbackConfiguration => 17,
ImuV3BrickletFunction::GetMagneticFieldCallbackConfiguration => 18,
ImuV3BrickletFunction::SetAngularVelocityCallbackConfiguration => 19,
ImuV3BrickletFunction::GetAngularVelocityCallbackConfiguration => 20,
ImuV3BrickletFunction::SetTemperatureCallbackConfiguration => 21,
ImuV3BrickletFunction::GetTemperatureCallbackConfiguration => 22,
ImuV3BrickletFunction::SetOrientationCallbackConfiguration => 23,
ImuV3BrickletFunction::GetOrientationCallbackConfiguration => 24,
ImuV3BrickletFunction::SetLinearAccelerationCallbackConfiguration => 25,
ImuV3BrickletFunction::GetLinearAccelerationCallbackConfiguration => 26,
ImuV3BrickletFunction::SetGravityVectorCallbackConfiguration => 27,
ImuV3BrickletFunction::GetGravityVectorCallbackConfiguration => 28,
ImuV3BrickletFunction::SetQuaternionCallbackConfiguration => 29,
ImuV3BrickletFunction::GetQuaternionCallbackConfiguration => 30,
ImuV3BrickletFunction::SetAllDataCallbackConfiguration => 31,
ImuV3BrickletFunction::GetAllDataCallbackConfiguration => 32,
ImuV3BrickletFunction::GetSpitfpErrorCount => 234,
ImuV3BrickletFunction::SetBootloaderMode => 235,
ImuV3BrickletFunction::GetBootloaderMode => 236,
ImuV3BrickletFunction::SetWriteFirmwarePointer => 237,
ImuV3BrickletFunction::WriteFirmware => 238,
ImuV3BrickletFunction::SetStatusLedConfig => 239,
ImuV3BrickletFunction::GetStatusLedConfig => 240,
ImuV3BrickletFunction::GetChipTemperature => 242,
ImuV3BrickletFunction::Reset => 243,
ImuV3BrickletFunction::WriteUid => 248,
ImuV3BrickletFunction::ReadUid => 249,
ImuV3BrickletFunction::GetIdentity => 255,
ImuV3BrickletFunction::CallbackAcceleration => 33,
ImuV3BrickletFunction::CallbackMagneticField => 34,
ImuV3BrickletFunction::CallbackAngularVelocity => 35,
ImuV3BrickletFunction::CallbackTemperature => 36,
ImuV3BrickletFunction::CallbackLinearAcceleration => 37,
ImuV3BrickletFunction::CallbackGravityVector => 38,
ImuV3BrickletFunction::CallbackOrientation => 39,
ImuV3BrickletFunction::CallbackQuaternion => 40,
ImuV3BrickletFunction::CallbackAllData => 41,
}
}
}
pub const IMU_V3_BRICKLET_MAGNETOMETER_RATE_2HZ: u8 = 0;
pub const IMU_V3_BRICKLET_MAGNETOMETER_RATE_6HZ: u8 = 1;
pub const IMU_V3_BRICKLET_MAGNETOMETER_RATE_8HZ: u8 = 2;
pub const IMU_V3_BRICKLET_MAGNETOMETER_RATE_10HZ: u8 = 3;
pub const IMU_V3_BRICKLET_MAGNETOMETER_RATE_15HZ: u8 = 4;
pub const IMU_V3_BRICKLET_MAGNETOMETER_RATE_20HZ: u8 = 5;
pub const IMU_V3_BRICKLET_MAGNETOMETER_RATE_25HZ: u8 = 6;
pub const IMU_V3_BRICKLET_MAGNETOMETER_RATE_30HZ: u8 = 7;
pub const IMU_V3_BRICKLET_GYROSCOPE_RANGE_2000DPS: u8 = 0;
pub const IMU_V3_BRICKLET_GYROSCOPE_RANGE_1000DPS: u8 = 1;
pub const IMU_V3_BRICKLET_GYROSCOPE_RANGE_500DPS: u8 = 2;
pub const IMU_V3_BRICKLET_GYROSCOPE_RANGE_250DPS: u8 = 3;
pub const IMU_V3_BRICKLET_GYROSCOPE_RANGE_125DPS: u8 = 4;
pub const IMU_V3_BRICKLET_GYROSCOPE_BANDWIDTH_523HZ: u8 = 0;
pub const IMU_V3_BRICKLET_GYROSCOPE_BANDWIDTH_230HZ: u8 = 1;
pub const IMU_V3_BRICKLET_GYROSCOPE_BANDWIDTH_116HZ: u8 = 2;
pub const IMU_V3_BRICKLET_GYROSCOPE_BANDWIDTH_47HZ: u8 = 3;
pub const IMU_V3_BRICKLET_GYROSCOPE_BANDWIDTH_23HZ: u8 = 4;
pub const IMU_V3_BRICKLET_GYROSCOPE_BANDWIDTH_12HZ: u8 = 5;
pub const IMU_V3_BRICKLET_GYROSCOPE_BANDWIDTH_64HZ: u8 = 6;
pub const IMU_V3_BRICKLET_GYROSCOPE_BANDWIDTH_32HZ: u8 = 7;
pub const IMU_V3_BRICKLET_ACCELEROMETER_RANGE_2G: u8 = 0;
pub const IMU_V3_BRICKLET_ACCELEROMETER_RANGE_4G: u8 = 1;
pub const IMU_V3_BRICKLET_ACCELEROMETER_RANGE_8G: u8 = 2;
pub const IMU_V3_BRICKLET_ACCELEROMETER_RANGE_16G: u8 = 3;
pub const IMU_V3_BRICKLET_ACCELEROMETER_BANDWIDTH_7_81HZ: u8 = 0;
pub const IMU_V3_BRICKLET_ACCELEROMETER_BANDWIDTH_15_63HZ: u8 = 1;
pub const IMU_V3_BRICKLET_ACCELEROMETER_BANDWIDTH_31_25HZ: u8 = 2;
pub const IMU_V3_BRICKLET_ACCELEROMETER_BANDWIDTH_62_5HZ: u8 = 3;
pub const IMU_V3_BRICKLET_ACCELEROMETER_BANDWIDTH_125HZ: u8 = 4;
pub const IMU_V3_BRICKLET_ACCELEROMETER_BANDWIDTH_250HZ: u8 = 5;
pub const IMU_V3_BRICKLET_ACCELEROMETER_BANDWIDTH_500HZ: u8 = 6;
pub const IMU_V3_BRICKLET_ACCELEROMETER_BANDWIDTH_1000HZ: u8 = 7;
pub const IMU_V3_BRICKLET_SENSOR_FUSION_OFF: u8 = 0;
pub const IMU_V3_BRICKLET_SENSOR_FUSION_ON: u8 = 1;
pub const IMU_V3_BRICKLET_SENSOR_FUSION_ON_WITHOUT_MAGNETOMETER: u8 = 2;
pub const IMU_V3_BRICKLET_SENSOR_FUSION_ON_WITHOUT_FAST_MAGNETOMETER_CALIBRATION: u8 = 3;
pub const IMU_V3_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
pub const IMU_V3_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
pub const IMU_V3_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
pub const IMU_V3_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
pub const IMU_V3_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
pub const IMU_V3_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
pub const IMU_V3_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
pub const IMU_V3_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
pub const IMU_V3_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
pub const IMU_V3_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
pub const IMU_V3_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
pub const IMU_V3_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
pub const IMU_V3_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
pub const IMU_V3_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
pub const IMU_V3_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Acceleration {
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for Acceleration {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> Acceleration {
Acceleration {
x: <i16>::from_le_byte_slice(&bytes[0..2]),
y: <i16>::from_le_byte_slice(&bytes[2..4]),
z: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct MagneticField {
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for MagneticField {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> MagneticField {
MagneticField {
x: <i16>::from_le_byte_slice(&bytes[0..2]),
y: <i16>::from_le_byte_slice(&bytes[2..4]),
z: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct AngularVelocity {
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for AngularVelocity {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> AngularVelocity {
AngularVelocity {
x: <i16>::from_le_byte_slice(&bytes[0..2]),
y: <i16>::from_le_byte_slice(&bytes[2..4]),
z: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Orientation {
pub heading: i16,
pub roll: i16,
pub pitch: i16,
}
impl FromByteSlice for Orientation {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> Orientation {
Orientation {
heading: <i16>::from_le_byte_slice(&bytes[0..2]),
roll: <i16>::from_le_byte_slice(&bytes[2..4]),
pitch: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct LinearAcceleration {
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for LinearAcceleration {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> LinearAcceleration {
LinearAcceleration {
x: <i16>::from_le_byte_slice(&bytes[0..2]),
y: <i16>::from_le_byte_slice(&bytes[2..4]),
z: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct GravityVector {
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for GravityVector {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> GravityVector {
GravityVector {
x: <i16>::from_le_byte_slice(&bytes[0..2]),
y: <i16>::from_le_byte_slice(&bytes[2..4]),
z: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Quaternion {
pub w: i16,
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for Quaternion {
fn bytes_expected() -> usize { 8 }
fn from_le_byte_slice(bytes: &[u8]) -> Quaternion {
Quaternion {
w: <i16>::from_le_byte_slice(&bytes[0..2]),
x: <i16>::from_le_byte_slice(&bytes[2..4]),
y: <i16>::from_le_byte_slice(&bytes[4..6]),
z: <i16>::from_le_byte_slice(&bytes[6..8]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct AllData {
pub acceleration: [i16; 3],
pub magnetic_field: [i16; 3],
pub angular_velocity: [i16; 3],
pub euler_angle: [i16; 3],
pub quaternion: [i16; 4],
pub linear_acceleration: [i16; 3],
pub gravity_vector: [i16; 3],
pub temperature: i8,
pub calibration_status: u8,
}
impl FromByteSlice for AllData {
fn bytes_expected() -> usize { 46 }
fn from_le_byte_slice(bytes: &[u8]) -> AllData {
AllData {
acceleration: <[i16; 3]>::from_le_byte_slice(&bytes[0..6]),
magnetic_field: <[i16; 3]>::from_le_byte_slice(&bytes[6..12]),
angular_velocity: <[i16; 3]>::from_le_byte_slice(&bytes[12..18]),
euler_angle: <[i16; 3]>::from_le_byte_slice(&bytes[18..24]),
quaternion: <[i16; 4]>::from_le_byte_slice(&bytes[24..32]),
linear_acceleration: <[i16; 3]>::from_le_byte_slice(&bytes[32..38]),
gravity_vector: <[i16; 3]>::from_le_byte_slice(&bytes[38..44]),
temperature: <i8>::from_le_byte_slice(&bytes[44..45]),
calibration_status: <u8>::from_le_byte_slice(&bytes[45..46]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct SensorConfiguration {
pub magnetometer_rate: u8,
pub gyroscope_range: u8,
pub gyroscope_bandwidth: u8,
pub accelerometer_range: u8,
pub accelerometer_bandwidth: u8,
}
impl FromByteSlice for SensorConfiguration {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> SensorConfiguration {
SensorConfiguration {
magnetometer_rate: <u8>::from_le_byte_slice(&bytes[0..1]),
gyroscope_range: <u8>::from_le_byte_slice(&bytes[1..2]),
gyroscope_bandwidth: <u8>::from_le_byte_slice(&bytes[2..3]),
accelerometer_range: <u8>::from_le_byte_slice(&bytes[3..4]),
accelerometer_bandwidth: <u8>::from_le_byte_slice(&bytes[4..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct AccelerationCallbackConfiguration {
pub period: u32,
pub value_has_to_change: bool,
}
impl FromByteSlice for AccelerationCallbackConfiguration {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> AccelerationCallbackConfiguration {
AccelerationCallbackConfiguration {
period: <u32>::from_le_byte_slice(&bytes[0..4]),
value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct MagneticFieldCallbackConfiguration {
pub period: u32,
pub value_has_to_change: bool,
}
impl FromByteSlice for MagneticFieldCallbackConfiguration {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> MagneticFieldCallbackConfiguration {
MagneticFieldCallbackConfiguration {
period: <u32>::from_le_byte_slice(&bytes[0..4]),
value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct AngularVelocityCallbackConfiguration {
pub period: u32,
pub value_has_to_change: bool,
}
impl FromByteSlice for AngularVelocityCallbackConfiguration {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> AngularVelocityCallbackConfiguration {
AngularVelocityCallbackConfiguration {
period: <u32>::from_le_byte_slice(&bytes[0..4]),
value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct TemperatureCallbackConfiguration {
pub period: u32,
pub value_has_to_change: bool,
}
impl FromByteSlice for TemperatureCallbackConfiguration {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> TemperatureCallbackConfiguration {
TemperatureCallbackConfiguration {
period: <u32>::from_le_byte_slice(&bytes[0..4]),
value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct OrientationCallbackConfiguration {
pub period: u32,
pub value_has_to_change: bool,
}
impl FromByteSlice for OrientationCallbackConfiguration {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> OrientationCallbackConfiguration {
OrientationCallbackConfiguration {
period: <u32>::from_le_byte_slice(&bytes[0..4]),
value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct LinearAccelerationCallbackConfiguration {
pub period: u32,
pub value_has_to_change: bool,
}
impl FromByteSlice for LinearAccelerationCallbackConfiguration {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> LinearAccelerationCallbackConfiguration {
LinearAccelerationCallbackConfiguration {
period: <u32>::from_le_byte_slice(&bytes[0..4]),
value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct GravityVectorCallbackConfiguration {
pub period: u32,
pub value_has_to_change: bool,
}
impl FromByteSlice for GravityVectorCallbackConfiguration {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> GravityVectorCallbackConfiguration {
GravityVectorCallbackConfiguration {
period: <u32>::from_le_byte_slice(&bytes[0..4]),
value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct QuaternionCallbackConfiguration {
pub period: u32,
pub value_has_to_change: bool,
}
impl FromByteSlice for QuaternionCallbackConfiguration {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> QuaternionCallbackConfiguration {
QuaternionCallbackConfiguration {
period: <u32>::from_le_byte_slice(&bytes[0..4]),
value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct AllDataCallbackConfiguration {
pub period: u32,
pub value_has_to_change: bool,
}
impl FromByteSlice for AllDataCallbackConfiguration {
fn bytes_expected() -> usize { 5 }
fn from_le_byte_slice(bytes: &[u8]) -> AllDataCallbackConfiguration {
AllDataCallbackConfiguration {
period: <u32>::from_le_byte_slice(&bytes[0..4]),
value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct AccelerationEvent {
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for AccelerationEvent {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> AccelerationEvent {
AccelerationEvent {
x: <i16>::from_le_byte_slice(&bytes[0..2]),
y: <i16>::from_le_byte_slice(&bytes[2..4]),
z: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct MagneticFieldEvent {
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for MagneticFieldEvent {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> MagneticFieldEvent {
MagneticFieldEvent {
x: <i16>::from_le_byte_slice(&bytes[0..2]),
y: <i16>::from_le_byte_slice(&bytes[2..4]),
z: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct AngularVelocityEvent {
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for AngularVelocityEvent {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> AngularVelocityEvent {
AngularVelocityEvent {
x: <i16>::from_le_byte_slice(&bytes[0..2]),
y: <i16>::from_le_byte_slice(&bytes[2..4]),
z: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct LinearAccelerationEvent {
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for LinearAccelerationEvent {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> LinearAccelerationEvent {
LinearAccelerationEvent {
x: <i16>::from_le_byte_slice(&bytes[0..2]),
y: <i16>::from_le_byte_slice(&bytes[2..4]),
z: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct GravityVectorEvent {
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for GravityVectorEvent {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> GravityVectorEvent {
GravityVectorEvent {
x: <i16>::from_le_byte_slice(&bytes[0..2]),
y: <i16>::from_le_byte_slice(&bytes[2..4]),
z: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct OrientationEvent {
pub heading: i16,
pub roll: i16,
pub pitch: i16,
}
impl FromByteSlice for OrientationEvent {
fn bytes_expected() -> usize { 6 }
fn from_le_byte_slice(bytes: &[u8]) -> OrientationEvent {
OrientationEvent {
heading: <i16>::from_le_byte_slice(&bytes[0..2]),
roll: <i16>::from_le_byte_slice(&bytes[2..4]),
pitch: <i16>::from_le_byte_slice(&bytes[4..6]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct QuaternionEvent {
pub w: i16,
pub x: i16,
pub y: i16,
pub z: i16,
}
impl FromByteSlice for QuaternionEvent {
fn bytes_expected() -> usize { 8 }
fn from_le_byte_slice(bytes: &[u8]) -> QuaternionEvent {
QuaternionEvent {
w: <i16>::from_le_byte_slice(&bytes[0..2]),
x: <i16>::from_le_byte_slice(&bytes[2..4]),
y: <i16>::from_le_byte_slice(&bytes[4..6]),
z: <i16>::from_le_byte_slice(&bytes[6..8]),
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct AllDataEvent {
pub acceleration: [i16; 3],
pub magnetic_field: [i16; 3],
pub angular_velocity: [i16; 3],
pub euler_angle: [i16; 3],
pub quaternion: [i16; 4],
pub linear_acceleration: [i16; 3],
pub gravity_vector: [i16; 3],
pub temperature: i8,
pub calibration_status: u8,
}
impl FromByteSlice for AllDataEvent {
fn bytes_expected() -> usize { 46 }
fn from_le_byte_slice(bytes: &[u8]) -> AllDataEvent {
AllDataEvent {
acceleration: <[i16; 3]>::from_le_byte_slice(&bytes[0..6]),
magnetic_field: <[i16; 3]>::from_le_byte_slice(&bytes[6..12]),
angular_velocity: <[i16; 3]>::from_le_byte_slice(&bytes[12..18]),
euler_angle: <[i16; 3]>::from_le_byte_slice(&bytes[18..24]),
quaternion: <[i16; 4]>::from_le_byte_slice(&bytes[24..32]),
linear_acceleration: <[i16; 3]>::from_le_byte_slice(&bytes[32..38]),
gravity_vector: <[i16; 3]>::from_le_byte_slice(&bytes[38..44]),
temperature: <i8>::from_le_byte_slice(&bytes[44..45]),
calibration_status: <u8>::from_le_byte_slice(&bytes[45..46]),
}
}
}
#[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)]
pub struct ImuV3Bricklet {
device: Device,
}
impl ImuV3Bricklet {
pub const DEVICE_IDENTIFIER: u16 = 2161;
pub const DEVICE_DISPLAY_NAME: &'static str = "IMU Bricklet 3.0";
pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> ImuV3Bricklet {
let mut result = ImuV3Bricklet { device: Device::new([2, 0, 0], uid, req_sender, 0) };
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetAcceleration) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetMagneticField) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetAngularVelocity) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetTemperature) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetOrientation) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetLinearAcceleration) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetGravityVector) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetQuaternion) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetAllData) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SaveCalibration) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetSensorConfiguration) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetSensorConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetSensorFusionMode) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetSensorFusionMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetAccelerationCallbackConfiguration) as usize] =
ResponseExpectedFlag::True;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetAccelerationCallbackConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetMagneticFieldCallbackConfiguration) as usize] =
ResponseExpectedFlag::True;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetMagneticFieldCallbackConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetAngularVelocityCallbackConfiguration) as usize] =
ResponseExpectedFlag::True;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetAngularVelocityCallbackConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetTemperatureCallbackConfiguration) as usize] =
ResponseExpectedFlag::True;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetTemperatureCallbackConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetOrientationCallbackConfiguration) as usize] =
ResponseExpectedFlag::True;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetOrientationCallbackConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetLinearAccelerationCallbackConfiguration) as usize] =
ResponseExpectedFlag::True;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetLinearAccelerationCallbackConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetGravityVectorCallbackConfiguration) as usize] =
ResponseExpectedFlag::True;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetGravityVectorCallbackConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetQuaternionCallbackConfiguration) as usize] =
ResponseExpectedFlag::True;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetQuaternionCallbackConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetAllDataCallbackConfiguration) as usize] =
ResponseExpectedFlag::True;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetAllDataCallbackConfiguration) as usize] =
ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetSpitfpErrorCount) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetBootloaderMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetBootloaderMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetWriteFirmwarePointer) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ImuV3BrickletFunction::WriteFirmware) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::SetStatusLedConfig) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetStatusLedConfig) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetChipTemperature) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ImuV3BrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
result.device.response_expected[u8::from(ImuV3BrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
result.device.response_expected[u8::from(ImuV3BrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
result
}
pub fn get_response_expected(&mut self, fun: ImuV3BrickletFunction) -> Result<bool, GetResponseExpectedError> {
self.device.get_response_expected(u8::from(fun))
}
pub fn set_response_expected(&mut self, fun: ImuV3BrickletFunction, 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 fn get_acceleration_callback_receiver(&self) -> ConvertingCallbackReceiver<AccelerationEvent> {
self.device.get_callback_receiver(u8::from(ImuV3BrickletFunction::CallbackAcceleration))
}
pub fn get_magnetic_field_callback_receiver(&self) -> ConvertingCallbackReceiver<MagneticFieldEvent> {
self.device.get_callback_receiver(u8::from(ImuV3BrickletFunction::CallbackMagneticField))
}
pub fn get_angular_velocity_callback_receiver(&self) -> ConvertingCallbackReceiver<AngularVelocityEvent> {
self.device.get_callback_receiver(u8::from(ImuV3BrickletFunction::CallbackAngularVelocity))
}
pub fn get_temperature_callback_receiver(&self) -> ConvertingCallbackReceiver<i8> {
self.device.get_callback_receiver(u8::from(ImuV3BrickletFunction::CallbackTemperature))
}
pub fn get_linear_acceleration_callback_receiver(&self) -> ConvertingCallbackReceiver<LinearAccelerationEvent> {
self.device.get_callback_receiver(u8::from(ImuV3BrickletFunction::CallbackLinearAcceleration))
}
pub fn get_gravity_vector_callback_receiver(&self) -> ConvertingCallbackReceiver<GravityVectorEvent> {
self.device.get_callback_receiver(u8::from(ImuV3BrickletFunction::CallbackGravityVector))
}
pub fn get_orientation_callback_receiver(&self) -> ConvertingCallbackReceiver<OrientationEvent> {
self.device.get_callback_receiver(u8::from(ImuV3BrickletFunction::CallbackOrientation))
}
pub fn get_quaternion_callback_receiver(&self) -> ConvertingCallbackReceiver<QuaternionEvent> {
self.device.get_callback_receiver(u8::from(ImuV3BrickletFunction::CallbackQuaternion))
}
pub fn get_all_data_callback_receiver(&self) -> ConvertingCallbackReceiver<AllDataEvent> {
self.device.get_callback_receiver(u8::from(ImuV3BrickletFunction::CallbackAllData))
}
pub fn get_acceleration(&self) -> ConvertingReceiver<Acceleration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetAcceleration), payload)
}
pub fn get_magnetic_field(&self) -> ConvertingReceiver<MagneticField> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetMagneticField), payload)
}
pub fn get_angular_velocity(&self) -> ConvertingReceiver<AngularVelocity> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetAngularVelocity), payload)
}
pub fn get_temperature(&self) -> ConvertingReceiver<i8> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetTemperature), payload)
}
pub fn get_orientation(&self) -> ConvertingReceiver<Orientation> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetOrientation), payload)
}
pub fn get_linear_acceleration(&self) -> ConvertingReceiver<LinearAcceleration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetLinearAcceleration), payload)
}
pub fn get_gravity_vector(&self) -> ConvertingReceiver<GravityVector> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetGravityVector), payload)
}
pub fn get_quaternion(&self) -> ConvertingReceiver<Quaternion> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetQuaternion), payload)
}
pub fn get_all_data(&self) -> ConvertingReceiver<AllData> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetAllData), payload)
}
pub fn save_calibration(&self) -> ConvertingReceiver<bool> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::SaveCalibration), payload)
}
pub fn set_sensor_configuration(
&self,
magnetometer_rate: u8,
gyroscope_range: u8,
gyroscope_bandwidth: u8,
accelerometer_range: u8,
accelerometer_bandwidth: u8,
) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(magnetometer_rate));
payload[1..2].copy_from_slice(&<u8>::to_le_byte_vec(gyroscope_range));
payload[2..3].copy_from_slice(&<u8>::to_le_byte_vec(gyroscope_bandwidth));
payload[3..4].copy_from_slice(&<u8>::to_le_byte_vec(accelerometer_range));
payload[4..5].copy_from_slice(&<u8>::to_le_byte_vec(accelerometer_bandwidth));
self.device.set(u8::from(ImuV3BrickletFunction::SetSensorConfiguration), payload)
}
pub fn get_sensor_configuration(&self) -> ConvertingReceiver<SensorConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetSensorConfiguration), payload)
}
pub fn set_sensor_fusion_mode(&self, mode: u8) -> ConvertingReceiver<()> {
let mut payload = vec![0; 1];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(mode));
self.device.set(u8::from(ImuV3BrickletFunction::SetSensorFusionMode), payload)
}
pub fn get_sensor_fusion_mode(&self) -> ConvertingReceiver<u8> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetSensorFusionMode), payload)
}
pub fn set_acceleration_callback_configuration(&self, period: u32, value_has_to_change: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
self.device.set(u8::from(ImuV3BrickletFunction::SetAccelerationCallbackConfiguration), payload)
}
pub fn get_acceleration_callback_configuration(&self) -> ConvertingReceiver<AccelerationCallbackConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetAccelerationCallbackConfiguration), payload)
}
pub fn set_magnetic_field_callback_configuration(&self, period: u32, value_has_to_change: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
self.device.set(u8::from(ImuV3BrickletFunction::SetMagneticFieldCallbackConfiguration), payload)
}
pub fn get_magnetic_field_callback_configuration(&self) -> ConvertingReceiver<MagneticFieldCallbackConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetMagneticFieldCallbackConfiguration), payload)
}
pub fn set_angular_velocity_callback_configuration(&self, period: u32, value_has_to_change: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
self.device.set(u8::from(ImuV3BrickletFunction::SetAngularVelocityCallbackConfiguration), payload)
}
pub fn get_angular_velocity_callback_configuration(&self) -> ConvertingReceiver<AngularVelocityCallbackConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetAngularVelocityCallbackConfiguration), payload)
}
pub fn set_temperature_callback_configuration(&self, period: u32, value_has_to_change: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
self.device.set(u8::from(ImuV3BrickletFunction::SetTemperatureCallbackConfiguration), payload)
}
pub fn get_temperature_callback_configuration(&self) -> ConvertingReceiver<TemperatureCallbackConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetTemperatureCallbackConfiguration), payload)
}
pub fn set_orientation_callback_configuration(&self, period: u32, value_has_to_change: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
self.device.set(u8::from(ImuV3BrickletFunction::SetOrientationCallbackConfiguration), payload)
}
pub fn get_orientation_callback_configuration(&self) -> ConvertingReceiver<OrientationCallbackConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetOrientationCallbackConfiguration), payload)
}
pub fn set_linear_acceleration_callback_configuration(&self, period: u32, value_has_to_change: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
self.device.set(u8::from(ImuV3BrickletFunction::SetLinearAccelerationCallbackConfiguration), payload)
}
pub fn get_linear_acceleration_callback_configuration(&self) -> ConvertingReceiver<LinearAccelerationCallbackConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetLinearAccelerationCallbackConfiguration), payload)
}
pub fn set_gravity_vector_callback_configuration(&self, period: u32, value_has_to_change: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
self.device.set(u8::from(ImuV3BrickletFunction::SetGravityVectorCallbackConfiguration), payload)
}
pub fn get_gravity_vector_callback_configuration(&self) -> ConvertingReceiver<GravityVectorCallbackConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetGravityVectorCallbackConfiguration), payload)
}
pub fn set_quaternion_callback_configuration(&self, period: u32, value_has_to_change: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
self.device.set(u8::from(ImuV3BrickletFunction::SetQuaternionCallbackConfiguration), payload)
}
pub fn get_quaternion_callback_configuration(&self) -> ConvertingReceiver<QuaternionCallbackConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetQuaternionCallbackConfiguration), payload)
}
pub fn set_all_data_callback_configuration(&self, period: u32, value_has_to_change: bool) -> ConvertingReceiver<()> {
let mut payload = vec![0; 5];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(period));
payload[4..5].copy_from_slice(&<bool>::to_le_byte_vec(value_has_to_change));
self.device.set(u8::from(ImuV3BrickletFunction::SetAllDataCallbackConfiguration), payload)
}
pub fn get_all_data_callback_configuration(&self) -> ConvertingReceiver<AllDataCallbackConfiguration> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetAllDataCallbackConfiguration), payload)
}
pub fn get_spitfp_error_count(&self) -> ConvertingReceiver<SpitfpErrorCount> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetSpitfpErrorCount), payload)
}
pub fn set_bootloader_mode(&self, mode: u8) -> ConvertingReceiver<u8> {
let mut payload = vec![0; 1];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(mode));
self.device.get(u8::from(ImuV3BrickletFunction::SetBootloaderMode), payload)
}
pub fn get_bootloader_mode(&self) -> ConvertingReceiver<u8> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetBootloaderMode), payload)
}
pub fn set_write_firmware_pointer(&self, pointer: u32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(pointer));
self.device.set(u8::from(ImuV3BrickletFunction::SetWriteFirmwarePointer), payload)
}
pub fn write_firmware(&self, data: [u8; 64]) -> ConvertingReceiver<u8> {
let mut payload = vec![0; 64];
payload[0..64].copy_from_slice(&<[u8; 64]>::to_le_byte_vec(data));
self.device.get(u8::from(ImuV3BrickletFunction::WriteFirmware), payload)
}
pub fn set_status_led_config(&self, config: u8) -> ConvertingReceiver<()> {
let mut payload = vec![0; 1];
payload[0..1].copy_from_slice(&<u8>::to_le_byte_vec(config));
self.device.set(u8::from(ImuV3BrickletFunction::SetStatusLedConfig), payload)
}
pub fn get_status_led_config(&self) -> ConvertingReceiver<u8> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetStatusLedConfig), payload)
}
pub fn get_chip_temperature(&self) -> ConvertingReceiver<i16> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetChipTemperature), payload)
}
pub fn reset(&self) -> ConvertingReceiver<()> {
let payload = vec![0; 0];
self.device.set(u8::from(ImuV3BrickletFunction::Reset), payload)
}
pub fn write_uid(&self, uid: u32) -> ConvertingReceiver<()> {
let mut payload = vec![0; 4];
payload[0..4].copy_from_slice(&<u32>::to_le_byte_vec(uid));
self.device.set(u8::from(ImuV3BrickletFunction::WriteUid), payload)
}
pub fn read_uid(&self) -> ConvertingReceiver<u32> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::ReadUid), payload)
}
pub fn get_identity(&self) -> ConvertingReceiver<Identity> {
let payload = vec![0; 0];
self.device.get(u8::from(ImuV3BrickletFunction::GetIdentity), payload)
}
}