If you are using the NHD-C12832A1Z-FSW-FBW-3V3 LCD, or another LCD based on the ST7565R chip, you may have ran into the issue of converting image data into a format suitable for sending to the display.

It’s a bit strange because the display is addressed using a page/column scheme, with each byte representing a slice of 8 vertical bits.

This python script does the necessary conversion. It reads an image and outputs a C array that you can paste into your program. Use it at your own risk.

convert_image_st7565r.py

Sample output:

/* hw.png (128x32) */
uint8_t data[512] = {
 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, /* and so on ... */
};