#ifndef POTENTIOMETER_h
#define POTENTIOMETER_h

class Potentiometer
{

	int EMA_S = 0;          //initialization of EMA S
	float EMA_a = 0.6;

	int _pin;
	int _id;

	int _value;
	int _previousReading;

	bool _inputFlag = false;
	bool _changeFlag = false;

	unsigned long _previousTimer;
	int _interval = 200;

	void (*_cb)(Potentiometer*, uint8_t, uint8_t); // Callback function
	/**
	   @brief What does this do?
	 */
	int _read();
	/**
	   @brief What does this do?
	 */
	void _setValue(int x);

public:

	static const uint8_t kEventStableUpdate = 0;
	static const uint8_t kEventUnstableUpdate = 1;

	Potentiometer(int pin, int id = 99) : _pin(pin), _id(id);
	/**
	   @brief What does this do?
	 */
	void setEventHandler(void (*function)(Potentiometer*, uint8_t, uint8_t));
	/**
	   @brief What does this do?
	 */
	int getValue();
	/**
	   @brief What does this do?
	 */
	int getId();
	/**
	   @brief What does this do?
	 */
	void check();
};

#endif