From e160316bfceb10ff981e449655aad972c0345107 Mon Sep 17 00:00:00 2001 From: linuswck Date: Fri, 5 Apr 2024 16:13:32 +0800 Subject: [PATCH] ld: add ld_terms_short in settings report --- src/laser_diode/laser_diode.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/laser_diode/laser_diode.rs b/src/laser_diode/laser_diode.rs index df46529..0faa163 100644 --- a/src/laser_diode/laser_diode.rs +++ b/src/laser_diode/laser_diode.rs @@ -56,6 +56,7 @@ struct Settings { ld_drive_current_limit: ElectricCurrent, pd_mon_params: pd_mon_params::Parameters, ld_pwr_limit: Power, + ld_terms_short: bool, } impl Default for Settings { @@ -67,6 +68,7 @@ impl Default for Settings { ld_drive_current_limit: ElectricCurrent::new::(0.0), pd_mon_params: pd_mon_params::Parameters::default(), ld_pwr_limit: Power::new::(0.0), + ld_terms_short: false, } } } @@ -111,10 +113,12 @@ impl LdDrive{ pub fn ld_short(&mut self) { self.ctrl.ld_short_enable(); + self.settings.ld_terms_short = true; } pub fn ld_open(&mut self) { self.ctrl.ld_short_disable(); + self.settings.ld_terms_short = false; } 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}, pd_mon_params: settings.pd_mon_params, 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.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 { self.power_up(); } else { @@ -246,6 +257,7 @@ pub struct LdSettingsSummary { ld_drive_current_limit: LdSettingsSummaryField, pd_mon_params: pd_mon_params::Parameters, ld_pwr_limit: Power, + ld_terms_short: bool, } #[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)]