forked from M-Labs/thermostat
Compare commits
3 Commits
c0bddc03b9
...
45129be836
Author | SHA1 | Date | |
---|---|---|---|
45129be836 | |||
227a157e9e | |||
e34196267b |
@ -444,7 +444,8 @@ impl Channels {
|
|||||||
|
|
||||||
pub fn set_max_v(&mut self, channel: usize, max_v: ElectricPotential) -> (ElectricPotential, ElectricPotential) {
|
pub fn set_max_v(&mut self, channel: usize, max_v: ElectricPotential) -> (ElectricPotential, ElectricPotential) {
|
||||||
let max = 4.0 * ElectricPotential::new::<volt>(3.3);
|
let max = 4.0 * ElectricPotential::new::<volt>(3.3);
|
||||||
let duty = (max_v.min(MAX_TEC_V).max(ElectricPotential::zero()) / max).get::<ratio>();
|
let max_v = max_v.min(MAX_TEC_V).max(ElectricPotential::zero());
|
||||||
|
let duty = (max_v / max).get::<ratio>();
|
||||||
let duty = self.set_pwm(channel, PwmPin::MaxV, duty);
|
let duty = self.set_pwm(channel, PwmPin::MaxV, duty);
|
||||||
self.channel_state(channel).pwm_limits.max_v = max_v.get::<volt>();
|
self.channel_state(channel).pwm_limits.max_v = max_v.get::<volt>();
|
||||||
(duty * max, max)
|
(duty * max, max)
|
||||||
@ -452,7 +453,8 @@ impl Channels {
|
|||||||
|
|
||||||
pub fn set_max_i_pos(&mut self, channel: usize, max_i_pos: ElectricCurrent) -> (ElectricCurrent, ElectricCurrent) {
|
pub fn set_max_i_pos(&mut self, channel: usize, max_i_pos: ElectricCurrent) -> (ElectricCurrent, ElectricCurrent) {
|
||||||
let max = ElectricCurrent::new::<ampere>(3.0);
|
let max = ElectricCurrent::new::<ampere>(3.0);
|
||||||
let duty = (max_i_pos.min(MAX_TEC_I).max(ElectricCurrent::zero()) / max).get::<ratio>();
|
let max_i_pos = max_i_pos.min(MAX_TEC_I).max(ElectricCurrent::zero());
|
||||||
|
let duty = (max_i_pos / max).get::<ratio>();
|
||||||
let duty = self.set_pwm(channel, PwmPin::MaxIPos, duty);
|
let duty = self.set_pwm(channel, PwmPin::MaxIPos, duty);
|
||||||
self.channel_state(channel).pwm_limits.max_i_pos = max_i_pos.get::<ampere>();
|
self.channel_state(channel).pwm_limits.max_i_pos = max_i_pos.get::<ampere>();
|
||||||
(duty * max, max)
|
(duty * max, max)
|
||||||
@ -460,7 +462,8 @@ impl Channels {
|
|||||||
|
|
||||||
pub fn set_max_i_neg(&mut self, channel: usize, max_i_neg: ElectricCurrent) -> (ElectricCurrent, ElectricCurrent) {
|
pub fn set_max_i_neg(&mut self, channel: usize, max_i_neg: ElectricCurrent) -> (ElectricCurrent, ElectricCurrent) {
|
||||||
let max = ElectricCurrent::new::<ampere>(3.0);
|
let max = ElectricCurrent::new::<ampere>(3.0);
|
||||||
let duty = (max_i_neg.min(MAX_TEC_I).max(ElectricCurrent::zero()) / max).get::<ratio>();
|
let max_i_neg = max_i_neg.min(MAX_TEC_I).max(ElectricCurrent::zero());
|
||||||
|
let duty = (max_i_neg / max).get::<ratio>();
|
||||||
let duty = self.set_pwm(channel, PwmPin::MaxINeg, duty);
|
let duty = self.set_pwm(channel, PwmPin::MaxINeg, duty);
|
||||||
self.channel_state(channel).pwm_limits.max_i_neg = max_i_neg.get::<ampere>();
|
self.channel_state(channel).pwm_limits.max_i_neg = max_i_neg.get::<ampere>();
|
||||||
(duty * max, max)
|
(duty * max, max)
|
||||||
|
Loading…
Reference in New Issue
Block a user