Skip to content

Add tft 3.5 inch featherwing helper #68

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
merged 6 commits into from
Mar 20, 2021

Conversation

FoamyGuy
Copy link
Contributor

This adds a new helper class and example for the 3.5" Featherwing device. This can be used by the Touch Deck project code to remove the need for much of the display and touchscreen setup boilerplate code.

Unfortunately I don't think it is going to be passing actions currently. Due to code duplication

I refactored the existing tft_featherwing_24 class to use a new base class that it can share with the new tft_featherwing_35 added in this PR.

But there are still some duplicate sections between other previously existing helper classes for the keyboard_featherwing, as well as some for matrix_featherwing and pixelmatrix.

I tested these changes with a Feather RP2040 on the 3.5" and 2.4" Featherwings using the simpletest scripts and the current Touch Deck code: https://github.com/FoamyGuy/Touch_Deck_Working_Files

@FoamyGuy
Copy link
Contributor Author

The newest commit includes a refactor to the keyboard_featherwing to make it use the new TFTFeatherWing superclass which removes the majority of the remaining duplication.

I tested these latest changes using an RP2040 Feather with the KeyboardFeatherwing and the keyboard featherwing test script from the examples directory.

There is still one dupe section in the matrix_featherwing and pixelmatrix. As well as one outstanding PyLint issue in the RTC Featherwing. I can try to fix those up tonight, but I'm not sure if I have hardware to test on.

@ladyada ladyada requested a review from kattni March 16, 2021 21:32
@ladyada
Copy link
Member

ladyada commented Mar 16, 2021

@kattni please look at code dup CI issue

@kattni
Copy link
Contributor

kattni commented Mar 16, 2021

@FoamyGuy We're going to either increase the threshold or disable the duplicate code check. I need to decide which. You will not need to resolve the issue with the modules you did not update.

@FoamyGuy
Copy link
Contributor Author

@kattni whoops I missed the last message until I came back here after pushing. I did end up refactoring the other helper classes and fix up the other last pylint issue in the rtc one.

@FoamyGuy
Copy link
Contributor Author

The latest commit refactors pixelmatrix and matrix_featherwing to make use of a new AutoWriteable superclass which allows them to avoid code duplication.

The one before that fixes up the last remaining pylint issue from rtc by returning None after the error is caught.

I tested the refactored class changes with Feather RP2040 and https://www.adafruit.com/product/3149 / https://www.adafruit.com/product/2945 using the simpletest scripts in the examples directory and everything seemed to be working.

Copy link
Collaborator

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style-wise this looks great. I didn't test.

@ladyada
Copy link
Member

ladyada commented Mar 17, 2021

@jedgarpark can u test since its in your wheelhouse?

@ladyada ladyada closed this Mar 17, 2021
@ladyada ladyada reopened this Mar 17, 2021
@FoamyGuy
Copy link
Contributor Author

Talking with @jedgarpark on this a bit one thing we've seen is some devices / versions of CircuitPython seem to have an issue where the touch driver chip is not quite ready to be initialized when code.py executes from a cold boot up.

It results in this error:

Traceback (most recent call last):
  File "code.py", line 13, in <module>
  File "/lib/adafruit_featherwing/tft_featherwing_35.py", line 36, in __init__
  File "/lib/adafruit_featherwing/tft_featherwing.py", line 42, in __init__
  File "adafruit_stmpe610.py", line 281, in __init__
RuntimeError: Failed to find STMPE610! Chip Version 0x804

We've figured out that adding a small time.sleep() before initializing resolves this issue.

I'm going to add some logic into the library module to try to catch the first one of these errors and retry once with a short time delay. This way the user won't have to worry about those details.

@jedgarpark
Copy link

@FoamyGuy I can test this

@jedgarpark
Copy link

@FoamyGuy That fixes the hang for me on both the example code and the Touch Deck code, great stuff!

@rsbohn
Copy link

rsbohn commented Mar 20, 2021

Fixed the hard crash I was seeing on Adafruit CircuitPython 6.2.0-beta.4 on 2021-03-18; Adafruit Feather M4 Express with samd51j19 with TFTFeatherWing35.

@FoamyGuy
Copy link
Contributor Author

Thank you @makermelissa for review, and @jedgarpark + @rsbohn for testing!

@FoamyGuy FoamyGuy merged commit c9e46e5 into adafruit:master Mar 20, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Mar 21, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout to 1.5.1 from 1.4.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#21 from FoamyGuy/remove_print
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#20 from FoamyGuy/fix_setup_py
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing to 1.14.0 from 1.13.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_FeatherWing#68 from FoamyGuy/add_tft_3_5_inch
  > "Increase duplicate code check threshold "
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.

6 participants