fix encodeur lib

This commit is contained in:
Clement 2023-10-20 20:40:04 +02:00
parent f5e79c6405
commit aa2cb1fb4c

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;
}