Tuesday, October 21, 2014

Getting Eink Display working with SAMA5D3 XPLAINED Board using Python3

Wrote some python code to run the Pervasive Display 2" Eink via COG Driver board (http://repaper.org).  I am running Debian Jessie on the SAMA5D3 XPLAINED board.

First lets connect up the SAMA5D3 to the COG Driver as follows.  You should look for the pin on the specified header.  The XPLAIN board is Arduino compatible so thus the pin numbers should be equivalent to other Arduino boards.  The board port/pins section is just for reference and not needed to connect up.

Pin NumberDescriptionColorSAMA5D3
Pin
SAMA5D3
Header
Board
Port/Pins
1.Vcc 3VRed3V3J14
2.(LED1)White-

3.(UART_RX)Grey-

4.(UART_TX)Purple-

5.(SW2)Blue-

6.TemperatureGreenA0J17C18
7.SPI_CLKYellow13J15C24
8.BUSYOrange7J18C5
9.PWMBrownPA20J19A20
10./RESETBlack6J18C6
11.PANEL_ONRed2J18C9
12.DISCHARGEWhite4J18C28
13.BORDER_CONTROLGrey3J18C8
14.SPI_MISOPurple12J15C22
15.SPI_MOSIBlue11J15C23
16.(RST/SBWTDIO)Green-

17.(TEST/SBWTCK)Yellow-

18.FLASH_CSOrange9J15C3
19./EPD_CSBrown8J15C4
20.GNDBlackGNDJ14
With the boards connected you now need to make sure you have GPIO, PWM, and SPI functioning on the debian build along with python 3 and the appropriate additional libraries.  Previous posts help you setup a Debian Jessie kernel and root file system.  Two other posts demonstrate how to get PWM and SPI working.  Then just make sure you have installed (apt-get install) python3 and python3-pil.  Finally you will need the liberation fonts for the text demo and this can be installed by doing an apt-get install fonts-liberation.

The sample python 3 code is available at this site: https://github.com/photonthunder/thunderLightning/tree/master/pythonEink.  There are three files: DebianIO.py, SpiBus.py, and EinkDriver.py.

To run the demo code just type ./EinkDriver.py

If you don't see anything on the display use the backside of the COG driver board and make sure that the PWM is running (should be between 100-300 kHz), that the pins are changing state, and that you are getting SPI data.  There is no feedback so you really won't know if it is working until you see data on the screen.  You can run DebianIO.py or SpiBus.py to test the IO or the spidev and see if they are working.

Good Luck