Array of bits

Hello,
I'd like to make a simple black and white sort of image encoder that takes screen pixels and transforms them into a 1024x600 resolution black and white image, and for this i was thinking of sending an array of bits through the serial port to a ESP32, which in turn sends the image to the Epdiy e-ink display driver.
At 1024x600 we have 614400 bits or 76.8 KB per frame edit: its 1200x825, about 125kb per frame, each bit will be white or black, 1 or 0.
Since making an array of bits in C seems to be impossible, i wanted to know which would be the fastest / best way of store this data.
thanks

You store 8 bits to a byte, as many bytes as you need... it's not the fastest way, it's the only way unless you can accept huge waste of memory.

By the way, you can see many examples of this if you browse through a few graphics libraries... I suggest you do so.

Compression will help with data transfer time.
You could have a look at this JPEGDecoder library

RLE is a better choice for 1 bit depth images, than JPEG. Or even LZW compression on the entire image if you can tolerate that.

I was assuming OP had picked black and white due to the size of the resulting image but forgot about eInk...

Indeed there are more optimized compression if it’s 1 bit depth.

Hi thanks for replies. I'm looking into those compression methods. In the meantime could you tell me if since the board has WIFI that i've read goes up to 20mbps, maybe woudl be a better choice than the using the serial port?

WiFi will add some overhead but indeed would very likely end up being much faster than a Serial Communication (at best you'll go to 2,000,000 bauds so 200,000 bytes per second roughly assuming processing those byte is not too long)

J-M-L:
WiFi will add some overhead but indeed would very likely end up being much faster than a Serial Communication (at best you'll go to 2,000,000 bauds so 200,000 bytes per second roughly assuming processing those byte is not too long)

200,000 bytes per second that would be the serial port speed right?

Do you have a working system, without compression, right now?

amadeok:
200,000 bytes per second that would be the serial port speed right?

yes, if you set the Serial connexion at 2 million bauds. if you set it a 9600 then it will be very painful :slight_smile:

aarg:
Do you have a working system, without compression, right now?

No i don’t. There is this guy who does: GitHub - vroland/epdiy: EPDiy is a driver board for affordable e-Paper (or E-ink) displays.
He made the driver board, and he made a few examples for example a terminal that runs from a raspberry pi i believe. Here there is some info about how to actually talk to the display: Driving waveforms – Essential scrap
But what i want to do is make it a sort of 1bit pc monitor. I’m using python module mss to capture the screen and Pillow to turn image into 1bit depth, and there is this rle compression program that can compress a 1bpp 1200x825 image of size 125kb to about 25kb. The capturing and conversion takes about 20ms on my i5 3570k and the compression 3ms more.
Right now i’m trying to find the fastest way to send this data to the esp32. Maybe i should use a raspberry pie instead of the esp32.

What’s the refresh rate of your e-ink screen?

J-M-L:
What’s the refresh rate of your e-ink screen?

There is this demo where he is using the fastest display his driver supports, the ED097TC2, it may be around 3 or 4 fps?: https://cdn.hackaday.io/files/1681937195969312/terminal_demo.mp4

Also note that the C++ standard library has already solved this problem:
If you know the size ahead of time, use std::bitset, otherwise use std::vector.

A ‘bool’ is usually the same size as a ‘char’, but the vector specifically implements in terms of bits.

https://en.cppreference.com/w/cpp/utility/bitset

Another thing - if you are sending the bits to the ESP32 for display, then why store them at all? Blast them directly to the screen as you get them.

So 300+ ms for displaying one frame. That’s probably the bottleneck in terms of system performance anyway.