From be781f127575d507e4375a9044c1ff0898ab302f Mon Sep 17 00:00:00 2001 From: Chris Giacofei Date: Fri, 21 Jan 2022 11:44:28 -0500 Subject: [PATCH] Use overloaded functions for get/set. --- boil_kettle/boil_kettle.ino | 4 ++-- boil_kettle/thermoControl.cpp | 24 ++++++++++++++++-------- boil_kettle/thermoControl.h | 12 +++++++----- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/boil_kettle/boil_kettle.ino b/boil_kettle/boil_kettle.ino index ee8c41a..a177b56 100644 --- a/boil_kettle/boil_kettle.ino +++ b/boil_kettle/boil_kettle.ino @@ -120,8 +120,8 @@ void setup() { mqtt_client.setCallback(MessageReceived); KettleController.begin(I_CS1); - KettleController.SetHysteresis(config.hysteresis); - KettleController.SetThreshPWR(config.threshold); + KettleController.Hysteresis(config.hysteresis); + KettleController.ThreshPWR(config.threshold); // if you get a connection, report back via serial: if (Ethernet.linkStatus() == LinkON) { diff --git a/boil_kettle/thermoControl.cpp b/boil_kettle/thermoControl.cpp index c78f428..1585d76 100644 --- a/boil_kettle/thermoControl.cpp +++ b/boil_kettle/thermoControl.cpp @@ -10,8 +10,8 @@ void thermoControl::begin(int pinRTD) { outMax = 100; outMin = 10; OpMode = OFF; - SampleTime = 100; - lastTime = millis()-SampleTime; + SampleInterval = 100; + lastTime = millis()-SampleInterval; output_pwm = 0; control_temp = 0; hysteresis = 1.0; @@ -25,8 +25,8 @@ void thermoControl::begin(int pinRTD, double temp, double duty, double mpt, doub outMax = 100; outMin = 10; OpMode = OFF; - SampleTime = 100; - lastTime = millis()-SampleTime; + SampleInterval = 100; + lastTime = millis()-SampleInterval; output_pwm = duty; control_temp = temp; @@ -40,7 +40,7 @@ bool thermoControl::Compute() { double temp = RTD->temperature(r_nominal, r_ref); - if(timeChange>=SampleTime && OpMode == AUTOMATIC) { + if(timeChange>=SampleInterval && OpMode == AUTOMATIC) { double output; double error = control_temp - temp; @@ -78,18 +78,26 @@ void thermoControl::Setpoint(double temp) { control_temp = temp; } -void thermoControl::SetSampleTime(int NewSampleTime) { +void thermoControl::SampleTime(int NewSampleTime) { if (NewSampleTime > 0) { - SampleTime = (unsigned long)NewSampleTime; + SampleInterval = (unsigned long)NewSampleTime; } } -void thermoControl::SetPowerLimits(double Max, double Min) { +void thermoControl::PowerLimits(double Max, double Min) { if(Min >= Max) return; outMax = Max; outMin = Min; } +void thermoControl::Hysteresis(double hys) { + hysteresis = hys; +} + +void thermoControl::ThreshPWR(double thresh) { + max_pwr_threshold = thresh; +} + void thermoControl::Mode(modes newMode) { OpMode = newMode; } diff --git a/boil_kettle/thermoControl.h b/boil_kettle/thermoControl.h index 93e8830..86af5ea 100644 --- a/boil_kettle/thermoControl.h +++ b/boil_kettle/thermoControl.h @@ -19,7 +19,7 @@ class thermoControl { modes OpMode; - unsigned long SampleTime; + unsigned long SampleInterval; unsigned long lastTime; public: @@ -30,10 +30,12 @@ class thermoControl { void Power(double); double Setpoint(); void Setpoint(double); - void SetSampleTime(int); - void SetPowerLimits(double, double); - void SetHysteresis(double); - void SetThreshPWR(double); + void SampleTime(int); + void PowerLimits(double, double); + void Hysteresis(double); + void Hysteresis(); + void ThreshPWR(double); + void ThreshPWR(); void Mode(modes); modes Mode(); modes CycleMode();