From ff3d9b790ab1aaf0d2886fb6940ceb73ba14f527 Mon Sep 17 00:00:00 2001 From: linuswck Date: Wed, 17 Jan 2024 17:13:27 +0800 Subject: [PATCH] thermostat: pid_state rename variables --- src/thermostat/pid_state.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/thermostat/pid_state.rs b/src/thermostat/pid_state.rs index 8f2add9..717bb07 100644 --- a/src/thermostat/pid_state.rs +++ b/src/thermostat/pid_state.rs @@ -23,11 +23,11 @@ const VREF_SENS: f64 = 3.3 / 2.0; pub struct PidState { pub adc_data: Option, pub adc_calibration: ad7172::ChannelCalibration, - pub adc_time: Instant, - pub adc_interval: Duration, + pub sample_ts: Instant, + pub sampling_interval: Duration, /// i_set 0A center point - pub center: ElectricPotential, - pub dac_value: ElectricPotential, + pub center_point: ElectricPotential, + pub dac_volt: ElectricPotential, pub pid_engaged: bool, pub pid: pid::Controller, pub sh: sh::Parameters, @@ -45,11 +45,11 @@ impl Default for PidState { PidState { adc_data: None, adc_calibration: ad7172::ChannelCalibration::default(), - adc_time: Instant::from_secs(0), + sample_ts: Instant::from_secs(0), // default: 10 Hz - adc_interval: Duration::from_millis(100), - center: ElectricPotential::new::(1.5), - dac_value: ElectricPotential::new::(0.0), + sampling_interval: Duration::from_millis(100), + center_point: ElectricPotential::new::(1.5), + dac_volt: ElectricPotential::new::(0.0), pid_engaged: false, pid: pid::Controller::new(pid::Parameters::default()), sh: sh::Parameters::default(), @@ -69,8 +69,8 @@ impl PidState { } else { Some(adc_data) }; - self.adc_interval = now - self.adc_time; - self.adc_time = now; + self.sampling_interval = now - self.sample_ts; + self.sample_ts = now; } /// Update PID state on ADC input, calculate new DAC output @@ -81,12 +81,12 @@ impl PidState { Some(pid_output) } - pub fn get_adc_time(&self) -> Time { - Time::new::(self.adc_time.total_millis() as f64) + pub fn get_sample_ts(&self) -> Time { + Time::new::(self.sample_ts.total_millis() as f64) } - pub fn get_adc_interval(&self) -> Time { - Time::new::(self.adc_interval.total_millis() as f64) + pub fn get_sampling_interval(&self) -> Time { + Time::new::(self.sampling_interval.total_millis() as f64) } pub fn get_adc(&self) -> Option {