2023-10-20 20:41:46 +02:00

86 lines
1.4 KiB
C++

#ifndef SWITCHABLEENCODEUR_H
#define SWITCHABLEENCODEUR_H
#include "Encoder.h"
class SwitchableEncodeur : public Encoder {
public:
/**
* @brief Construct a new Switchable Encodeur object
*
* @param pin1 ENCODER_DT
* @param pin2 ENCODER_CLK
* @param pinSW ENCODER_SW
* @param nbMenu nombre D'état du system
*/
SwitchableEncodeur(uint8_t pin1, uint8_t pin2, uint8_t pinSW, int nbMenu = 0);
/**
* @brief reset the menu
*/
void resetMenu();
/**
* @brief add one to the menu
*/
void addMenu();
/**
* @brief Get the Menu number
* @return int
*/
int getMenu();
/**
* @brief Get return the encodeur value
*
* @return int dernière valeur de l'encodeur
*/
int getValue();
/**
* @brief update the encodeur value
*
* @return true the value has changed
* @return false the value has not changed
*/
bool update();
/**
* @brief reset the encodeur value
*/
void resetValue();
static SwitchableEncodeur* getInstance();
private:
static SwitchableEncodeur* instance;
/**
* @brief menu actuel
*/
int menu;
/**
* @brief old position of the encoder
*/
int oldPosition = -999;
/**
* @brief old menu number
*/
int oldMenu = -999;
/**
* @brief nombre de menu
*/
int nbMenu;
};
#endif