feat:encoder with existing lib (#2)

Co-authored-by: Clement <c.boesmier@aptatio.com>
Reviewed-on: #2
This commit is contained in:
2023-10-20 18:32:17 +02:00
parent 6e2da886fc
commit 3a6d55c646
19 changed files with 1943 additions and 8 deletions

View File

@ -0,0 +1,80 @@
#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 nombre de menu
*/
int nbMenu;
};
#endif