Skip to content

Add support for I2CEncoder V2.1 rotary encoders #56

@cameronprince

Description

@cameronprince

Hello,

I'd like to extend micropython-micro-gui to include support for the I2CEncoder V2.1 encoders (https://www.tindie.com/products/saimon/i2cencoder-v21-connect-rotary-encoder-on-i2c-bus/).

Could you please take a look at #55 and let me know if I'm on the right track?

I'm instantiating the i2cEncoderLibV2 object for the encoder in hardware_setup.py and passing the object to Display as display = Display(ssd, None, None, None, False, None, encoder)

I didn't want to directly couple the i2cEncoderLibV2 library to ugui.py, so an isinstance check isn't possible in the Display method. I went with this for now, but not sure if there's a better way:

        if incr is False:  # Special encoder-only mode
            if not isinstance(encoder, (int, bool)):
                assert touch is False and nxt is None and sel is None and prev is None and decr is None, "Invalid args"
                ipdev = InputI2CEnc(encoder)
            else:
                ev = isinstance(encoder, int)
                assert ev and touch is False and decr is None and prev is not None, "Invalid args"
                ipdev = InputEnc(nxt, sel, prev, encoder)

It looks like we'll possibly need a new version of the Pushbutton primitive, too, or just handle the button completely in InputI2CEnc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions