After you mentioned an encoder with four callback per click I looked for different types of encoders: The topic is more complicated than I thought.
There are encoders without any notch/click. The current implementation would be the best for these types.
There are encoders with click and the switches toggle BETWEEN the stable positions. This is the most common case I think.
There are encoders where one switch is at the stable click position. Here the pins are not symmetric and must be handled differently. Perhaps your last mentions encoder is of this type? Do you know the name of your 4-steps-per-click encoder?
??? Maybe there are even more?
Espruino is such a great platform so we should supported each type out of the box with simple parameterization and not choose one in favor of the others. The principle of a rotary encoder is the same only the state machine differs.
Next I will play a little bit with different rotary encoders. I will try to merge the current module code with the attached version and generalize the module. The current module behavior (+/-2) could then be the default one. Existing clients will not be broken. And the documentation should point to the parameterization possibilities.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
After you mentioned an encoder with four callback per click I looked for different types of encoders: The topic is more complicated than I thought.
Espruino is such a great platform so we should supported each type out of the box with simple parameterization and not choose one in favor of the others. The principle of a rotary encoder is the same only the state machine differs.
I have created a small pull request to initialize the current module correctly.
https://github.com/espruino/EspruinoDocs/pull/187 → Solution for 1)
Next I will play a little bit with different rotary encoders. I will try to merge the current module code with the attached version and generalize the module. The current module behavior (+/-2) could then be the default one. Existing clients will not be broken. And the documentation should point to the parameterization possibilities.
What do you think? Should I try this?