From 0e087c699239db86b5ab086325a2b3c1f6ecaa2f Mon Sep 17 00:00:00 2001 From: linuswck Date: Thu, 18 Apr 2024 15:36:13 +0800 Subject: [PATCH] ld: ld_soft_i_limit now limits ld_i_out being set --- src/laser_diode/laser_diode.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laser_diode/laser_diode.rs b/src/laser_diode/laser_diode.rs index 79e3b8d..1282778 100644 --- a/src/laser_diode/laser_diode.rs +++ b/src/laser_diode/laser_diode.rs @@ -148,8 +148,8 @@ impl LdDrive{ } pub fn ld_set_i(&mut self, i: ElectricCurrent){ - self.settings.ld_drive_current = i; - LdCurrentOutCtrlTimer::set_target_i_and_listen_irq(i, self.ctrl.get_i_set()); + self.settings.ld_drive_current = i.min(self.settings.ld_drive_current_limit); + LdCurrentOutCtrlTimer::set_target_i_and_listen_irq(self.settings.ld_drive_current, self.ctrl.get_i_set()); } pub fn poll_and_update_output_current(&mut self) -> ElectricCurrent {