ld: add ld_terms_short in settings report

This commit is contained in:
linuswck 2024-04-05 16:13:32 +08:00
parent 0a992c1dc8
commit e160316bfc
1 changed files with 12 additions and 0 deletions

View File

@ -56,6 +56,7 @@ struct Settings {
ld_drive_current_limit: ElectricCurrent, ld_drive_current_limit: ElectricCurrent,
pd_mon_params: pd_mon_params::Parameters, pd_mon_params: pd_mon_params::Parameters,
ld_pwr_limit: Power, ld_pwr_limit: Power,
ld_terms_short: bool,
} }
impl Default for Settings { impl Default for Settings {
@ -67,6 +68,7 @@ impl Default for Settings {
ld_drive_current_limit: ElectricCurrent::new::<milliampere>(0.0), ld_drive_current_limit: ElectricCurrent::new::<milliampere>(0.0),
pd_mon_params: pd_mon_params::Parameters::default(), pd_mon_params: pd_mon_params::Parameters::default(),
ld_pwr_limit: Power::new::<milliwatt>(0.0), ld_pwr_limit: Power::new::<milliwatt>(0.0),
ld_terms_short: false,
} }
} }
} }
@ -111,10 +113,12 @@ impl LdDrive{
pub fn ld_short(&mut self) { pub fn ld_short(&mut self) {
self.ctrl.ld_short_enable(); self.ctrl.ld_short_enable();
self.settings.ld_terms_short = true;
} }
pub fn ld_open(&mut self) { pub fn ld_open(&mut self) {
self.ctrl.ld_short_disable(); self.ctrl.ld_short_disable();
self.settings.ld_terms_short = false;
} }
pub fn power_up(&mut self){ pub fn power_up(&mut self){
@ -221,6 +225,7 @@ impl LdDrive{
ld_drive_current_limit: LdSettingsSummaryField { value: settings.ld_drive_current_limit, max: Settings::LD_CURRENT_MAX}, ld_drive_current_limit: LdSettingsSummaryField { value: settings.ld_drive_current_limit, max: Settings::LD_CURRENT_MAX},
pd_mon_params: settings.pd_mon_params, pd_mon_params: settings.pd_mon_params,
ld_pwr_limit: settings.ld_pwr_limit, ld_pwr_limit: settings.ld_pwr_limit,
ld_terms_short: settings.ld_terms_short,
} }
} }
@ -231,6 +236,12 @@ impl LdDrive{
self.settings.pd_mon_params = settings.pd_mon_params; self.settings.pd_mon_params = settings.pd_mon_params;
self.settings.ld_pwr_limit = settings.ld_pwr_limit; self.settings.ld_pwr_limit = settings.ld_pwr_limit;
if self.settings.ld_terms_short {
self.ld_short();
} else {
self.ld_open();
}
if settings.default_pwr_on { if settings.default_pwr_on {
self.power_up(); self.power_up();
} else { } else {
@ -246,6 +257,7 @@ pub struct LdSettingsSummary {
ld_drive_current_limit: LdSettingsSummaryField<ElectricCurrent>, ld_drive_current_limit: LdSettingsSummaryField<ElectricCurrent>,
pd_mon_params: pd_mon_params::Parameters, pd_mon_params: pd_mon_params::Parameters,
ld_pwr_limit: Power, ld_pwr_limit: Power,
ld_terms_short: bool,
} }
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)] #[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]