joukos / PaperTTY

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

It8951 1bpp mode, A2 refresh #111

Closed mcarr823 closed 10 months ago

mcarr823 commented 10 months ago

This PR adds support for 1bpp mode and A2 display refresh mode for the IT8951 driver.

It also adds 2bpp mode, but doesn't currently utilize it.

2 new flags have been added: --disable_a2 and --disable_1bpp I went with --disable instead of --enable because they're on by default, so you'd only specify the flag if you wanted to disable them.

1bpp mode also has certain requirements around where the x and y coordinates land, and what size the image is. So the "band" method has been updated to accommodate boundaries other than the default of 8 for the x axis.

Anyway, 1bpp mode means that black and white images can be displayed with a much smaller SPI write. It uses 75% less bytes than the previous default (4bpp), so writes should be 4x as fast. This isn't noticeable for small writes (eg. single line changes), but it is noticeable for bigger writes (eg. full screen changes), especially on devices which can't write data over the pins as quickly.

A2 refresh mode is a faster update mode for 1bpp images. Per https://www.waveshare.com/w/upload/c/c4/E-paper-mode-declaration.pdf DU mode has a typical update time of 260ms. A2 mode has a typical update time of 120ms. *Note that it is currently disabled for the 6" panel because that particular panel has extra requirements for A2 mode (four-byte alignment) per comments in the code, and I don't have one of those panels to test with.

joukos commented 10 months ago

Thanks for the big PR - I can't check it out right now but will certainly take a look when I have some time, sounds good.

mcarr823 commented 10 months ago

Thanks @joukos, I'll take a look at VNC and images at some stage. The actual code changes needed should be minor. It's just that they would both need a flag to enable 1bpp/a2 since, unlike terminal mode, they might have more than 2 colors.

I'll also need to see if I can improve the banding at all. Currently it results in a few pixels being unavailable, like a margin at the end of the panel, because 1bpp requires images to be of a certain size. (Currently set to multiples of 32, but might be able to tweak that).