• 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.

    1. There are encoders without any notch/click. The current implementation would be the best for these types.
    2. There are encoders with click and the switches toggle BETWEEN the stable positions. This is the most common case I think.
    3. 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?
    4. ??? 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.

    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?

About

Avatar for luwar @luwar started