Skip to content

Commit

Permalink
fixup! lib: Update code to use new api and modules
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickelectric committed Nov 25, 2024
1 parent b51dea1 commit a81a1a0
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,25 @@ impl fmt::Display for UserLed {
}

/// The `AxisData` struct encapsulates values for the x, y, and z axes.
#[derive(Debug, Default, Clone, Copy)]
#[derive(Debug, Default, Clone)]
pub struct AxisData {
pub x: f32,
pub y: f32,
pub z: f32,
}

/// Reads all sensors and stores on a single structure.
#[derive(Debug, Default, Clone)]
pub struct SensorData {
pub adc: Vec<f32>,
pub temperature: f32,
pub pressure: f32,
pub accelerometer: AxisData,
pub magnetometer: AxisData,
pub gyro: AxisData,
pub leak: bool,
}

/// The `Navigator` struct contains various components used for navigator. It includes PWM control,
/// pressure and temperature sensing, analog-to-digital conversion, inertial measurement unit,
/// magnetometer, and LEDs control.
Expand Down Expand Up @@ -342,7 +354,17 @@ impl Navigator {
}
}

// Implement other methods as needed
pub fn read_all(&mut self) -> SensorData {
SensorData {
adc: self.read_adc_all(),
temperature: self.read_temperature(),
pressure: self.read_pressure(),
accelerometer: self.read_accel(),
magnetometer: self.read_mag(),
gyro: self.read_gyro(),
leak: self.read_leak()
}
}
}

pub struct NavigatorBuilder {
Expand Down

0 comments on commit a81a1a0

Please sign in to comment.