raphaelyancey / pyky040 Goto Github PK
View Code? Open in Web Editor NEW๐ High-level Python interface for the KY040 rotary encoder
Home Page: https://pypi.org/project/pyky040/
License: GNU General Public License v3.0
๐ High-level Python interface for the KY040 rotary encoder
Home Page: https://pypi.org/project/pyky040/
License: GNU General Public License v3.0
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
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
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.
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)
With the threaded example the callback get called only twice
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)
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
Is it possible to have two options on the switch, pressed short and long?
Babau
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.