#ifndef __PID_H_INCLUDED__
#define __PID_H_INCLUDED__

#include <stdint.h>

class PID {
public:
    PID ( double kP, double kI, double kD, double lI, uint32_t cD );

    double CalculateGain( double position );

    virtual void Set_Setpoint( double setpoint );

    double GetProportionalGain(void)
		{ return m_ProportionalGain; }

    double GetIntegralGain(void)
		{ return m_IntegralGain; }

    double GetDifferentialGain(void)
		{ return m_DifferentialGain; }

    void SetProportionalConstant( double kP )
        { m_KProportional = kP; };

    void SetIntegralConstant( double kI )
        { m_KIntegral = kI; }

    void SetDifferentialConstant( double kD )
        { m_KDifferential = kD; }

    void SetDifferentialCycle( uint32_t Dc )
        { m_DifferentialCycle = Dc; }

    double GetProportionalConstant(void)
		{ return m_KProportional; }

    double GetIntegralConstant(void)
		{ return m_KIntegral; }

    double GetDifferentialConstant(void)
		{ return m_KDifferential; }

    double GetIntegralLimit(void)
		{ return m_IntegralLimit; }

    double GetSetpoint(void)
		{ return m_Setpoint; }

private:
    double		m_KProportional;
    double		m_KIntegral;
    double		m_KDifferential;
    double		m_IntegralLimit;
    double		m_ProportionalGain;
    double		m_IntegralGain;
    double		m_DifferentialGain;
    double		m_Setpoint;
    double		m_Gain;
    uint32_t	m_DifferentialCycle;
    uint32_t	m_DifferentialCycleCount;
    double		m_ErrorSum;
    double      m_LastError;
};

#endif
/* End of File */
