Rotary encoders are notoriously difficult to get right.
Although I haven’t used this new encoder class yet, it looks very interesting. From active Teensy forum user Theremingenieur, it allows initialization with upper and/or lower limits.
You can find the code in this thread.
While working on a project to automate environmental control in our greenhouse, I needed to implement a menu interface on a small OLED display. In this sub-project, meant to test the concept, I’ve used a Teensy 3.1, a small I2C-driven 0.96" monochrome OLED display and a rotary encoder.
Bill of materials: Teensy 3.1 - the Teensy 3.1 is no longer available, but you can easily find the compatible Teensy 3.