From a81a1a0fa60c60dfd8a5ac16957403c0915ad8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Mon, 25 Nov 2024 18:28:06 -0300 Subject: [PATCH] fixup! lib: Update code to use new api and modules --- src/lib.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 02c9bc346..0f76f061f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, + 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. @@ -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 {