PwmLimits: uom
This commit is contained in:
parent
9d89104f50
commit
dc7d11912a
@ -1,9 +1,7 @@
|
|||||||
use num_traits::Zero;
|
use num_traits::Zero;
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use uom::si::{
|
use uom::si::f64::{
|
||||||
electric_potential::volt,
|
ElectricCurrent, ElectricPotential,
|
||||||
electric_current::ampere,
|
|
||||||
f64::{ElectricCurrent, ElectricPotential},
|
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
ad7172::PostFilter,
|
ad7172::PostFilter,
|
||||||
@ -73,9 +71,9 @@ impl ChannelConfig {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
struct PwmLimits {
|
struct PwmLimits {
|
||||||
max_v: f64,
|
max_v: ElectricPotential,
|
||||||
max_i_pos: f64,
|
max_i_pos: ElectricCurrent,
|
||||||
max_i_neg: f64,
|
max_i_neg: ElectricCurrent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PwmLimits {
|
impl PwmLimits {
|
||||||
@ -84,15 +82,15 @@ impl PwmLimits {
|
|||||||
let (max_i_pos, _) = channels.get_max_i_pos(channel);
|
let (max_i_pos, _) = channels.get_max_i_pos(channel);
|
||||||
let (max_i_neg, _) = channels.get_max_i_neg(channel);
|
let (max_i_neg, _) = channels.get_max_i_neg(channel);
|
||||||
PwmLimits {
|
PwmLimits {
|
||||||
max_v: max_v.get::<volt>(),
|
max_v,
|
||||||
max_i_pos: max_i_pos.get::<ampere>(),
|
max_i_pos,
|
||||||
max_i_neg: max_i_neg.get::<ampere>(),
|
max_i_neg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply(&self, channels: &mut Channels, channel: usize) {
|
pub fn apply(&self, channels: &mut Channels, channel: usize) {
|
||||||
channels.set_max_v(channel, ElectricPotential::new::<volt>(self.max_v));
|
channels.set_max_v(channel, self.max_v);
|
||||||
channels.set_max_i_pos(channel, ElectricCurrent::new::<ampere>(self.max_i_pos));
|
channels.set_max_i_pos(channel, self.max_i_pos);
|
||||||
channels.set_max_i_neg(channel, ElectricCurrent::new::<ampere>(self.max_i_neg));
|
channels.set_max_i_neg(channel, self.max_i_neg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user