forked from M-Labs/kirdy
Add fns to apply ld, tec settings summary configs
This commit is contained in:
parent
ef2410f441
commit
92c6cf12d4
@ -222,6 +222,20 @@ impl LdDrive{
|
||||
ld_pwr_limit: settings.ld_pwr_limit,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_settings_from_summary(&mut self, settings: LdSettingsSummary) {
|
||||
self.power_down();
|
||||
self.settings.ld_drive_current = settings.ld_drive_current.value;
|
||||
self.settings.ld_drive_current_limit = settings.ld_drive_current_limit.value;
|
||||
self.settings.pd_responsitivity = settings.pd_responsitivity;
|
||||
self.settings.ld_pwr_limit = settings.ld_pwr_limit;
|
||||
|
||||
if settings.default_pwr_on {
|
||||
self.power_up();
|
||||
} else {
|
||||
self.power_down();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]
|
||||
|
@ -488,6 +488,51 @@ impl Thermostat{
|
||||
thermistor_params: self.get_steinhart_hart(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_settings_from_summary(&mut self, settings: ThermostatSettingsSummary) {
|
||||
self.power_down();
|
||||
self.set_max_i_neg(settings.tec_settings.max_i_neg.value);
|
||||
self.set_max_i_pos(settings.tec_settings.max_i_pos.value);
|
||||
self.set_max_v(settings.tec_settings.max_v.value);
|
||||
|
||||
self.apply_steinhart_hart(settings.thermistor_params);
|
||||
self.apply_temp_mon_settings(settings.temp_mon_settings);
|
||||
|
||||
match settings.temp_adc_settings.rate {
|
||||
Some(rate) => {
|
||||
match settings.temp_adc_settings.filter_type {
|
||||
FilterType::Sinc3 => {
|
||||
self.set_temp_adc_sinc3_filter(0, SingleChODR::closest(rate).unwrap())
|
||||
}
|
||||
FilterType::Sinc5Sinc1 => {
|
||||
self.set_temp_adc_sinc5_sinc1_filter(0, SingleChODR::closest(rate).unwrap())
|
||||
}
|
||||
FilterType::Sinc3WithFineODR => {
|
||||
self.set_temp_adc_sinc3_fine_filter(0, rate)
|
||||
}
|
||||
FilterType::Sinc5Sinc1With50hz60HzRejection => {
|
||||
self.set_temp_adc_sinc5_sinc1_with_postfilter(0, PostFilter::closest(rate).unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
debug!(" Temperature ADC Settings is not found");
|
||||
}
|
||||
}
|
||||
|
||||
self.set_pid_engaged(settings.pid_engaged);
|
||||
self.pid_ctrl_ch0.apply_pid_params(settings.pid_params);
|
||||
self.set_temperature_setpoint(settings.temperature_setpoint);
|
||||
if !settings.pid_engaged {
|
||||
self.set_i(settings.tec_settings.i_set.value);
|
||||
}
|
||||
|
||||
if settings.default_pwr_on {
|
||||
self.power_up();
|
||||
} else {
|
||||
self.power_down();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]
|
||||
|
Loading…
Reference in New Issue
Block a user