Skip to content

Commit

Permalink
Rename PixelWord to Word
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantM11235 committed Dec 7, 2024
1 parent 0a2c03c commit d8f2a0d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions mipidsi/src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait DrawBatch<DI, M, I>
where
DI: Interface,
M: Model,
M::ColorFormat: PixelFormat<DI::PixelWord>,
M::ColorFormat: PixelFormat<DI::Word>,
I: IntoIterator<Item = Pixel<M::ColorFormat>>,
{
fn draw_batch(&mut self, item_pixels: I) -> Result<(), DI::Error>;
Expand All @@ -23,7 +23,7 @@ impl<DI, M, RST, I> DrawBatch<DI, M, I> for Display<DI, M, RST>
where
DI: Interface,
M: Model,
M::ColorFormat: PixelFormat<DI::PixelWord>,
M::ColorFormat: PixelFormat<DI::Word>,
I: IntoIterator<Item = Pixel<M::ColorFormat>>,
RST: OutputPin,
{
Expand Down
6 changes: 3 additions & 3 deletions mipidsi/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Builder<DI, MODEL, RST>
where
DI: Interface,
MODEL: Model,
MODEL::ColorFormat: PixelFormat<DI::PixelWord>,
MODEL::ColorFormat: PixelFormat<DI::Word>,
{
di: DI,
model: MODEL,
Expand All @@ -42,7 +42,7 @@ impl<DI, MODEL> Builder<DI, MODEL, NoResetPin>
where
DI: Interface,
MODEL: Model,
MODEL::ColorFormat: PixelFormat<DI::PixelWord>,
MODEL::ColorFormat: PixelFormat<DI::Word>,
{
///
/// Constructs a new builder for given [Model].
Expand All @@ -62,7 +62,7 @@ impl<DI, MODEL, RST> Builder<DI, MODEL, RST>
where
DI: Interface,
MODEL: Model,
MODEL::ColorFormat: PixelFormat<DI::PixelWord>,
MODEL::ColorFormat: PixelFormat<DI::Word>,
RST: OutputPin,
{
///
Expand Down
4 changes: 2 additions & 2 deletions mipidsi/src/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl<DI, M, RST> DrawTarget for Display<DI, M, RST>
where
DI: Interface,
M: Model,
M::ColorFormat: PixelFormat<DI::PixelWord>,
M::ColorFormat: PixelFormat<DI::Word>,
RST: OutputPin,
{
type Error = DI::Error;
Expand Down Expand Up @@ -122,7 +122,7 @@ impl<DI, MODEL, RST> OriginDimensions for Display<DI, MODEL, RST>
where
DI: Interface,
MODEL: Model,
MODEL::ColorFormat: PixelFormat<DI::PixelWord>,
MODEL::ColorFormat: PixelFormat<DI::Word>,
RST: OutputPin,
{
fn size(&self) -> Size {
Expand Down
28 changes: 14 additions & 14 deletions mipidsi/src/interface/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait Interface {
/// In most cases this will be u8, except for larger parallel interfaces such as
/// 16 bit (currently supported)
/// or 9 or 18 bit (currently unsupported)
type PixelWord: Copy;
type Word: Copy;

/// Error type
type Error: core::fmt::Debug;
Expand All @@ -31,7 +31,7 @@ pub trait Interface {
/// [`Interface::flush`] must be called to ensure the data is actually sent
fn send_pixels<const N: usize>(
&mut self,
pixels: impl IntoIterator<Item = [Self::PixelWord; N]>,
pixels: impl IntoIterator<Item = [Self::Word; N]>,
) -> Result<(), Self::Error>;

/// Send the same pixel value multiple times
Expand All @@ -41,7 +41,7 @@ pub trait Interface {
/// [`Interface::flush`] must be called to ensure the data is actually sent
fn send_repeated_pixel<const N: usize>(
&mut self,
pixel: [Self::PixelWord; N],
pixel: [Self::Word; N],
count: u32,
) -> Result<(), Self::Error>;

Expand All @@ -50,7 +50,7 @@ pub trait Interface {
}

impl<T: Interface> Interface for &mut T {
type PixelWord = T::PixelWord;
type Word = T::Word;
type Error = T::Error;

fn send_command(&mut self, command: u8, args: &[u8]) -> Result<(), Self::Error> {
Expand All @@ -59,14 +59,14 @@ impl<T: Interface> Interface for &mut T {

fn send_pixels<const N: usize>(
&mut self,
pixels: impl IntoIterator<Item = [Self::PixelWord; N]>,
pixels: impl IntoIterator<Item = [Self::Word; N]>,
) -> Result<(), Self::Error> {
T::send_pixels(self, pixels)
}

fn send_repeated_pixel<const N: usize>(
&mut self,
pixel: [Self::PixelWord; N],
pixel: [Self::Word; N],
count: u32,
) -> Result<(), Self::Error> {
T::send_repeated_pixel(self, pixel, count)
Expand Down Expand Up @@ -97,28 +97,28 @@ pub trait PixelFormat<Word> {
// but that doesn't work yet

#[doc(hidden)]
fn send_pixels<DI: Interface<PixelWord = Word>>(
fn send_pixels<DI: Interface<Word = Word>>(
di: &mut DI,
pixels: impl IntoIterator<Item = Self>,
) -> Result<(), DI::Error>;

#[doc(hidden)]
fn send_repeated_pixel<DI: Interface<PixelWord = Word>>(
fn send_repeated_pixel<DI: Interface<Word = Word>>(
di: &mut DI,
pixel: Self,
count: u32,
) -> Result<(), DI::Error>;
}

impl PixelFormat<u8> for Rgb565 {
fn send_pixels<DI: Interface<PixelWord = u8>>(
fn send_pixels<DI: Interface<Word = u8>>(
di: &mut DI,
pixels: impl IntoIterator<Item = Self>,
) -> Result<(), DI::Error> {
di.send_pixels(pixels.into_iter().map(rgb565_to_bytes))
}

fn send_repeated_pixel<DI: Interface<PixelWord = u8>>(
fn send_repeated_pixel<DI: Interface<Word = u8>>(
di: &mut DI,
pixel: Self,
count: u32,
Expand All @@ -128,14 +128,14 @@ impl PixelFormat<u8> for Rgb565 {
}

impl PixelFormat<u8> for Rgb666 {
fn send_pixels<DI: Interface<PixelWord = u8>>(
fn send_pixels<DI: Interface<Word = u8>>(
di: &mut DI,
pixels: impl IntoIterator<Item = Self>,
) -> Result<(), DI::Error> {
di.send_pixels(pixels.into_iter().map(rgb666_to_bytes))
}

fn send_repeated_pixel<DI: Interface<PixelWord = u8>>(
fn send_repeated_pixel<DI: Interface<Word = u8>>(
di: &mut DI,
pixel: Self,
count: u32,
Expand All @@ -145,14 +145,14 @@ impl PixelFormat<u8> for Rgb666 {
}

impl PixelFormat<u16> for Rgb565 {
fn send_pixels<DI: Interface<PixelWord = u16>>(
fn send_pixels<DI: Interface<Word = u16>>(
di: &mut DI,
pixels: impl IntoIterator<Item = Self>,
) -> Result<(), DI::Error> {
di.send_pixels(pixels.into_iter().map(rgb565_to_u16))
}

fn send_repeated_pixel<DI: Interface<PixelWord = u16>>(
fn send_repeated_pixel<DI: Interface<Word = u16>>(
di: &mut DI,
pixel: Self,
count: u32,
Expand Down
6 changes: 3 additions & 3 deletions mipidsi/src/interface/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ where
DC: OutputPin,
WR: OutputPin,
{
type PixelWord = BUS::Word;
type Word = BUS::Word;
type Error = ParallelError<BUS::Error, DC::Error, WR::Error>;

fn send_command(&mut self, command: u8, args: &[u8]) -> Result<(), Self::Error> {
Expand All @@ -213,7 +213,7 @@ where

fn send_pixels<const N: usize>(
&mut self,
pixels: impl IntoIterator<Item = [Self::PixelWord; N]>,
pixels: impl IntoIterator<Item = [Self::Word; N]>,
) -> Result<(), Self::Error> {
for pixel in pixels {
for word in pixel {
Expand All @@ -225,7 +225,7 @@ where

fn send_repeated_pixel<const N: usize>(
&mut self,
pixel: [Self::PixelWord; N],
pixel: [Self::Word; N],
count: u32,
) -> Result<(), Self::Error> {
if count == 0 || N == 0 {
Expand Down
6 changes: 3 additions & 3 deletions mipidsi/src/interface/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<'a, SPI: SpiDevice, DC: OutputPin> SpiInterface<'a, SPI, DC> {
}

impl<SPI: SpiDevice, DC: OutputPin> Interface for SpiInterface<'_, SPI, DC> {
type PixelWord = u8;
type Word = u8;
type Error = SpiError<SPI::Error, DC::Error>;

fn send_command(&mut self, command: u8, args: &[u8]) -> Result<(), Self::Error> {
Expand All @@ -39,7 +39,7 @@ impl<SPI: SpiDevice, DC: OutputPin> Interface for SpiInterface<'_, SPI, DC> {

fn send_pixels<const N: usize>(
&mut self,
pixels: impl IntoIterator<Item = [Self::PixelWord; N]>,
pixels: impl IntoIterator<Item = [Self::Word; N]>,
) -> Result<(), Self::Error> {
let mut arrays = pixels.into_iter();

Expand All @@ -65,7 +65,7 @@ impl<SPI: SpiDevice, DC: OutputPin> Interface for SpiInterface<'_, SPI, DC> {

fn send_repeated_pixel<const N: usize>(
&mut self,
pixel: [Self::PixelWord; N],
pixel: [Self::Word; N],
count: u32,
) -> Result<(), Self::Error> {
let fill_count = core::cmp::min(count, (self.buffer.len() / N) as u32);
Expand Down
10 changes: 5 additions & 5 deletions mipidsi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub struct Display<DI, MODEL, RST>
where
DI: interface::Interface,
MODEL: Model,
MODEL::ColorFormat: PixelFormat<DI::PixelWord>,
MODEL::ColorFormat: PixelFormat<DI::Word>,
RST: OutputPin,
{
// DCS provider
Expand All @@ -153,7 +153,7 @@ impl<DI, M, RST> Display<DI, M, RST>
where
DI: interface::Interface,
M: Model,
M::ColorFormat: PixelFormat<DI::PixelWord>,
M::ColorFormat: PixelFormat<DI::Word>,
RST: OutputPin,
{
///
Expand Down Expand Up @@ -436,7 +436,7 @@ pub mod _mock {
pub struct MockDisplayInterface;

impl Interface for MockDisplayInterface {
type PixelWord = u8;
type Word = u8;
type Error = Infallible;

fn send_command(&mut self, _command: u8, _args: &[u8]) -> Result<(), Self::Error> {
Expand All @@ -445,14 +445,14 @@ pub mod _mock {

fn send_pixels<const N: usize>(
&mut self,
_pixels: impl IntoIterator<Item = [Self::PixelWord; N]>,
_pixels: impl IntoIterator<Item = [Self::Word; N]>,
) -> Result<(), Self::Error> {
Ok(())
}

fn send_repeated_pixel<const N: usize>(
&mut self,
_pixel: [Self::PixelWord; N],
_pixel: [Self::Word; N],
_count: u32,
) -> Result<(), Self::Error> {
Ok(())
Expand Down

0 comments on commit d8f2a0d

Please sign in to comment.