Coder Social home page Coder Social logo

raphaelyancey / pyky040 Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 16.0 78 KB

๐ŸŽ› High-level Python interface for the KY040 rotary encoder

Home Page: https://pypi.org/project/pyky040/

License: GNU General Public License v3.0

Python 100.00%
encoder gpio python raspberry-pi

pyky040's People

Contributors

dtrv avatar raphaelyancey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pyky040's Issues

Switch Pin with "device" configuration

I'm trying to use the "device" configuration rather than the GPIO pins and I have it working perfectly for the rotary encoder. How would I go about monitoring the button pushes through the same "device" method?

Thanks
Kris

CLK and DT -- pull up to remove dependency on carrier board?

Hi,

Looking at the code it seems DT + CLK are pulled low. The common carrier board has 10K pull-ups, which presumably override this so the DT + CLK become pulled-up.

Is there a reason why they're pulled down and not up in the code? Potentially, if they were pulled up I could connect a rotary encoder without the carrier board or external pull ups.

Thanks!

Callan

Double input

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)

Custom step start

Try adding a start=0 to the encoder setup, so that it starts at 0 and if you turn the encoder ti negtive values it gets to -1

double input

Hi, I have an issue using this useful library.
I get double input either by rotating as well as pressing the switch. (using it on a raspberry pi 3 b+)

I mean, when rotating by 1, I get

The scale position is 1
The scale position is 2

then

The scale position is 3
The scale position is 4

But I can bear with that for what I have to use it.

Major problem are with the switch. When pressing I get

Button pressed
Button pressed

And I can't use it like this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.