forked from M-Labs/thermostat
Move PwmLimits into its own file
This commit is contained in:
parent
ce1ee5a2fe
commit
ced3363232
@ -1,13 +1,12 @@
|
||||
use num_traits::Zero;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use uom::si::f64::{
|
||||
ElectricCurrent, ElectricPotential,
|
||||
};
|
||||
use uom::si::f64::ElectricCurrent;
|
||||
use crate::{
|
||||
ad7172::PostFilter,
|
||||
channels::Channels,
|
||||
command_parser::CenterPoint,
|
||||
pid,
|
||||
pwm_limits::PwmLimits,
|
||||
steinhart_hart,
|
||||
};
|
||||
|
||||
@ -68,29 +67,3 @@ impl ChannelConfig {
|
||||
let _ = channels.set_i(channel, self.i_set);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
struct PwmLimits {
|
||||
max_v: ElectricPotential,
|
||||
max_i_pos: ElectricCurrent,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ mod command_parser;
|
||||
use command_parser::Ipv4Config;
|
||||
mod timer;
|
||||
mod pid;
|
||||
mod pwm_limits;
|
||||
mod steinhart_hart;
|
||||
mod channels;
|
||||
use channels::{CHANNELS, Channels};
|
||||
|
31
src/pwm_limits.rs
Normal file
31
src/pwm_limits.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
use uom::si::f64::{
|
||||
ElectricCurrent, ElectricPotential,
|
||||
};
|
||||
use crate::channels::Channels;
|
||||
|
||||
#[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).0;
|
||||
let max_i_pos = channels.get_max_i_pos(channel).0;
|
||||
let max_i_neg = channels.get_max_i_neg(channel).0;
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user