Skip to content
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

add touchio as an optional type of input #8

Merged
merged 2 commits into from Mar 5, 2020

Conversation

iraytrace
Copy link
Contributor

I find sometimes I wanted to use touchio inputs with Debouncer. Simple check for that type allows this.

@kattni kattni requested a review from dastels January 8, 2020 18:19
@kattni
Copy link
Contributor

kattni commented Jan 8, 2020

@dastels Please review and test this. I will deal with the documentation building failure if we intend to move forward with the PR. Thanks!

Copy link
Contributor

@FoamyGuy FoamyGuy left a 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

@kattni
Copy link
Contributor

kattni commented Jan 29, 2020

@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
Copy link
Member

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)):
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants