diff --git a/src/laser_diode/laser_diode.rs b/src/laser_diode/laser_diode.rs index dc01280..4948b1c 100644 --- a/src/laser_diode/laser_diode.rs +++ b/src/laser_diode/laser_diode.rs @@ -117,13 +117,14 @@ impl LdDrive{ self.ctrl.ld_short_disable(); } - pub fn power_up(&mut self){ + pub fn power_up(&mut self){ + let prev_i_set = LdCurrentOutCtrlTimer::get_target_i(); LdCurrentOutCtrlTimer::reset(); let _ = self.ctrl.set_i(ElectricCurrent::new::(0.0), Settings::LD_DRIVE_TRANSIMPEDANCE, Settings::DAC_OUT_V_MAX); LdPwrExcProtector::pwr_on_and_arm_protection(); // Wait for LD Power Supply to start up before driving current to laser diode sleep(30); - self.ld_set_i(self.settings.ld_drive_current); + self.ld_set_i(prev_i_set); self.settings.pwr_on = true; } diff --git a/src/laser_diode/ld_current_out_ctrl_timer.rs b/src/laser_diode/ld_current_out_ctrl_timer.rs index 780d787..3a3fb84 100644 --- a/src/laser_diode/ld_current_out_ctrl_timer.rs +++ b/src/laser_diode/ld_current_out_ctrl_timer.rs @@ -63,6 +63,13 @@ impl LdCurrentOutCtrlTimer { } } + pub fn get_target_i() -> ElectricCurrent { + if let Some(ref mut ld_current_out_ctrl_timer ) = LdCurrentOutCtrlTimer::get() { + return ld_current_out_ctrl_timer.target_i + } + ElectricCurrent::new::(0.0) + } + pub fn set_alarm() { if let Some(ref mut ld_current_out_ctrl_timer ) = LdCurrentOutCtrlTimer::get() { ld_current_out_ctrl_timer.timeout = true;