#ifndef _PID_H
#define _PID_H

#include <atmel_start.h>
#include <COAST.h>

// #define DEBUG_PID

typedef struct {
        //! controller setpoint
        float setpoint;
        //! the input of the last timestep
        float last_input;
        //! storage for integration
        float output_sum;
#ifdef DEBUG_PID
        float p_factor;
        float i_factor;
        float d_factor;
#endif
        //! timestep counter
        uint16_t id_cnt;
} pid_cntrl_t;

/*! use this function with a PID structure and an input to calculate
 *  the output for each timestep.
*/
float pid_compute(pid_cntrl_t *pid_inst, float input);

#endif
