feat:encoder with existing lib (#2)
Co-authored-by: Clement <c.boesmier@aptatio.com> Reviewed-on: #2
This commit is contained in:
80
lib/SwitchableEncodeur/include/SwitchableEncodeur.h
Normal file
80
lib/SwitchableEncodeur/include/SwitchableEncodeur.h
Normal 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
|
Reference in New Issue
Block a user