Closed foxsam21 closed 4 years ago
yes. I use it this way.
Here some snippets, exctracted from the RotaryElement of the HomeDing library:
globals:
RotaryEncoder *_encoder;
long _value = 0;
/**
* @brief The interrupt service routine to check the signals from the rotary encoder
*/
ICACHE_RAM_ATTR void _checkPosition()
{
_encoder->tick(); // just call tick() to check the state.
}
in init():
_encoder = new RotaryEncoder(_pin1, _pin2);
pinMode(_pin1, INPUT_PULLUP);
attachInterrupt(_pin1, _checkPosition, CHANGE);
pinMode(_pin2, INPUT_PULLUP);
attachInterrupt(_pin2, _checkPosition, CHANGE);
in loop():
_encoder->tick(); // just call tick() to check the state.
long newPos = _encoder->getPosition();
if (newPos != _value) {
_value = newPos;
// use new _value
...
}
Is this library's interrupt rotary encoder compatible with esp8266? It seems like its not because of the use of pin change interupt vs external interrupt. What can I look into to change the type of interrupt for this library?