Skip to content

Commit

Permalink
Merge pull request tock#4206 from alevy/st7xx
Browse files Browse the repository at this point in the history
st7xx: flip 16-bit endianness of buffer before txn
  • Loading branch information
bradjc authored Oct 18, 2024
2 parents e688128 + 9c49282 commit c834850
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion capsules/extra/src/st77xx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,18 @@ impl<'a, A: Alarm<'a>, B: Bus<'a, BusAddr8>, P: Pin> screen::Screen<'a> for ST77
}
}

fn write(&self, data: SubSliceMut<'static, u8>, continue_write: bool) -> Result<(), ErrorCode> {
fn write(
&self,
mut data: SubSliceMut<'static, u8>,
continue_write: bool,
) -> Result<(), ErrorCode> {
if self.status.get() == Status::Idle {
// Data is provided as RGB565 ( RRRRR GGG | GGG BBBBB ), but the device expects it to come over the bus in little endian, so ( GGG BBBBB | RRRRR GGG ).
// TODO(alevy): replace `chunks_mut` wit `array_chunks` when stable.
for pair in data.as_slice().chunks_mut(2) {
pair.swap(0, 1);
}

self.setup_command.set(false);
let len = data.len();
self.write_buffer.replace(data.take());
Expand Down

0 comments on commit c834850

Please sign in to comment.