/* * boost_control.h * * Created on: 18. aug. 2019 * Author: Ola Ruud */ #pragma once #include "engine.h" #include "periodic_task.h" #include "closed_loop_controller.h" #include "pid.h" class SimplePwm; class BoostController : public ClosedLoopController { public: DECLARE_ENGINE_PTR; void init(SimplePwm* pmw, const ValueProvider3D* openLoopMap, const ValueProvider3D* closedLoopTargetMap, pid_s* pidParams); void update(); // Called when the configuration may have changed. Controller will // reset if necessary. void onConfigurationChange(pid_s* previousConfiguration); // Helpers for individual parts of boost control expected observePlant() const override; expected getSetpoint() const override; expected getOpenLoop(float target) const override; expected getClosedLoop(float target, float manifoldPressure) override; void setOutput(expected outputValue) override; private: bool m_shouldResetPid = false; Pid m_pid; const ValueProvider3D* m_openLoopMap = nullptr; const ValueProvider3D* m_closedLoopTargetMap = nullptr; SimplePwm* m_pwm = nullptr; }; void startBoostPin(); void initBoostCtrl(DECLARE_ENGINE_PARAMETER_SIGNATURE); void setDefaultBoostParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE); void onConfigurationChangeBoostCallback(engine_configuration_s *previousConfiguration); void updateBoostControl();