-
Notifications
You must be signed in to change notification settings - Fork 71
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 iterable touchpad functionality #114
Conversation
@dhalbert Please take a look at your convenience! |
If this works I can add it to the CLUE as well. Is it worth doing for the Crickit? I added an issue there as well, but can remove it if it isn't worth doing for that one. |
I realize this is a good fit for |
Just checking in on this PR, let me know if anything else is needed! |
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 out successfully today.
I have a few small suggestions about the example code, but things are looking good to me beyond these.
I also made a build with this updated library for CPX Russian language. I believe this is one of the more space restricted ones. I did get a successful build with it.
@dhalbert you have any other thoughts on these changes?
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 apologize for missing the fact you reworked the original PR.
Ideally, as you mention, the way to do this would be to use board.<pin_name>
as a key in a dictionary of TouchIn
s. Unfortunately, as you found, microcontroller.Pin
is not hashable (does not implement __hash__()
), so we can't do that. That would eliminate the need to use strings, and would save some getattr()
calls. But I think it is fine as is.
I defer to @FoamyGuy's comments on the example.
I did another round of build testing for firmware size and found that the
I'm not sure what could be removed to make room. @dhalbert or @kattni do either of you have any ideas? Does the |
We've discussed multiple times putting in a mechanism to not freeze an entire library, and this was the use case for that option. However, it has been vetoed in the end every time it has come up. I feel like it will need to be considered eventually as there are almost certainly going to be new Circuit Playgrounds. I assume the suggestion will be create a new library for the new Playgrounds. That doesn't help here as this is far too widely used to factor
|
The library could be refactored into a base library and separate CPX/CPB libraries. Or the CPX part could be left in the base library, since we don't freeze it into CPB. |
Unless we can guarantee backwards compatibility, refactoring would be a bit of a nightmare. There would be so much code to update. Even if we left CPX alone. |
Changed to draft to avoid accidental merge. |
Tagging adafruit/circuitpython#6342 since it's somewhat related, though it doesn't seem to be the main issue, if I understand correctly. |
Yes, we can revisit this once adafruit/circuitpython#6342 i in a stable release, which would be 7.3.0 final. In addition, the work by @Neradoc here: adafruit/circuitpython#6346 to include only the parts of a frozen library that are useful (e.g. omit So we can un-draft this as soon as 7.3.0 final is out. |
Sounds like this can be reopened! |
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've suggested a simplification (not tested!) now that it's easier to keep track of pins. The _touches
dict can grow as needed: it doesn't need to contain placeholders for all the pins when it starts. Maybe you can touch up my code further.
Co-authored-by: Dan Halbert <halbert@halwitz.org>
…Adafruit_CircuitPython_CircuitPlayground into dev/iterable-io-rework
Great suggestions! I don't immediately see any improvements to your suggestions, I think it's pretty streamlined! The code could change back towards what it was if the |
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.
Couple of simplifications.
Good eye! Changes made. |
…thon_CircuitPlayground into dev/iterable-io-rework
Taking another look at this with CircuitPython 8.0.0 beta out, merged in changes from |
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.
Two minor doc touchups, but looks very good! Thanks for persevering with this.
Co-authored-by: Dan Halbert <halbert@halwitz.org>
Co-authored-by: Dan Halbert <halbert@halwitz.org>
@dhalbert should I go ahead and merge, or is this pending a specific CircuitPython release? |
If this works with 7.x.x, no problem. I wasn't sure whether @FoamyGuy wanted to review again. |
print("Touchpads currently registering a touch:") | ||
print(current_touched) | ||
else: | ||
print("No touchpads are currently regustering a touch.") |
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.
Going back to test this again. noticed small typo here, regustering
instead of registering
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.
Ha! Good catch.
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 a few variations of this again today, all were successful.
- CPX
ru
language build from current core main branch with this version of the library frozen in - CPX 7.3.2 downloaded from cp.org with this library in the root of CIRCUITPY (to override the frozen one)
- CPX 8.0.0-beta.0 downloaded from cp.org with this library in the root of CIRCUITPY
Looks good to me.
Thanks everyone! |
Updating https://github.com/adafruit/Adafruit_CircuitPython_BH1750 to 1.1.5 from 1.1.4: > Merge pull request adafruit/Adafruit_CircuitPython_BH1750#7 from tcfranks/main > Use year duration range for copyright attribution > Keep copyright up to date in documentation Updating https://github.com/adafruit/Adafruit_CircuitPython_BMP3XX to 1.3.15 from 1.3.14: > Merge pull request adafruit/Adafruit_CircuitPython_BMP3XX#22 from tcfranks/main > Use year duration range for copyright attribution > Keep copyright up to date in documentation Updating https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground to 5.3.0 from 5.2.8: > Merge pull request adafruit/Adafruit_CircuitPython_CircuitPlayground#114 from tekktrik/dev/iterable-io-rework > Use year duration range for copyright attribution > Keep copyright up to date in documentation Updating https://github.com/adafruit/Adafruit_CircuitPython_IL91874 to 1.2.9 from 1.2.8: > Merge pull request adafruit/Adafruit_CircuitPython_IL91874#16 from tcfranks/main > Use year duration range for copyright attribution > Keep copyright up to date in documentation Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1322 to 1.3.6 from 1.3.5: > Merge pull request adafruit/Adafruit_CircuitPython_SSD1322#17 from tcfranks/main > Use year duration range for copyright attribution > Keep copyright up to date in documentation Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1325 to 1.4.7 from 1.4.6: > Merge pull request adafruit/Adafruit_CircuitPython_SSD1325#15 from tcfranks/main > Use year duration range for copyright attribution > Keep copyright up to date in documentation Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1331 to 1.3.7 from 1.3.6: > Merge pull request adafruit/Adafruit_CircuitPython_SSD1331#16 from tcfranks/main > Use year duration range for copyright attribution > Keep copyright up to date in documentation Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1351 to 1.3.7 from 1.3.6: > Merge pull request adafruit/Adafruit_CircuitPython_SSD1351#18 from tcfranks/main > Use year duration range for copyright attribution > Keep copyright up to date in documentation Updating https://github.com/adafruit/Adafruit_CircuitPython_SSD1608 to 1.2.17 from 1.2.16: > Merge pull request adafruit/Adafruit_CircuitPython_SSD1608#15 from tcfranks/main > Use year duration range for copyright attribution > Keep copyright up to date in documentation Updating https://github.com/adafruit/Adafruit_CircuitPython_TMP007 to 2.1.12 from 2.1.11: > Merge pull request adafruit/Adafruit_CircuitPython_TMP007#13 from tcfranks/main > Use year duration range for copyright attribution > Keep copyright up to date in documentation Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_MIDI to 1.0.12 from 1.0.11: > Merge pull request adafruit/Adafruit_CircuitPython_BLE_MIDI#10 from tcfranks/main > Use year duration range for copyright attribution > Keep copyright up to date in documentation
Based off of comments from #113, resolves #103
I had to fiddle with the inner working in order to be able to return Pin objects. Doesn't look like
touchio.TouchIn
objects store theirPin
, and you can't usePin
s as dictionary keys either. This adds the functionality described in the aforementioned PR, but with all the necessary tweaks to make it happen. Tested before the finalpre-commit
run by building as a UF2 and running the now modified example for touching all pads (which doesn't touch ALL of them anymore, for what it's worth).