Move PwmLimits into its own file
This commit is contained in:
parent
bd9ae997ae
commit
5b29f12a50
|
@ -1,8 +1,9 @@
|
|||
use crate::{
|
||||
ad7172,
|
||||
command_parser::{CenterPoint, Polarity},
|
||||
config::PwmLimits,
|
||||
pid, steinhart_hart as sh,
|
||||
pid,
|
||||
pwm_limits::PwmLimits,
|
||||
steinhart_hart as sh,
|
||||
};
|
||||
use num_traits::Zero;
|
||||
use smoltcp::time::{Duration, Instant};
|
||||
|
|
|
@ -2,11 +2,13 @@ use crate::{
|
|||
ad7172::PostFilter,
|
||||
channels::Channels,
|
||||
command_parser::{CenterPoint, Polarity},
|
||||
pid, steinhart_hart,
|
||||
pid,
|
||||
pwm_limits::PwmLimits,
|
||||
steinhart_hart,
|
||||
};
|
||||
use num_traits::Zero;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uom::si::f64::{ElectricCurrent, ElectricPotential};
|
||||
use uom::si::f64::ElectricCurrent;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ChannelConfig {
|
||||
|
@ -70,29 +72,3 @@ impl ChannelConfig {
|
|||
channels.set_polarity(channel, self.polarity.clone());
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PwmLimits {
|
||||
pub max_v: ElectricPotential,
|
||||
pub max_i_pos: ElectricCurrent,
|
||||
pub max_i_neg: ElectricCurrent,
|
||||
}
|
||||
|
||||
impl PwmLimits {
|
||||
pub fn new(channels: &mut Channels, channel: usize) -> Self {
|
||||
let max_v = channels.get_max_v(channel);
|
||||
let max_i_pos = channels.get_max_i_pos(channel);
|
||||
let max_i_neg = channels.get_max_i_neg(channel);
|
||||
PwmLimits {
|
||||
max_v,
|
||||
max_i_pos,
|
||||
max_i_neg,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn apply(&self, channels: &mut Channels, channel: usize) {
|
||||
channels.set_max_v(channel, self.max_v);
|
||||
channels.set_max_i_pos(channel, self.max_i_pos);
|
||||
channels.set_max_i_neg(channel, self.max_i_neg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ mod command_parser;
|
|||
use command_parser::Ipv4Config;
|
||||
mod channels;
|
||||
mod pid;
|
||||
mod pwm_limits;
|
||||
mod steinhart_hart;
|
||||
mod timer;
|
||||
use channels::{Channels, CHANNELS};
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
use crate::channels::Channels;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uom::si::{
|
||||
f64::{ElectricCurrent, ElectricPotential},
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PwmLimits {
|
||||
pub max_v: ElectricPotential,
|
||||
pub max_i_pos: ElectricCurrent,
|
||||
pub max_i_neg: ElectricCurrent,
|
||||
}
|
||||
|
||||
impl PwmLimits {
|
||||
pub fn new(channels: &mut Channels, channel: usize) -> Self {
|
||||
PwmLimits {
|
||||
max_v: channels.get_max_v(channel),
|
||||
max_i_pos: channels.get_max_i_pos(channel),
|
||||
max_i_neg: channels.get_max_i_neg(channel),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn apply(&self, channels: &mut Channels, channel: usize) {
|
||||
channels.set_max_v(channel, self.max_v);
|
||||
channels.set_max_i_pos(channel, self.max_i_pos);
|
||||
channels.set_max_i_neg(channel, self.max_i_neg);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue