From 7e690396fcdd5f270971da729f35dcfe3de9b9ba Mon Sep 17 00:00:00 2001 From: Sam Der Date: Wed, 29 May 2024 14:07:55 -0700 Subject: [PATCH] Use 4-element array instead of 4-tuple to represent LIM temperature readings (#91) * Use 4-element array instead of 4-tuple * Use Iterator::chain to join PT reading arrays --- pod-operation/src/components/lim_temperature.rs | 3 +-- pod-operation/src/state_machine.rs | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pod-operation/src/components/lim_temperature.rs b/pod-operation/src/components/lim_temperature.rs index 5e070e12..ade303c3 100644 --- a/pod-operation/src/components/lim_temperature.rs +++ b/pod-operation/src/components/lim_temperature.rs @@ -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() } } diff --git a/pod-operation/src/state_machine.rs b/pod-operation/src/state_machine.rs index 9ab633be..c82e1020 100644 --- a/pod-operation/src/state_machine.rs +++ b/pod-operation/src/state_machine.rs @@ -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;