Skip to content

Commit

Permalink
lib: Use vector over ADCData
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Nov 21, 2024
1 parent 622c97b commit 62c9ea7
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,6 @@ pub struct AxisData {
pub z: f32,
}

/// Encapsulates the value of ADC's four channels.
#[derive(Debug, Default, Clone, Copy)]
pub struct ADCData {
pub channel: [f32; 4],
}

/// Encapsulates the value of all sensors on the board.
#[derive(Debug, Default, Clone, Copy)]
pub struct SensorData {
pub adc: ADCData,
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 @@ -346,12 +328,9 @@ impl Navigator {
}
}

pub fn read_adc_all(&mut self) -> ADCData {
pub fn read_adc_all(&mut self) -> Vec<f32> {
if let Some(adc_sensor) = self.get_adc_sensor() {
let values = adc_sensor.read_all_channels().unwrap();
ADCData {
channel: [values[0], values[1], values[2], values[3]],
}
adc_sensor.read_all_channels().unwrap()
} else {
panic!("No ADC sensor available");
}
Expand Down

0 comments on commit 62c9ea7

Please sign in to comment.