EncoderLib is a library to handle a rotary encoder in MicroPython.
Functions:
encoder(clk, dt)
The encoder function initializes the library and it takes two parameters:
1. clk = pin number clk pin
2. dt = pin number dt pin
Example:
e = encoderLib.encoder(clk, dt)
getValue()
The getValue function returns the current rotary location.
example:
import encoderLib last = 0 e = encoderLib.encoder(12, 13) # Initializes the library with pin CLK on 12 and pin DT on 13 while True: # Infinite loop value = e.getValue() # Get rotary encoder value if value != last: # If there is a new value do last = value print(value) # In this case it prints the value
Nice to see a new library! Have you considered making the code pep8-compliant, so that it fits the rest of the python libraries better?
Also, perhaps using pin interrupts would make it more robust?