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])
| 138 | /// |
| 139 | /// The input data is chunked to respect the maximum write size accepted by the SPI bus. |
| 140 | fn 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. |
| 157 | struct ST7735SLcd<P: Pins, B> { |