{ "info": { "author": "Raphael Yancey", "author_email": "pypi@raphaelyancey.fr", "bugtrack_url": null, "classifiers": [], "description": "# pyKY040\n\n**High-level Python module for the KY040 rotary encoder and switch** on Raspberry Pi and similar boards that use `RPi.GPIO`\n\n\"KY-040\n\n## Features\n\n- Increment callback\n- Decrement callback\n- Change callback (increment or decrement)\n- Switch press callback\n\n### Options\n\n- Scale mode (internal counter is bound between X and Y, and is given as argument in the callback functions)\n- Looped scale mode (from X to Y, then X again)\n- Custom scale step\n\n## Installation\n\n`pip install pyky040`\n\n## Usage\n\n### Basic\n\n```python\n# Import the module\nfrom pyky040 import pyky040\n\n# Define your callback\ndef my_callback(scale_position):\n print('Hello world! The scale position is {}'.format(scale_position))\n\n# Init the encoder pins\nmy_encoder = pyky040.Encoder(CLK=17, DT=18, SW=26)\n\n# Setup the options and callbacks (see documentation)\nmy_encoder.setup(scale_min=0, scale_max=100, step=1, chg_callback=my_callback)\n\n# Launch the listener\nmy_encoder.watch()\n\n# Mess with the encoder...\n# > Hello world! The scale position is 1\n# > Hello world! The scale position is 2\n# > Hello world! The scale position is 3\n# > Hello world! The scale position is 2\n# > Hello world! The scale position is 1\n```\n\n### In a thread\n\nAs the `watch()` method runs an infinite polling loop, you might want to run it in a thread if you don't want to block the rest of your script, or if you have **multiple encoders** to handle.\n\n```python\n# Import the module and threading\nfrom pyky040 import pyky040\nimport threading\n\n# Define your callback\ndef my_callback(scale_position):\n print('Hello world! The scale position is {}'.format(scale_position))\n\n# Init the encoder pins\nmy_encoder = pyky040.Encoder(CLK=17, DT=18, SW=26)\n\n# Setup the options and callbacks (see documentation)\nmy_encoder.setup(scale_min=0, scale_max=100, step=1, chg_callback=my_callback)\n\n# Create the thread\nmy_thread = threading.Thread(target=my_encoder.watch)\n\n# Launch the thread\nmy_thread.start()\n\n# Do other stuff\nprint('Other stuff...')\nwhile True:\n print('Looped stuff...')\n sleep(1000)\n# ... this is also where you can setup other encoders!\n\n# Mess with the encoder...\n# > Other stuff...\n# > Looped stuff...\n# > Hello world! The scale position is 1\n# > Hello world! The scale position is 2\n# > Hello world! The scale position is 3\n# > Looped stuff...\n# > Hello world! The scale position is 2\n\n```\n\n**Note:** The interruption of the module when running in threads is not yet handled, you might have to kill it by yourself \ud83d\udd2a\n\n## Documentation\n\n#### `Encoder(CLK=x, DT=y, SW=z)`\n\nInitializes the module with the specified encoder pins.\n\n- Options\n - `polling_interval` Specify the pins polling interval in ms (default 1ms)\n\n#### `Encoder.setup()`\n\nSetup the behavior of the module. All of the following keyword arguments are optional.\n\n- Callbacks\n - `inc_callback (function)` When the encoder is incremented (clockwise). Scale position as first argument.\n - `dec_callback (function)` When the encoder is decremented. Scale position as first argument.\n - `chg_callback (function)` When the encoder is either incremented or decremented. Scale position as first argument.\n - `sw_callback (function)` When the encoder switch is pressed\n\n- Scale mode\n - `scale_min (int/float)` Scale minimum\n - `scale_max (int/float)` Scale maximum\n - `loop (boolean)` Loop mode (defaults to `False`)\n - `step (int/float)` Scale step when incrementing or decrementing\n\n- Options\n - `sw_debounce_time (int/float)` Switch debounce time in ms (allow only one interrupt per X ms, dismiss others)\n\n**Note:** better keep using ints and not floats for more precise results.\n\n#### `Encoder.watch()`\n\nStarts the listener. The pins polling interval is `1ms` by default and can be customized (see `Encoder()`).\n\n## CHANGELOG\n\n**0.1.2**\n\n - Changed `__init_` args to kwargs for better readability and ease of use `Encoder(CLK=x, DT=y, SW=z)`\n - Added customizable debounce time (in ms) for the switch `setup(..., sw_debounce_time=300)`\n - Added customizable polling interval (in ms) `Encoder(..., polling_interval=1)`\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/raphaelyancey/pyKY040", "keywords": "keyes rotary encoder switch ky040", "license": "", "maintainer": "", "maintainer_email": "", "name": "pyky040", "package_url": "https://pypi.org/project/pyky040/", "platform": "", "project_url": "https://pypi.org/project/pyky040/", "project_urls": { "Bug Reports": "https://github.com/raphaelyancey/pyKY040/issues", "Homepage": "https://github.com/raphaelyancey/pyKY040", "Source": "https://github.com/raphaelyancey/pyKY040" }, "release_url": "https://pypi.org/project/pyky040/0.1.3/", "requires_dist": [ "RPi.GPIO" ], "requires_python": "", "summary": "High-level interface for the KY040 rotary encoder and switch.", "version": "0.1.3" }, "last_serial": 4008136, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "63d0cfe895014f7c9a48c32fff67800e", "sha256": "f457e8d10b3665088c85b382d7b2893141bcebc42a66c42fbee624e50d21b140" }, "downloads": -1, "filename": "pyky040-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "63d0cfe895014f7c9a48c32fff67800e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17635, "upload_time": "2018-05-09T23:57:37", "url": "https://files.pythonhosted.org/packages/63/3f/3823651a11a71279c3d1abafa2bf8c081db6628b0cec3ca3381ae0b45c2e/pyky040-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d33c33a588d0c606567f9e69136d3b9f", "sha256": "c8483ccf67c13b3c7c84cd07e69566b241d0ee7c2fd41143df65f0f6b6628939" }, "downloads": -1, "filename": "pyky040-0.1.0.tar.gz", "has_sig": false, "md5_digest": "d33c33a588d0c606567f9e69136d3b9f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4042, "upload_time": "2018-05-09T23:57:39", "url": "https://files.pythonhosted.org/packages/57/f2/a56ca316b81da0b400d4b62ac018992594bb52cd6989801e44a87b4d3c73/pyky040-0.1.0.tar.gz" } ], "0.1.0a0": [ { "comment_text": "", "digests": { "md5": "c51aadf27065fbff33a60636aacc9185", "sha256": "1abb8a8cff183f2e55e0b5232e804972f3f8647f41aa1641820b0a19b04856a7" }, "downloads": -1, "filename": "pyky040-0.1.0a0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c51aadf27065fbff33a60636aacc9185", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17641, "upload_time": "2018-05-10T12:57:52", "url": "https://files.pythonhosted.org/packages/c7/04/e2eee6aeb1f904fc08ea770f3d3eddc1340f7d8b421234a3a3fd9de4480b/pyky040-0.1.0a0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ee17b7546e4693dafb1939eba50dc0f2", "sha256": "fce73f067575cf6412eb865532be0c6fd3f324c8c2db6311cb5325278011824e" }, "downloads": -1, "filename": "pyky040-0.1.0a0.tar.gz", "has_sig": false, "md5_digest": "ee17b7546e4693dafb1939eba50dc0f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4039, "upload_time": "2018-05-10T12:57:54", "url": "https://files.pythonhosted.org/packages/f0/aa/8ce26f1cce1d05141d4524283557851a6d5d6df3a313066edd16037d147e/pyky040-0.1.0a0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "2903dbbdd0ea6b44e9942e380652412b", "sha256": "5929f2715b489168150db18202196f092f515b7094a010932d839cc3687c4f79" }, "downloads": -1, "filename": "pyky040-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2903dbbdd0ea6b44e9942e380652412b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17618, "upload_time": "2018-05-10T13:00:38", "url": "https://files.pythonhosted.org/packages/ff/6f/e8795923d0db1092f5c3f5478ebe648d85b343c210fcb28fd92a7a27d903/pyky040-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "66316aea62af1c7864beb7f345839e74", "sha256": "682f2d7a0feee82cf1a84de5026ed0aaeac346c4fded713143adf6b8f091baf0" }, "downloads": -1, "filename": "pyky040-0.1.1.tar.gz", "has_sig": false, "md5_digest": "66316aea62af1c7864beb7f345839e74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4037, "upload_time": "2018-05-10T13:00:40", "url": "https://files.pythonhosted.org/packages/3b/ea/02a094844abca801e692b11f28b4b4e13ee8493eca9de47819d2578fb6df/pyky040-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "2f9640edd4a32e1eddb02293442741c3", "sha256": "ae2b18fbbc292f7319be38cf46a33fee8aee83880145654f52c5fb08effb1e5e" }, "downloads": -1, "filename": "pyky040-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2f9640edd4a32e1eddb02293442741c3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 18013, "upload_time": "2018-06-27T14:20:39", "url": "https://files.pythonhosted.org/packages/4b/51/0c74d023d42663abd912af1add3ef7428a535ea020d2a9de9fdb37668e77/pyky040-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "93a1957e6034890b9b58fad3324ec367", "sha256": "91557d373155ef2167b6373d45939160e5b5084a0adea7993f20bcc2c6fd8cf3" }, "downloads": -1, "filename": "pyky040-0.1.2.tar.gz", "has_sig": false, "md5_digest": "93a1957e6034890b9b58fad3324ec367", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4481, "upload_time": "2018-06-27T14:20:40", "url": "https://files.pythonhosted.org/packages/34/a8/f8ac1216f48a0d54151c22b04879aec6101b72bb42b7a6b9bf387a05cb90/pyky040-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "c55a39ff39e52ff6e7ed07109f4c0b3a", "sha256": "d6c7a96de968d1e1df8de270e67d891c23f016d312ec7fa26a81f53eac71e6c2" }, "downloads": -1, "filename": "pyky040-0.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c55a39ff39e52ff6e7ed07109f4c0b3a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 18019, "upload_time": "2018-06-27T16:34:32", "url": "https://files.pythonhosted.org/packages/dd/31/c49323cafdcf011334ac7c225daf8f96d96ece0b23884894fa6f037ad7f6/pyky040-0.1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "391b1809bbc0444687aa63a5e15805f5", "sha256": "d4905d3c381be2d56f14e728656e75d138011d7d68ba91814fe2f4dd6b2bed0b" }, "downloads": -1, "filename": "pyky040-0.1.3.tar.gz", "has_sig": false, "md5_digest": "391b1809bbc0444687aa63a5e15805f5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4480, "upload_time": "2018-06-27T16:34:33", "url": "https://files.pythonhosted.org/packages/56/14/e514d1e786cf468c8d269ac15a65e8dd6c116bab2b90d4f0c5a90da55e7f/pyky040-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c55a39ff39e52ff6e7ed07109f4c0b3a", "sha256": "d6c7a96de968d1e1df8de270e67d891c23f016d312ec7fa26a81f53eac71e6c2" }, "downloads": -1, "filename": "pyky040-0.1.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c55a39ff39e52ff6e7ed07109f4c0b3a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 18019, "upload_time": "2018-06-27T16:34:32", "url": "https://files.pythonhosted.org/packages/dd/31/c49323cafdcf011334ac7c225daf8f96d96ece0b23884894fa6f037ad7f6/pyky040-0.1.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "391b1809bbc0444687aa63a5e15805f5", "sha256": "d4905d3c381be2d56f14e728656e75d138011d7d68ba91814fe2f4dd6b2bed0b" }, "downloads": -1, "filename": "pyky040-0.1.3.tar.gz", "has_sig": false, "md5_digest": "391b1809bbc0444687aa63a5e15805f5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4480, "upload_time": "2018-06-27T16:34:33", "url": "https://files.pythonhosted.org/packages/56/14/e514d1e786cf468c8d269ac15a65e8dd6c116bab2b90d4f0c5a90da55e7f/pyky040-0.1.3.tar.gz" } ] }