65 lines
1.1 KiB
C
Raw Normal View History

2023-08-11 16:40:06 +02:00
#ifndef ENCODER_H
#define ENCODER_H
#include <Arduino.h>
class Encoder{
public:
/**
* @brief Construct a new Encoder object with the given pins
*
* @param pinSW encoder switch pin
* @param pinDT encoder DT pin
* @param pinCLK encoder CLK pin
*/
Encoder(int pinSW, int pinDT, int pinCLK);
/**
* @brief returns the instance of the encoder
*/
static Encoder* getInstance();
private:
/**
* @brief pinSW is the pin number of the switch
*/
int pinSW;
/**
* @brief pinDT is the pin number of the DT pin
*/
int pinDT;
/**
* @brief pinCLK is the pin number of the CLK pin
*/
int pinCLK;
/**
* @brief swEvent is the event called when the switch is pressed
*/
IRAM_ATTR static void swEvent();
/**
* @brief dtEvent is the event called when the encoder is turned
*/
IRAM_ATTR static void dtEvent();
/**
* @brief number is the current number of the encoder
*/
int number;
/**
* @brief instance is the instance of the encoder
*/
static Encoder* instance;
};
#endif