use core::fmt::Debug;
#[cfg(feature = "defmt")]
use defmt::Format;
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(Format))]
pub enum Error<E> {
Comm(E),
InvalidDevice,
InvalidConfig,
Timeout,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum AccelerometerPowerMode {
Disable = 0x00,
LowPower = 0x03,
Normal = 0x04,
HighPerf = 0x07,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum AccelerometerRange {
G2 = 0,
G4 = 1,
G8 = 2,
G16 = 3,
}
impl AccelerometerRange {
pub fn to_g(self) -> f32 {
match self {
AccelerometerRange::G2 => 2.0,
AccelerometerRange::G4 => 4.0,
AccelerometerRange::G8 => 8.0,
AccelerometerRange::G16 => 16.0,
}
}
}
impl Default for AccelerometerRange {
fn default() -> Self {
AccelerometerRange::G8
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GyroscopePowerMode {
Disable = 0x00,
Suspend = 0x01,
LowPower = 0x03,
Normal = 0x04,
HighPerf = 0x07,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum GyroscopeRange {
DPS125 = 0,
DPS250 = 1,
DPS500 = 2,
DPS1000 = 3,
DPS2000 = 4,
}
impl GyroscopeRange {
pub fn to_dps(self) -> f32 {
match self {
GyroscopeRange::DPS125 => 125.0,
GyroscopeRange::DPS250 => 250.0,
GyroscopeRange::DPS500 => 500.0,
GyroscopeRange::DPS1000 => 1000.0,
GyroscopeRange::DPS2000 => 2000.0,
}
}
}
impl Default for GyroscopeRange {
fn default() -> Self {
GyroscopeRange::DPS2000
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Sensor3DData {
pub x: i16,
pub y: i16,
pub z: i16,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Sensor3DDataScaled {
pub x: f32,
pub y: f32,
pub z: f32,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum OutputDataRate {
Odr0_78hz = 0x01,
Odr1_56hz = 0x02,
Odr3_125hz = 0x03,
Odr6_25hz = 0x04,
Odr12_5hz = 0x05,
Odr25hz = 0x06,
Odr50hz = 0x07,
Odr100hz = 0x08,
Odr200hz = 0x09,
Odr400hz = 0x0A,
Odr800hz = 0x0B,
Odr1600hz = 0x0C,
Odr3200hz = 0x0D,
Odr6400hz = 0x0E,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum AverageNum {
Avg1 = 0x00,
Avg2 = 0x01,
Avg4 = 0x02,
Avg8 = 0x03,
Avg16 = 0x04,
Avg32 = 0x05,
Avg64 = 0x06,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Bandwidth {
OdrHalf = 0,
OdrQuarter = 1,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum SensorType {
Accelerometer,
Gyroscope,
}