MCPcopy Index your code
hub / github.com/endbasic/endbasic / lcd_write

Function lcd_write

st7735s/src/lib.rs:140–154  ·  view source on GitHub ↗

Writes arbitrary data to the SPI bus. The input data is chunked to respect the maximum write size accepted by the SPI bus.

(spi_bus: &mut B, data: &[u8])

Source from the content-addressed store, hash-verified

138///
139/// The input data is chunked to respect the maximum write size accepted by the SPI bus.
140fn lcd_write<B: SpiBus>(spi_bus: &mut B, data: &[u8]) -> io::Result<()> {
141 // TODO(jmmv): Do we really need to chunk the data ourselves, or can we try to write it
142 // all to the bus and then expect the write to return partial results?
143 for chunk in data.chunks(spi_bus.max_size()) {
144 let mut i = 0;
145 loop {
146 let n = spi_bus.write(&chunk[i..])?;
147 if n == chunk.len() - i {
148 break;
149 }
150 i += n;
151 }
152 }
153 Ok(())
154}
155
156/// LCD handler for the ST7735S console.
157struct ST7735SLcd<P: Pins, B> {

Calls 3

max_sizeMethod · 0.45
writeMethod · 0.45
lenMethod · 0.45