2 Replies Latest reply on Mar 24, 2018 4:35 AM by GeIo_1586191

    Any library or tips on how to create a compatible eInk image at runtime


      At the moment if I want to create a suitable byte array for an image to be displayed on the eInk display, I first need to convert my 264px x 176px bitmap into a "variable array" using the manufacturer's PDI Apps utility program.


      This works fine for hardcoding but now I want to create an application which includes some QR code generator code (you can find various libraries on github etc.) whereby I can create a compatible eInk image at runtime. The idea for the example app is to allow someone to send a text string via Bluetooth and for a QR code to be generated and displayed on the eInk display.


      The problem now is that it is not obvious how the PDI App converts the bitmap. The methodology appears to have changed compared to the old eInk displays.


      So, does anyone have a conversion library that will do this or does anyone have some tips on how to do it?


      I have reviewed Appendix B of the example "CE218133 - PSoC 6 MCU E-INK Display with CapSense" document but none the wiser.






        • 1. Re: Any library or tips on how to create a compatible eInk image at runtime



          i did this with a python script. You can implement this in c if you have all pixel values as array.


          from PIL import Image

          import numpy as np

          import os

          import matplotlib.pyplot as plt

          import binascii


          img = Image.open("eink.jpg")

          n_img = np.asarray(img)

          n_img = n_img[:,:,0]


          height, width = n_img.shape[:2]


          op = "output.c"


          oS = "/* Cypress custom image */" + os.linesep

          oS += "cy_eink_image_t const pyimg[CY_EINK_IMAGE_SIZE]=" + os.linesep

          oS += "{" + os.linesep


          testImg = np.zeros((height,width))



          for y in range(height): #rows

              for x in range(width/8): # columns

                  intVal = 0

                  for i in range(0,8): # 8 pixel in x = 1 byte

                      boolVal = int(n_img[y,8*x+i] > 127 )

                      intVal += boolVal << (7-i)

                      testImg[y,8*x+i] = boolVal

                  hexString = '0x{:02x}'.format(intVal).upper().replace("X","x")

                  oS += hexString + ", "

              if y == height - 1:

                  oS = oS[:-2]

              oS += " // " + str(y+1) + os.linesep

          oS += "};" + os.linesep


          with open(op, "w+") as outFile:






          You go row for row and for each column byte combine 8 pixel (boolean, 1 or 0) to one byte. I Think the most significant bit ist the left most pixel. Its mostly bit shifting.

          1 of 1 people found this helpful