forked from M-Labs/kirdy
thermostat: Save the user config-ed value directly
- the firmware recorded the actual value set with quantization errors or other errors - this caused confusion for the user when they read back the settings
This commit is contained in:
parent
3410a271fd
commit
a76b8de994
|
@ -233,36 +233,39 @@ impl Thermostat {
|
|||
|
||||
pub fn set_i(&mut self, i_tec: ElectricCurrent) -> ElectricCurrent {
|
||||
let voltage = i_tec * 10.0 * R_SENSE + self.tec_settings.center_pt;
|
||||
let voltage = self.max1968.set_dac(voltage, self.max1968.dac_out_range);
|
||||
let _voltage = self.max1968.set_dac(voltage, self.max1968.dac_out_range);
|
||||
|
||||
self.tec_settings.i_set = (voltage - self.tec_settings.center_pt) / (10.0 * R_SENSE);
|
||||
self.tec_settings.i_set = i_tec;
|
||||
self.tec_settings.i_set
|
||||
}
|
||||
|
||||
pub fn set_max_v(&mut self, max_v: ElectricPotential) -> ElectricPotential {
|
||||
let duty = (max_v / TecSettings::MAX_V_DUTY_TO_VOLTAGE_RATE).get::<ratio>();
|
||||
let duty = self
|
||||
let _duty = self
|
||||
.max1968
|
||||
.set_pwm(PwmPinsEnum::MaxV, duty as f64, TecSettings::MAX_V_DUTY_MAX);
|
||||
self.tec_settings.max_v_set = duty as f32 * TecSettings::MAX_V_DUTY_TO_VOLTAGE_RATE;
|
||||
|
||||
self.tec_settings.max_v_set = max_v;
|
||||
self.tec_settings.max_v_set
|
||||
}
|
||||
|
||||
pub fn set_max_i_pos(&mut self, max_i_pos: ElectricCurrent) -> ElectricCurrent {
|
||||
let duty = (max_i_pos / TecSettings::MAX_I_POS_NEG_DUTY_TO_CURRENT_RATE).get::<ratio>();
|
||||
let duty = self
|
||||
let _duty = self
|
||||
.max1968
|
||||
.set_pwm(PwmPinsEnum::MaxPosI, duty as f64, TecSettings::MAX_I_POS_DUTY_MAX);
|
||||
self.tec_settings.max_i_pos_set = duty as f32 * TecSettings::MAX_I_POS_NEG_DUTY_TO_CURRENT_RATE;
|
||||
|
||||
self.tec_settings.max_i_pos_set = max_i_pos;
|
||||
self.tec_settings.max_i_pos_set
|
||||
}
|
||||
|
||||
pub fn set_max_i_neg(&mut self, max_i_neg: ElectricCurrent) -> ElectricCurrent {
|
||||
let duty = (max_i_neg / TecSettings::MAX_I_POS_NEG_DUTY_TO_CURRENT_RATE).get::<ratio>();
|
||||
let duty = self
|
||||
let _duty = self
|
||||
.max1968
|
||||
.set_pwm(PwmPinsEnum::MaxNegI, duty as f64, TecSettings::MAX_I_NEG_DUTY_MAX);
|
||||
self.tec_settings.max_i_neg_set = duty as f32 * TecSettings::MAX_I_POS_NEG_DUTY_TO_CURRENT_RATE;
|
||||
|
||||
self.tec_settings.max_i_neg_set = max_i_neg;
|
||||
self.tec_settings.max_i_neg_set
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue