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

paralleldisplay: reset and read pins should be optional #6118

Merged
merged 3 commits into from
Mar 8, 2022

Conversation

deshipu
Copy link

@deshipu deshipu commented Mar 5, 2022

The reset and read pins should be optional, but the espressif
code had several places where it assumed they are not, and a bug that
caused a crash on release_displays if they were made optional.

The bug was caused by the fields for storing pin numbers being set
to NO_PIN, which has value of -1, while the fields have type
uint8_t. That set the actual value to 255, and a subsequent
comparison to NO_PIN returned false.

The ``reset`` and ``read`` pins should be optional, but the espressif
code had several places where it assumed they are not, and a bug that
caused a crash on ``release_displays`` if they were made optional.

The bug was caused by the fields for storing pin numbers being set
to ``NO_PIN``, which has value of -1, while the fields have type
``uint8_t``.  That set the actual value to 255, and a subsequent
comparison to ``NO_PIN`` returned false.
@dhalbert
Copy link
Collaborator

dhalbert commented Mar 5, 2022

In other ports, NO_PIN is 0xff. In this port, it is set by #define NO_PIN (GPIO_NUM_NC), where GPIO_NUM_NC is -1, but if NO_PIN were changed to 0xff, it would make changing things to int8_t not necessary. I also think it would be better not to use a signed byte for a pin number, in case we have pins > 128.

@deshipu
Copy link
Author

deshipu commented Mar 5, 2022

You can always change it to int16_t when needed, it's not like we are saving loads of memory here. And by the same argument, what if we have 255 pins?

@dhalbert
Copy link
Collaborator

dhalbert commented Mar 5, 2022

I am just saying I think the initial idea of using #define NO_PIN (GPIO_NUM_NC) was not the best choice.

@deshipu
Copy link
Author

deshipu commented Mar 5, 2022

Isn't it needed for compatibility with idf?

Co-authored-by: Dan Halbert <halbert@halwitz.org>
@deshipu deshipu requested a review from dhalbert March 5, 2022 22:19
dhalbert
dhalbert previously approved these changes Mar 6, 2022
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Thanks for the change! I'd like @tannewt to comment on the overall PR: I don't have much experience with displays.

@dhalbert dhalbert requested a review from tannewt March 6, 2022 01:54
@gamblor21
Copy link
Member

Just a quick late night look but I do not think the atmel or rp2040 ports will work if the read pin is left out (likely a bug as well with them). Also in the espressif port I noticed common_hal_never_reset_pin(read); was removed but never replaced if read was specified which I believe means if it is given it would be reset when the other display pins would not be.

@deshipu
Copy link
Author

deshipu commented Mar 6, 2022

Just a quick late night look but I do not think the atmel or rp2040 ports will work if the read pin is left out (likely a bug as well with them).

You are right! I started this with the reset pin, and after checking in all the ports that they do have the code to make it optional, I noticed that the espressif port also has that code for the read pin, and assumed the other ports would as well. I will fix that.

Also in the espressif port I noticed common_hal_never_reset_pin(read); was removed but never replaced if read was specified which I believe means if it is given it would be reset when the other display pins would not be.

It was there twice: https://github.com/adafruit/circuitpython/pull/6118/files#diff-6e4f17b3d8ddfa1af71ef1d81695db73526478965d2f456c14574a98bd32bb47R81

@deshipu
Copy link
Author

deshipu commented Mar 7, 2022

Looks like making the read pin optional took the build size over the edge for the Japanese translation of Matrix Portal M4. Should I revert that and just leave the reset pin as optional, or can we do something to make that one build fit?

@tannewt
Copy link
Member

tannewt commented Mar 8, 2022

The matrixportal build has paralleldisplay enabled and clearly doesn't need it. You can disable it and then the build should fit.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

This all looks good to me.

@dhalbert
Copy link
Collaborator

dhalbert commented Mar 8, 2022

I shrank the matrixportal build here: eff6057

So if that works, and gets merged, we can merge this afterwards and you won't have to submit that patch.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Can merge now with shrink in from #6117.

@dhalbert dhalbert merged commit 1c8f671 into adafruit:main Mar 8, 2022
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.

4 participants