yuri91 / ili9341-rs

A WIP, no_std, generic driver for the ILI9341 (and ILI9340C) TFT LCD display
Apache License 2.0
58 stars 50 forks source link

Gpio8Interface data_pins issues #15

Closed tarcieri closed 4 years ago

tarcieri commented 4 years ago

I'm trying to wire up Gpio8Interface and it seems trickier than it needs to be.

I think my main concerns are:

I'm dealing with a type where all of the pins are owned:

https://docs.rs/pyportal/0.4.0/pyportal/pins/struct.Display.html

I'd like to just hand off ownership of all of the pins, including the display bus pins, to the display driver. It seems right now I can only hand over some of them, and the others need to be borrowed.

I think it might make sense to have some sort of display bus type where all of the pins are generic instead of the current:

https://docs.rs/ili9341/0.3.0/ili9341/gpio/struct.Gpio8Interface.html#method.new

data_pins: &'a mut [&'a mut dyn OutputPin<Error = PinE>; 8],

Something like this (I know it's a bit ugly, but):

pub struct DataPins<P0, P1, P2, P3, P4, P5, P6, P7>
where
    P0: OutputPin<Error = PinE>,
    P1: OutputPin<Error = PinE>,
    ...
    P7: OutputPin<Error = PinE>,
{
    p0: P0,
    p1: P1,
    ...
    p7: P7
}

That'd also eliminate any concerns around lifetimes.

yuri91 commented 4 years ago

Hi!

This interface was added by @flaminggoat . I personally don't have a use case for the gpio interface, so I am not sure if he had a particular use case in mind for implementing it like it is now.

In principle I have nothing against changing it. I would wait a bit to see if somebody that uses the current interface has some thoughts on this.

tarcieri commented 4 years ago

If @flaminggoat is ok with it, I can send a PR to change it to something like the above. I think it'd really help with simplifying pin ownership.

yuri91 commented 4 years ago

Since https://github.com/yuri91/ili9341-rs/pull/16 landed, the actual display interface is implemented by https://github.com/therealprof/display-interface (and friends).

So I am going to close this