use crate::register::*;
#[derive(Debug, Clone, Copy)]
pub struct Configuration {
pub mode: Mode,
pub datarate: DataRate,
pub range: Range,
pub enable_new_acceleration_interrupt: bool,
pub motion_detection: Option<MotionDetctionConfiguration>,
}
impl Default for Configuration {
fn default() -> Self {
Self {
mode: Mode::HighResolution,
datarate: DataRate::Hz_6_25,
range: Range::G2,
enable_new_acceleration_interrupt: false,
motion_detection: None,
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct MotionDetctionConfiguration {
pub datarate: MotionDetectionDataRate,
pub latch_mode: MotionDetectionLatchMode,
pub non_activity_counter: u8,
pub wakeup_counter: u8,
pub wakeup_threshold: u8,
pub interrupt_pin: Option<InterruptPinConfiguration>,
pub enable_x_negative: bool,
pub enable_x_positive: bool,
pub enable_y_negative: bool,
pub enable_y_positive: bool,
pub enable_z_negative: bool,
pub enable_z_positive: bool,
}
impl Default for MotionDetctionConfiguration {
fn default() -> Self {
Self {
datarate: MotionDetectionDataRate::Hz_6_25,
latch_mode: MotionDetectionLatchMode::Latched,
non_activity_counter: 10,
wakeup_counter: 1,
wakeup_threshold: 40,
interrupt_pin: None,
enable_x_negative: true,
enable_x_positive: true,
enable_y_negative: true,
enable_y_positive: true,
enable_z_negative: true,
enable_z_positive: true,
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct InterruptPinConfiguration {
pub polarity: InterruptPinPolarity,
pub response: InterruptPinResponse,
}
impl Default for InterruptPinConfiguration {
fn default() -> Self {
Self {
polarity: InterruptPinPolarity::ActiveLow,
response: InterruptPinResponse::Latched,
}
}
}