!SfJCDXZbMHXkPovtKL:matrix.org

Rust Embedded Graphics

324 Members
Help and chat for embedded-graphics and the wider embedded Rust graphics ecosystem | https://github.com/embedded-graphics/embedded-graphics | https://crates.io/crates/embedded-graphics27 Servers

Load older messages


SenderMessageTime
12 Nov 2024
@almindor:matrix.orgalmindor coz the DI just sees an Iterator<Item = TransportNativeUX> (e.g. u8 or u16 really..) 22:53:24
@grantm11235:matrix.orgGrantM11235Why does the interface care if you are sending contiguous pixels or not?22:54:14
@almindor:matrix.orgalmindorhow would it know when to terminate the spi session?22:54:32
@almindor:matrix.orgalmindorI mean say you're doing a circle, top few pixels (say 3) are contiguous, then next line it's 7 pixels etc.22:55:09
@almindor:matrix.orgalmindorright now we pre-buffer the 3, do a send of 3, pre-buffer the 7 etc.22:55:21
@almindor:matrix.orgalmindorin between you need to call the window addressing to move the positions22:55:43
@almindor:matrix.orgalmindorso it's saving us SPI sends, but also window addressing calls (another SPI send)22:55:56
@almindor:matrix.orgalmindorwith the callback hack, I guess this could work in a way where the DI just buffers the bytes until it gets back "non-contiguous" answer, and inside the callback, the driver would actually move the window as well22:57:04
@almindor:matrix.orgalmindorbut it also needs to be the right order, e.g. the 1st buffered stuff needs to be send out before the window call is made to move the position22:57:51
@almindor:matrix.orgalmindornot easy to ping-pong this if the driver is not to use its own buffers22:58:04
@grantm11235:matrix.orgGrantM11235
In reply to @almindor:matrix.org
right now we pre-buffer the 3, do a send of 3, pre-buffer the 7 etc.
You don't need to pre-buffer, you can just optimistically set the window and keep sending pixels as long as they are contiguous
23:00:40
@almindor:matrix.orgalmindor ok, so you're saying call next in a loop, check continuity, if ok then what.. do we expose a "stack" of sorts a stateful setup in the DI? I guess it could work with some sort of next_pixel and flush approach 23:02:03
@grantm11235:matrix.orgGrantM11235 You can turn an impl Iterator<Item = (Position, Color)> into an impl Iterator<Item = (Position, impl Iterator<Item = Color>)> 23:05:22
@grantm11235:matrix.orgGrantM11235Where each item in the iterator is the start position, and an iterator of all the pixels that start there and continue on the same line23:06:28
@almindor:matrix.orgalmindorI assume you actually mean Item = u16 or u8 ? I don't think the DI should know about colors? But even so, how would this work? You NEED to walk the original iterator from embedded-graphics, and as you go you need to keep the values "somewhere" so you can then send them off23:07:47
@grantm11235:matrix.orgGrantM11235You only need to peek one pixel at a time23:08:49
@almindor:matrix.orgalmindorI don't know when to "switch to a new position" until I walk all the pixels and find a one that's off. All the previous ones need to be somewhere (they cannot be sent yet)23:08:52
@almindor:matrix.orgalmindor I think a buffer_data and flush_buffer interface would work ok here 23:16:11
@grantm11235:matrix.orgGrantM11235(btw, I think the DI does need to know about colors, unfortunately. I don't remember the exact details, but it involves weird packing with the more obscure interfaces and pixel formats)23:17:29
@almindor:matrix.orgalmindorwe could push the color -> byteorder transform into the DI, it's probably beneficial for some interface types (e.g. parallel)23:18:22
@almindor:matrix.orgalmindornot sure if there's a downside yet23:18:31
@grantm11235:matrix.orgGrantM11235This should let you take an iterator of (position, color) and make sub-iterators of contiguous pixels https://doc.rust-lang.org/core/iter/struct.Peekable.html#method.next_if23:21:01
@grantm11235:matrix.orgGrantM11235Then just pass those sub-iterators to fill_contiguous23:22:00
@almindor:matrix.orgalmindor but e-g draw_iter doesn't have that binding (Peekable) AFAICS 23:38:55
@grantm11235:matrix.orgGrantM11235You can make any iterator peekable https://doc.rust-lang.org/core/iter/trait.Iterator.html#method.peekable23:40:52
@almindor:matrix.orgalmindor so pixels.peekable().next_if(|p| ...).map(|p| ...) kind of thing? 23:46:42
@almindor:matrix.orgalmindor wouldn't that be single shot only though? I'm a bit confused how next_if works wrt. continuing 23:47:20
@grantm11235:matrix.orgGrantM11235

It would be something like

let mut peekable = pixels.peekable();
loop {
23:49:09
@grantm11235:matrix.orgGrantM11235 *

It would be something like

let mut peekable = pixels.peekable();
loop {
   let sub_iter = peekable.next_if(|p| ...).map(|p| ...);
   ...
}
23:49:54
@grantm11235:matrix.orgGrantM11235 Well, not quite. You would need to create an iterator combinator that uses next_if for it's next 23:52:50

Show newer messages


Back to Room ListRoom Version: 5