[Skip to Content]

Published Saturday 28 April 2018
Categories: Home Automation | Programming and Code |

Post View Counter 985

e-paper display

Over the past few months Andrew has been working on a new circuit for a custom home alarm system to replace our current hardwired commercial alarm.

For the display panel on the new alarm we are going to be using a e-ink display to show the status of the alarm and the sensor status for each door and window.

We sourced a basic 2.9 inch e-ink display from ebay and it is a 296x128 pixel back and white display and a SPI interface from https://www.waveshare.com/wiki/2.9inch_e-Paper_Module

The display uses an array of bytes to write to the display panel with each byte controlling 8 pixels. You can either write the entire display each time or select a starting x and y location and write the data as required.

The manufacturer has a windows application to convert images into the data format required but it is all in Chinese and we couldn’t get it to work.

I wrote a simple Windows form application which opens a bitmap file and then loops though each row and column and gets the hex value for each pixel. If the pixel is black it then returns “0” for a black pixel or “1” for a white pixel.

Each row is then combined into a series of 1’s and 0’s  and converted into a byte array which is then saved into a StringBuilder and formatted as HEX values with comma separators.

The resulting text output can then be saved into text file and used on the panels control software to write to the display via the SPI bus.

e-paper display with image loaded

Converting the above 16px x 16px image results in the following code with each row of pixels being converted into two byte values per line.

{
0x9C,0xE7,
0x08,0x43,
0x08,0x43,
0x9C,0xE7,
0xFF,0xFF,
0xCF,0x39,
0x86,0x10,
0x86,0x10,
0xCF,0x39,
0xFF,0xFF,
0xF9,0xFF,
0xF0,0xE7,
0xF0,0xC3,
0xF9,0xC3,
0xFF,0xE7,
0xFF,0xFF,
};

The image below shows a converted photo of me into a 1 bit BMP file and then converted into the byte array for the display.

e-paper display with image loaded

The source code for the app can be downloaded from https://github.com/briandorey/BitmapToByteArrayConverter

Permalink


0 Comments



Post your comment