diff --git a/src/laser_diode/laser_diode.rs b/src/laser_diode/laser_diode.rs index d0750f4..b70111c 100644 --- a/src/laser_diode/laser_diode.rs +++ b/src/laser_diode/laser_diode.rs @@ -50,6 +50,7 @@ impl Settings{ #[derive(Deserialize, Serialize, Clone, Copy, Debug, Tree)] struct Settings { + pwr_on: bool, ld_drive_current: ElectricCurrent, ld_drive_current_limit: ElectricCurrent, pd_responsitivity: pd_responsitivity::Parameters, @@ -59,6 +60,7 @@ struct Settings { impl Default for Settings { fn default() -> Self { Self { + pwr_on: false, ld_drive_current: ElectricCurrent::new::(0.0), ld_drive_current_limit: ElectricCurrent::new::(0.0), pd_responsitivity: pd_responsitivity::Parameters::default(), @@ -124,10 +126,12 @@ impl LdDrive{ // 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.settings.pwr_on = true; } pub fn power_down(&mut self){ LdPwrExcProtector::pwr_off(); + self.settings.pwr_on = false; } pub fn get_pd_i(&mut self) -> ElectricCurrent { @@ -205,6 +209,7 @@ impl LdDrive{ pub fn get_settings_summary(&mut self) -> LdSettingsSummary { let settings = self.settings; LdSettingsSummary { + pwr_on: self.settings.pwr_on, ld_drive_current: LdSettingsSummaryField { value: settings.ld_drive_current, max: Settings::LD_CURRENT_MAX}, ld_drive_current_limit: LdSettingsSummaryField { value: settings.ld_drive_current_limit, max: Settings::LD_CURRENT_MAX}, pd_responsitivity: settings.pd_responsitivity, @@ -215,6 +220,7 @@ impl LdDrive{ #[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)] pub struct LdSettingsSummary { + pwr_on: bool, ld_drive_current: LdSettingsSummaryField, ld_drive_current_limit: LdSettingsSummaryField, pd_responsitivity: pd_responsitivity::Parameters, diff --git a/src/thermostat/thermostat.rs b/src/thermostat/thermostat.rs index e35b253..a80ca40 100644 --- a/src/thermostat/thermostat.rs +++ b/src/thermostat/thermostat.rs @@ -28,6 +28,7 @@ pub const R_SENSE: ElectricalResistance = ElectricalResistance { #[derive(Deserialize, Serialize, Clone, Copy, Debug, Tree)] pub struct TecSettings { + pub pwr_on: bool, pub center_pt: ElectricPotential, pub max_v_set: ElectricPotential, pub max_i_pos_set: ElectricCurrent, @@ -89,6 +90,7 @@ impl TecSettings{ impl Default for TecSettings { fn default() -> Self { Self { + pwr_on: false, center_pt: ElectricPotential::new::(1.5), max_v_set: ElectricPotential::new::(5.0), max_i_pos_set: ElectricCurrent::new::(1.0), @@ -108,6 +110,7 @@ pub struct Thermostat { #[derive(Deserialize, Serialize, Copy, Clone, Debug, Tree)] pub struct ThermostatSettingsSummary { + pwr_on: bool, tec_settings: TecSettingSummary, pid_params: PidParams, temp_mon_settings: TempMonSettings, @@ -187,12 +190,14 @@ impl Thermostat{ pub fn power_up(&mut self){ self.max1968.power_up(); + self.tec_settings.pwr_on = true; } pub fn power_down(&mut self){ self.max1968.power_down(); self.pid_ctrl_ch0.reset_pid_state(); self.set_i(ElectricCurrent::new::(0.0)); + self.tec_settings.pwr_on = true; } fn set_center_pt(&mut self, value: ElectricPotential){ @@ -384,6 +389,7 @@ impl Thermostat{ pub fn get_settings_summary(&mut self) -> ThermostatSettingsSummary { ThermostatSettingsSummary { + pwr_on: self.tec_settings.pwr_on, tec_settings: self.get_tec_settings(), pid_params: self.get_pid_settings(), temp_mon_settings: self.get_temp_mon_settings(),