-
-
Notifications
You must be signed in to change notification settings - Fork 88
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 a way to specify packing direction for framebuffer #697
Comments
Didn't you intend to implement this packing in the |
I did, but seeing as we now have |
OK, that might help in reducing some code duplication and having to maintain another crate. Adding the SSD1306 compatible layout will not only require a parameter for the direction, but also the bit order. To keep |
Sorry for not being clear on this point earlier: since |
Is there a better way to implement this than to add another type parameter for the bit order? Framebuffer<C, R, BYTE_ORDER, BIT_ORDER, DIRECTION, const WIDTH: usize, const HEIGHT: usize, const N: usize> This would be a terrible type. Maybe we could wrap let fb = Framebuffer::<Rgb565, LittleEndian<RawU16>, Horizontal, 10, 10, { buffer_size::<Horizontal>(10, 10) }>::new();
let fb = Framebuffer::<BinaryColor, Lsb0<RawU1>, Vertical, 10, 10, { buffer_size::<Vertical>(10, 10) }>::new(); |
I suggested a type parameter for perf reasons, but yes that's a horrid type. I like your solution, but I'm not sure I follow with the naming; the bit order wouldn't change for vertical byte alignment, only the direction of the byte. I haven't given it much thought but don't we essentially have to swap X and Y coordinates without swapping WIDTH and HEIGHT to be able to support SSD1306 et al? |
The
In the current implementation the MSB of the first byte in the buffer is located at |
Ah I see. That's a bit unfortunate. Perhaps this is too complex, but we could consolidate the bit ordering and direction: let fb = Framebuffer::<Rgb565, LittleEndian<RawU16, Horizontal>, 10, 10, { buffer_size::<Horizontal>(10, 10) }>::new();
let fb = Framebuffer::<BinaryColor, Lsb0<RawU1, Vertical>, 10, 10, { buffer_size::<Vertical>(10, 10) }>::new(); although having now written it, the above doesn't really help reduce the size of the type. That said, I'm not sure this is too much of an issue for the end user. The SSD1306 (etc) driver writers will have to deal with all the LSB/MSB horizontal/vertical configuration but that doesn't need to be passed on to the user and can be type aliased within the crate. FWIW this is the full SSD1306 type using an SPI interface, so maybe we're in the right club when it comes to long types ;) type Display = Ssd1306<
SPIInterfaceNoCS<
spi::Spi<
SPI1,
spi::Spi1NoRemap,
(
gpio::gpioa::PA5<gpio::Alternate<gpio::PushPull>>,
gpio::gpioa::PA6<gpio::Input<gpio::Floating>>,
gpio::gpioa::PA7<gpio::Alternate<gpio::PushPull>>,
),
u8,
>,
gpio::gpiob::PB1<gpio::Output<gpio::PushPull>>,
>,
DisplaySize128x64,
BufferedGraphicsMode<DisplaySize128x64>,
>; |
I think that keeping them separate is better.
Yes, Rust embedded users should all be familiar with looong types. My concern was primarily that users who use |
Sounds good to me. Grouping them brings no benefits.
A cost I'm personally happy to shift onto our users 😁
Hm, interesting idea, although I'm not sure how useful that would be when programs like |
I think we will need this if we want to keep |
Ok, no problem then :) By the way, I made a milestone for the 0.8 release and put some issues into it. Please add/remove them or any others as you see fit. |
I just noticed that and I'll take a look. If you want to start working on any of the issues please assign yourself to the issue to prevent that we accidentally start working on the same one. |
The most complicated issue, but also the most important to solve, for the next breaking release will be #613 IMO. But that issue has been blocked for months. If we want to release |
Soon would be good, but it feels messy to do a double release like you suggest. I don't think there are any objective blockers to #613, more that nobody has been able to spend some time on it, no? |
What do you mean by "double release"? E-g 0.9 would probably not released shortly after the 0.8 release, if we release 0.8 soon (ish).
I wanted to do tests on real hardware before deciding on a new |
Yeah, releasing 0.8 then 0.9.
Makes sense :). Did you end up ordering all the right stuff by the way? And please send me an email or Element message so I can reimburse you for those purchases - I totally forgot! |
The displays from China arrived OK (see embedded-graphics/hardware-bench#1 (comment)). I didn't order any other development hardware yet, because we hadn't finally decided what to order and the STM32H7 board did go out of stock in the meantime (at least at Digikey and Mouser). |
Thanks for the update. I've left a comment over at hardware-bench |
I just noticed that you assigned yourself to this issue. I had perviously worked on this and have uploaded my WIP version to #711, if you want to continue from where I stopped working on this. |
Argh, I knew I'd forget to unassign. I had a quick play around but nothing concrete. Please feel free to carry on with this in #711; I won't step on your toes. |
You wouldn't step on my toes and I wouldn't mind to share some of the work. If you are still interested to work on this, go ahead. |
Ok, noted :) thanks also for making a start on it |
IIUC, the current framebuffer implementation packs colours of less than 8BPP horizontally. It would be useful for displays like the SSD1306 if the colours (in this case
BinaryColor
) could also be packed vertically, meaning the display data is laid out like this:I think this is the only part of
FrameBuffer
that would block a new release as it would change the API to include a new argument/type parameter to dictate the mapping direction. The performance optimisations could come in a patch release when I have more time to focus on e-g, or someone else wants to pick them up.The text was updated successfully, but these errors were encountered: