current_abs_max_tec_i from all channels, not 0 & 1
Helps if a thermostat was made with more than 2 channels.
parent
504fca8757
commit
e344c11562
|
@ -1,4 +1,3 @@
|
|||
use core::cmp::max_by;
|
||||
use heapless::{consts::U2, Vec};
|
||||
use serde::{Serialize, Serializer};
|
||||
use smoltcp::time::Instant;
|
||||
|
@ -525,9 +524,14 @@ impl Channels {
|
|||
}
|
||||
|
||||
pub fn current_abs_max_tec_i(&mut self) -> ElectricCurrent {
|
||||
max_by(self.get_tec_i(0).abs(),
|
||||
self.get_tec_i(1).abs(),
|
||||
|a, b| a.partial_cmp(b).unwrap_or(core::cmp::Ordering::Equal))
|
||||
let mut max_abs_current = ElectricCurrent::new::<ampere>(0.0);
|
||||
for channel in 0..CHANNELS {
|
||||
let channel_abs_current = self.get_tec_i(channel).abs();
|
||||
if channel_abs_current > max_abs_current {
|
||||
max_abs_current = channel_abs_current;
|
||||
}
|
||||
}
|
||||
max_abs_current
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue