feat: led-lib (#3)

This commit is contained in:
2023-10-20 20:51:54 +02:00
parent 3a6d55c646
commit 8edae04556
8 changed files with 126 additions and 1 deletions

View File

@ -68,6 +68,11 @@ private:
*/
int oldPosition = -999;
/**
* @brief old menu number
*/
int oldMenu = -999;
/**
* @brief nombre de menu
*/

View File

@ -13,6 +13,7 @@ SwitchableEncodeur::SwitchableEncodeur(uint8_t pin1, uint8_t pin2, uint8_t pinSW
pinMode(pinSW, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pinSW), switchEncoder, RISING);//FIXME: maybe change to FALLING
this->oldPosition = -999;
this->oldMenu = -999;
}
@ -38,7 +39,8 @@ SwitchableEncodeur* SwitchableEncodeur::getInstance() {
bool SwitchableEncodeur::update() {
bool sortie = false;
long newPosition = this->read()/4;
if (newPosition != this->oldPosition) {
if (newPosition != this->oldPosition || this->menu != this->oldMenu) {
this->oldMenu = this->menu;
this->oldPosition = newPosition;
sortie = true;
}