-
Notifications
You must be signed in to change notification settings - Fork 218
Encoder: add support for reading/writing sysfs attributes #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+337
−140
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sync from upstream
dplanella
commented
Nov 28, 2017
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright (c) 2014 MIT OpenCourseWare |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a proper copyright assignment with the right owner. As it stands now, it's a boiler plate assignment.
@dplanella thanks, I'll merge this and fix up the copyright header afterwards. |
pdp7
added a commit
that referenced
this pull request
Dec 1, 2017
Features: * Issue #194: Encoder position cannot be set * PR #205: Encoder: add support for reading/writing sysfs attributes Fixes: * Issue #198: use https for DEFAULT_URL in distribute_setup.py * Issue #197: Fix leak of pwm enable file descriptor * Issue #189: Fix seg fault of PWM in Python 3.6 * Issue #180: Clarify there is no 0 prefix for pin lables * PR #201: Encoder: do kernel check, PEP8 cleanup * PR #202: Encoder: corrected kernel check logic * PR #207: Encoder: improved usage adocumentation * PR #210: Encoder: fix sysfs import, make code Python 3 compatible * PR #212: Encoder: fix Python 3 compatibility * PR #213: Encoder: fix frequency calculation from period shortlog: * David Planella (18): * Encoder: initialize only the given channel * Sync from master * Encoder: do kernel check, PEP8 cleanup * Encoder: added sysfs module * Encoder: use sysfs to write QEP attributes * Encoder: corrected kernel check logic * Merge pull request #2 from adafruit/master * Encoder: convert get/set methods to properties, update apidoc strings * Encoder: updated README * Encoder: add README apt install clarification * Encoder: copyright assignment note, updated comments * Encoder: added usage notes * Encoder: improved usage documentation * Encoder: minor fix to usage example * Encoder: added a note about permissions * Encoder: switched sysfs to be a relative import compatible with Python 2 and 3 * Encoder: use items() instead of iteritems() to be Python 3 compatible * Encoder: fix frequency getter * Drew Fustini (18): * use https for DEFAULT_URL in distribute_setup.py (#198) * fix except syntax for Python 3 * use dict.items() instead of dict.iteritems() for Python 3 * fix error in set_brightness() * close enable_fd when stopping PWM output (#197) * Merge pull request #199 from dplanella/patch-1 * Fix leak of pwm enable file descriptor (#197) * Merge pull request #201 from dplanella/encoder-cleanup * remove test_rotary.py as not valid for pytest * Fix seg fault of PWM in Python 3.6 (#189) * Merge pull request #202 from dplanella/patch-2 * Clarify there is no 0 prefix for pin lables (#180) * Merge pull request #205 from dplanella/encoder-sysfs * assign copyright for new file to Adafruit Industries * Add bash scripts to help install and test * Merge pull request #212 from dplanella/patch-4 * Merge pull request #207 from dplanella/patch-3 * Merge pull request #213 from dplanella/fix-encoder-frequency Signed-off-by: Drew Fustini <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds support for reading and writing the eqep attributes in the sys filesystem. As such, on a given eqep channel, it allows disabling/enabling it, getting/setting its mode, getting/setting the position and getting/setting the update frequency.
To do this, it makes use of the sysfs library. Given its small size (it's simply a class), the library has been included in the repository, so that adding a new dependency is avoided. Furthermore, the library does not seem to be available on https://pypi.python.org.
IMPORTANT: the header comment on the sysfs.py file contains the (MIT) license text and the list of original authors. It seems the code originated from a stackoverflow snippet, which was then published on github as the sysfs library. The license was set as MIT upon doing that, but the copyright assignment was left as "Copyright (c) 2014 MIT OpenCourseWare", which is most probably boilerplate.
Before merging the branch, you might want to fix that and set a proper copyright owner (e.g. AdaFruit or the original author). How that's done, I'll leave it up to you :)