Skip to content

Commit

Permalink
Use 4-element array instead of 4-tuple to represent LIM temperature r…
Browse files Browse the repository at this point in the history
…eadings (#91)

* Use 4-element array instead of 4-tuple

* Use Iterator::chain to join PT reading arrays
  • Loading branch information
samderanova authored May 29, 2024
1 parent fe9f55a commit 7e69039
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions pod-operation/src/components/lim_temperature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ impl LimTemperature {
self.ads1015.destroy_ads1015();
}

pub fn read_lim_temps(&mut self) -> (f32, f32, f32, f32) {
pub fn read_lim_temps(&mut self) -> [f32; 4] {
[SingleA0, SingleA1, SingleA2, SingleA3]
.map(|channel| block!(self.ads1015.read(channel)).unwrap())
.map(voltage_to_temp)
.into()
}
}
8 changes: 4 additions & 4 deletions pod-operation/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ impl StateMachine {
if self.downstream_pressure_transducer.read_pressure() < MIN_PRESSURE {
return State::Faulted;
}
let default_readings: [f32; 4] = self.lim_temperature_port.read_lim_temps().into();
let alternative_readings: [f32; 4] = self.lim_temperature_starboard.read_lim_temps().into();
let all_readings = [default_readings, alternative_readings].concat();
if all_readings
let default_readings = self.lim_temperature_port.read_lim_temps();
let alternative_readings = self.lim_temperature_starboard.read_lim_temps();
if default_readings
.iter()
.chain(alternative_readings.iter())
.any(|&reading| reading > LIM_TEMP_THRESHOLD)
{
return State::Faulted;
Expand Down

0 comments on commit 7e69039

Please sign in to comment.