Calculate current_abs_max_tec_i from all channels #119
|
@ -1,4 +1,4 @@
|
||||||
use core::{cmp::max_by, marker::PhantomData};
|
use core::marker::PhantomData;
|
||||||
use heapless::{consts::U2, Vec};
|
use heapless::{consts::U2, Vec};
|
||||||
use num_traits::Zero;
|
use num_traits::Zero;
|
||||||
use serde::{Serialize, Serializer};
|
use serde::{Serialize, Serializer};
|
||||||
|
@ -561,9 +561,10 @@ impl Channels {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn current_abs_max_tec_i(&mut self) -> ElectricCurrent {
|
pub fn current_abs_max_tec_i(&mut self) -> ElectricCurrent {
|
||||||
max_by(self.get_tec_i(0).abs(),
|
(0..CHANNELS)
|
||||||
self.get_tec_i(1).abs(),
|
.map(|channel| self.get_tec_i(channel).abs())
|
||||||
|a, b| a.partial_cmp(b).unwrap_or(core::cmp::Ordering::Equal))
|
.max_by(|a, b| a.partial_cmp(b).unwrap_or(core::cmp::Ordering::Equal))
|
||||||
|
|||||||
|
.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Quite curious though, is it internally same efficiency? I remember in some languages it's not in case of streams
It doesn't matter here. The bottleneck will be
self.get_tec_i(channel)
which blocks until the single conversion Adc readings return.