Skip to content

Double input #4

@SebDominguez

Description

@SebDominguez

I'm opening a new issue to hopefully get more visibility there...

Having a similar same issue:
inc_callback, dec_callback& chg_callback get called multiple time for each "steps" of my rotary encoder. sw_callback is called once as expected. I tried to change the polling_interval, but this seems to make things worst as if I keep turning the encoder clockwise I'll get the counterclockwise callback executed.

ezgif com-video-to-gif

Adding logger.info(self.polling_interval) on pyky040.py at line 47 and 133 give me the following output:INFO:root:5

Maybe this is due to the cheap construction of the rotary encoder module? I'm using those one (I thing you are using the same one)

iu-1

With the threaded example the callback get called only twice

2

this is the code I run

# Import the module and threading
from pyky040 import pyky040
import threading
import time

# Define your callback
def up_callback(scale_position):
    print("up")

def down_callback(scale_position):
    print("down")

def pressed_callback():
    print("pressed")

# Init the encoder pins
encoder = pyky040.Encoder(CLK=5, DT=6, SW=13, polling_interval=5)

# Setup the options and callbacks (see documentation)
encoder.setup(scale_min=0, scale_max=100, step=1, inc_callback=up_callback, dec_callback=down_callback, sw_callback=pressed_callback)

# Create the thread
my_thread = threading.Thread(target=encoder.watch)

my_thread.daemon=True

# Launch the thread
my_thread.start()

# Do other stuff
print('Other stuff...')
while True:
    print('Looped stuff...')
    time.sleep(10)
# ... this is also where you can setup other encoders!

Well I just received another rotary encoder (PEC16-4220F-S0024) and I still have this issue

Originally posted by @SebDominguez in #1 (comment)

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