10000 Added option to allow Displays with Single Byte Boundaries by makermelissa · Pull Request #1708 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Added option to allow Displays with Single Byte Boundaries #1708

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 8 commits into from
Mar 29, 2019
Merged

Added option to allow Displays with Single Byte Boundaries #1708

merged 8 commits into from
Mar 29, 2019

Conversation

makermelissa
Copy link
Collaborator
@makermelissa makermelissa commented Mar 26, 2019

This fixes #1683 and allows the SSD1351 display to work with displayio.

if (self->init_cs_toggle && self->set_cs != NULL) {
self->set_cs(self->bus, true);
self->set_cs(self->bus, false);
}
Copy link

Choose a reason for hiding this comment

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

I'm not sure this is going to be reliable, especially on the faster MCUs and with longer wires going to the display — the voltage might have not enough time to grow to TTL levels. I wonder if it wouldn't be better to toggle the CS pin at the start and at the end of the delay later in this loop.

Copy link
@deshipu deshipu Mar 26, 2019

Choose a reason for hiding this comment

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

Basically leave the self->set_cs(self->bus, false) here, and move the self->set_cs(self->bus, true) to right after the send commands. Of course then we will need one more just before the loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The main reason I have the toggle commands right next to each other is because that’s how it functions in the Arduino driver.

I originally had it after the send command and it required adding an additional reset for the ST7789 display to function for it to work, which is the main reason I added this. When I moved it to before the send commands based on the comments by @ladyada, it worked much better.

Also, I was testing with relatively long wires hooked up (about 6” or so) using an M4 processor and it worked consistently in this manner.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After thinking about it for a bit, I could dd an arbitrary amount of delay between (1-2ms) between the commands if that would make you feel more comfortable.

Copy link

Choose a reason for hiding this comment

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

Thank you. It's initialization code, so it doesn't hurt us much if it takes a few ms longer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I looked in the datasheet to see about minimum CS toggle times, and the minimum times for CS setup are in the tens of nanoseconds, so it seems like this will not be an issue.

Copy link

Choose a reason for hiding this comment

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

Thank you, sorry for being paranoid.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it was appropriate, and a small delay is good. Microcontrollers will only get faster.

@makermelissa makermelissa added this to the 4.0.0 - Bluetooth milestone Mar 28, 2019
@dhalbert dhalbert requested a review from tannewt March 28, 2019 20:43
@tannewt
Copy link
Member
tannewt commented Mar 28, 2019

Please rebase this so it doesn't include the chip select changes. Thanks!

@makermelissa
Copy link
Collaborator Author

Done.

@makermelissa
Copy link
Collaborator Author

Looks like Travis is failing with "git submodule update --init --recursive". Any ideas?

@tannewt
Copy link
Member
tannewt commented Mar 29, 2019

@makermelissa The lwip server is unhappy. Waiting and then retry should work.

@makermelissa
Copy link
Collaborator Author

Ok, thanks!

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.

Looks great! One style comment for a follow up PR. Will merge now to get it into Beta 6. Thanks!

data[1] = __builtin_bswap16(x1 - 1 + self->colstart);
self->send(self->bus, false, (uint8_t*) data, 4);
if (self->single_byte_bounds) {
data[0] = __builtin_bswap16(((x0 + self->colstart) << 8) | ((x1 - 1 + self->colstart) & 0xFF));
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using bswap and shifts here, put the data declaration inside the if and change it to uint8_t. That will isolate the individual values and make it clearer to read.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point on readability. I was just hoping it would make the program a little smaller when I did it this way. Thanks for merging it in. I can make the readability improvement for the next release.

@tannewt tannewt merged commit 5478610 into adafruit:master Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Displayio column & row commands are 16 bit (need 8 bit too)
4 participants
0