-
Notifications
You must be signed in to change notification settings - Fork 15
add touchio as an optional type of input #8
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
Conversation
@dastels Please review and test this. I will deal with the documentation building failure if we intend to move forward with the PR. Thanks! |
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.
I tested this version of the adafruit_debouncer library using a CPX device with touchio working on pin A1
For testing I modified the Usage Example in the readme to include setting up the touchio pin. Everything is working as expected, after modifying the example I am seeing all of the correct print statements when using the touch pin. I also verified that DigitalInOut is still working as expected with the modified library by testing on one of the build-in buttons D4
@iraytrace There are documentation building issues on this PR that I cannot easily edit. If you are available, please ping me directly and I can help you walk though it. Otherwise, I will have someone submit your changes as a new PR with the documentation fixes included. |
@@ -48,6 +48,7 @@ | |||
import time | |||
import digitalio | |||
from micropython import const | |||
import touchio |
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.
this will stop the module from being importable on boards without touchio
@@ -62,7 +63,7 @@ def __init__(self, io_or_predicate, interval=0.010): | |||
:param int interval: bounce threshold in seconds (default is 0.010, i.e. 10 milliseconds) | |||
""" | |||
self.state = 0x00 | |||
if isinstance(io_or_predicate, digitalio.DigitalInOut): | |||
if isinstance(io_or_predicate, (digitalio.DigitalInOut, touchio.TouchIn)): |
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.
could this be changed to 'if hasattr(io_or_predicate, 'value')` ? This would mean that the import of touchio was not needed, but would also make it work with other io types, such as on a seesaw.
I find sometimes I wanted to use touchio inputs with Debouncer. Simple check for that type allows this.