-
Notifications
You must be signed in to change notification settings - Fork 59
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
New interface traits #149
New interface traits #149
Conversation
d718a50
to
0a81216
Compare
Wow, I didn't expect this to impact performance much on my project (8 bit unbuffered parallel interface using Please try it out, I think it might be faster than #146 edit: Clearing the screen (320x240) went from 90ms to 10ms 🤯 |
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.
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.
LGTM! @rfuest I want to wait on your opinion as well however.
I don't think it's a good idea to remove support for |
How would you want to address this though? Deprecate DI with 0.9 and give some time? Use features to switch between DI and "PI" versions? I don't want to overcomplitcate things or delay them unless necessary. I think if we release this as 0.9, FSMC can keep supporting 0.8 until they reimplement for the new version. I find it interesting they decided to implement DI inside the HAL directly. |
99% of the time we can't just use slices of pixels. For starters, embedded-graphics only uses iterators. Even if we did have a slice of pixels, we would still need to convert rgb565 to big-endian or convert rgb666 to left-aligned. Even if the pixels were already in the right format, they might still need to be copied to a dma capable buffer
Using an iterator at the interface boundary instead of a slice means that we don't need to unnecessarily buffer the data when using an unbuffered interface like Footnotes
|
One of my design decisions when making this trait was to only support mipi dcs style interfaces, not all "displays" that have some concept of "commands" and "data". The reason is that other display interfaces work differently and have different usage patterns. For example, SSD1306 oled command parameters are sent as "commands" but in mipi dcs they are "data". That means the only other crates that can use this trait are the other crates that support the same displays as us, such as We can't make the trait private/sealed because we want to allow high performance, hardware specific impls like stm32's fsmc, rpi's pio, or esp32's i80. These impls don't actually need to be in the HALs, they can be in third party crates as long as the HALs support the basic operations. We could still add convenience constructors like |
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.
While I might not like all the details of the implementation I won't oppose merging it. Let's see how it works out in practice. And it's definitely a nice improvement over display_interface
👍 .
But one thing I would like to bring up is the mutable slice that is used as a buffer in SpiInterface
. There might be use cases where this would be harder to work with, because a Display
that uses SpiInterface
couldn't be stored in the same struct as the SPI buffer. What is the reason you decided to use this approach instead of making the buffer a const generic inside the SpiInterface
?
Co-authored-by: Ralf Fuest <[email protected]>
Some chips can only dma from certain memory regions. If the user is able to create the buffer in one of those regions, then their hal's spi impl won't need to copy the data into another buffer. I changed it to be generic over Initializing a display with an inline array buffer involves creating the array, moving it into the interface, then moving that interface into the display driver. Each of those moves involves allocating space for the whole array on the stack and copying the whole array. LLVM is notoriously bad at optimizing these copies away. Moving the display driver after that will have the same problem. For practical purposes it's probably easier to just use |
Correct, when it comes to CS there are essentially two scenarios. Either the CS is handled by the SPI/HAL directly or by us. In general we should favour the SPI/HAL to handle it because at least some MCUs have HW control of CS built-in to the "fast SPI" implementation. Note that many HALs have this implemented "wrong" and do not automatically switch CS and other SPI settings (such as mode, speed etc.) properly when switching between If we control CS we need to ensure it's reset properly at the end of a transaction of course. If we do not, the best we can do is just document that it's the upstream's responsibility to not let CS hang. DMA buffers are a must, the speed increase when using them is quite large. |
I'm confused, the message you are replying to isn't about CS |
Ups, misclicked. I read parts in email and then came here and clicked the wrong thing. It was meant mostly as a reaction to the CS discussion, but also l inked to the DMA buffer requirement. |
OK, you convinced me that using |
Co-authored-by: Ralf Fuest <[email protected]>
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 think I'm happy with this change atm. @rfuest I'll let you review one more time since your changes were done, but I'm inclined to go ahead with this and merge soon to get the ball rolling.
The PR is in already in a very good state, but there are still 2 unresolved conversations that should be addressed before this can be merged. The one about the duplicate name isn't too important, but I think that the one about the |
No description provided.