Skip to content
Snippets Groups Projects
Potentiometer.hpp 954 B
Newer Older
#ifndef POTENTIOMETER_h
#define POTENTIOMETER_h

Matthew's avatar
Matthew committed
class Potentiometer
{
Matthew's avatar
Matthew committed
	int EMA_S = 0;          //initialization of EMA S
	float EMA_a = 0.6;
Matthew's avatar
Matthew committed
	int _pin;
	int _id;
Matthew's avatar
Matthew committed
	int _value;
	int _previousReading;
Matthew's avatar
Matthew committed
	bool _inputFlag = false;
	bool _changeFlag = false;
Matthew's avatar
Matthew committed
	unsigned long _previousTimer;
	int _interval = 200;
Matthew's avatar
Matthew committed
	void (*_cb)(Potentiometer*, uint8_t, uint8_t); // Callback function
Matthew's avatar
Matthew committed
	/**
	   @brief What does this do?
	 */
Matthew's avatar
Matthew committed
	int _read();
Matthew's avatar
Matthew committed
	/**
	   @brief What does this do?
	 */
Matthew's avatar
Matthew committed
	void _setValue(int x);
Matthew's avatar
Matthew committed
public:
Matthew's avatar
Matthew committed
	static const uint8_t kEventStableUpdate = 0;
	static const uint8_t kEventUnstableUpdate = 1;
Matthew's avatar
Matthew committed
	Potentiometer(int pin, int id = 99) : _pin(pin), _id(id);
Matthew's avatar
Matthew committed
	/**
	   @brief What does this do?
	 */
Matthew's avatar
Matthew committed
	void setEventHandler(void (*function)(Potentiometer*, uint8_t, uint8_t));
Matthew's avatar
Matthew committed
	/**
	   @brief What does this do?
	 */
Matthew's avatar
Matthew committed
	int getValue();
Matthew's avatar
Matthew committed
	/**
	   @brief What does this do?
	 */
Matthew's avatar
Matthew committed
	int getId();
Matthew's avatar
Matthew committed
	/**
	   @brief What does this do?
	 */
Matthew's avatar
Matthew committed
	void check();