joukos / PaperTTY

PaperTTY - Python module to render a TTY or VNC on e-ink
942 stars 101 forks source link

Trying to add Waveshare 7.5" B V2 #95

Closed TheGreyDiamond closed 2 years ago

TheGreyDiamond commented 2 years ago

I'm trying to add support for Waveshare 7.5" B V2. This should work though I created this PR to get some help as I am unfamiliar with E-Ink stuff. I will test it tomorrow and report here. Turns out it doesn't work. Init looks fine, though something is funky with displaying the image. It just turns out to random-ish pixel garbage..... Help appreciated.

joukos commented 2 years ago

Even very small miscommunication with the display often results in garbage. Is the code based on this https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5b_V2.py ?

TheGreyDiamond commented 2 years ago

Yes, though I didn't touch the send method yet, it looked too confusing to me...

joukos commented 2 years ago

Quickly comparing the two, it seems that in the reference code this display has a pretty straightforward way of displaying the image, ie. just more or less writing the data (b/w and red separately) there without weird bit operations etc., so this should probably just be more aligned with that in order to work properly.

In some local branch of mine I redid some of the data/command sending stuff, like the reference code here has a separate method for SPI.writebytes2 etc., so it might make sense to have some generalized variants of these that all the drivers could use. Would make much of the driver code shorter if each byte or so wasn't written on its own line...

For the purposes of this driver though, no refactoring is necessary I think, and you should just take the reference code and kludge it to behave like PaperTTY expects (ie. it can be drawn to etc.), and otherwise use Waveshare's implementation almost verbatim for starters. If you get the image shown properly, then it can be refactored if necessary.

TheGreyDiamond commented 2 years ago

Okay, so I managed to show a proper image on the E-Ink via paperTTY. I'm able to show stuff via the frame buffer thing. Two things still left:

joukos commented 2 years ago
joukos commented 2 years ago

Also, great that you got it working so fast!

TheGreyDiamond commented 2 years ago

About the colour topic, I kind of hoped I was able to make things from the frame buffer of VNC red where they are actually red. Anyways, I'll have to think a little about how I want it to work in terminal mode, etc.

About the partial thing: That's a little sad cause then it makes it a little useless for my current project. 😅 I read through the datasheet and it mentions partial and partial window, so it might actually support it? I'll have to dig into that. Also the docs talk about 2 grey levels... Is that supported by paperTTY?

joukos commented 2 years ago

In VNC mode it should be simple to just consider the PIL image from the VNC display as desired, for example if (before converting it to grayscale) there's "red" - or, the Nth color in general - you'd just need to write those things to the appropriate color supported by the display, and this probably requires some minor changes here and there, but in general could be made configurable with a slider or somesuch. There's probably some optimal way to it.

As for partial window, I skimmed through the datasheet and there indeed seemingly is something there, but in the examples/lib I couldn't immediately find any usage of such for this display, so what might be worth doing at this point is to just ask Waveshare - their support has been very responsive in technical questions like these.

Or, alternatively I suppose could just create an issue in their repo about it: https://github.com/waveshare/e-Paper, but support might be faster.

If it does support partial refresh, I don't think it would work in a tricolor mode anyway (but might be wrong again).

joukos commented 2 years ago

Also, what are the requirements for the display for your project, for example how fast should it update and do you need the colors?

TheGreyDiamond commented 2 years ago

About the color: I have an idea on how I can implement it. Partials: I'll reach out to Waveshare later today.

I'm building a smarthome Display. Having it flash randomly completly sucks.

TheGreyDiamond commented 2 years ago

Okay, I just got a response from Waveshare. No the display does not officially support partials. Welp, that sucks a little but good to know. Why did they put it in the datasheet then?

TheGreyDiamond commented 2 years ago

I think I'll finish this first (which it now is) and then do the colour stuff in a different PR entirely.

joukos commented 2 years ago

Sorry about delay again. I'll try to check this out asap. So it works now for your display?

As for the datasheet, I'm not sure off the top of my head / can't remember, but the references to "partial window" etc. might also mean just that a part of the screen gets updated, ie. only those pixels are sent to the display, but the physical act of actually refreshing the display to show the change needs to be done for the whole area anyway.

TheGreyDiamond commented 2 years ago

So it works now for your display?

Yes, it works on my ~machine~ display

joukos commented 2 years ago

I've no means to really test this, but hopefully others with this display benefit from it. Thanks for the contribution!

joukos commented 2 years ago

P.S. I'll publish the new version in PyPi a bit later.