Add stepwise controller
This adds the ability to use stepwise curves alongside
pid control. This creates a base controller class that
pidcontroller and stepwise controller inherit from.
Note: Hysteresis to come in follow-on patch
Tested-by:
Created a stepwise controller and noticed that when it
crossed a threshold that it contributed to the pwm setting.
Change-Id: I6cf842f80eaccafc905d620970afe91e2092d568
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/pid/stepwisecontroller.hpp b/pid/stepwisecontroller.hpp
new file mode 100644
index 0000000..c3af1a1
--- /dev/null
+++ b/pid/stepwisecontroller.hpp
@@ -0,0 +1,52 @@
+#pragma once
+
+#include "controller.hpp"
+#include "ec/stepwise.hpp"
+#include "fan.hpp"
+
+#include <memory>
+#include <vector>
+
+class ZoneInterface;
+
+class StepwiseController : public Controller
+{
+ public:
+ static std::unique_ptr<Controller>
+ CreateStepwiseController(ZoneInterface* owner, const std::string& id,
+ const std::vector<std::string>& inputs,
+ const ec::StepwiseInfo& initial);
+
+ StepwiseController(const std::string& id,
+ const std::vector<std::string>& inputs,
+ ZoneInterface* owner) :
+ Controller(),
+ _owner(owner), _id(id), _inputs(inputs)
+ {
+ }
+
+ float input_proc(void) override;
+
+ void output_proc(float value) override;
+
+ void process(void) override;
+
+ std::string get_id(void)
+ {
+ return _id;
+ }
+
+ ec::StepwiseInfo& get_stepwise_info(void)
+ {
+ return _stepwise_info;
+ }
+
+ protected:
+ ZoneInterface* _owner;
+
+ private:
+ // parameters
+ ec::StepwiseInfo _stepwise_info;
+ std::string _id;
+ std::vector<std::string> _inputs;
+};