Close

An Easy-to-source Epaper Breakout Board

A project log for SAGES

What is the best way to ensure the progress of humanity 10,000 years in the future?

jareklupinskijareklupinski 05/28/2016 at 19:020 Comments

One of the biggest difficulties I've faced in finding a good E-paper solution was trying to create a driver board going off the manufacturer's reference circuits for their displays. Often these schematic contain components that are either non-stocked in the US or local to their geographic area. After chatting with a few people in the Hacker Channel and reaching out to the manufacturer, I finished a tiny breakout board that should make it easy to communicate with an epaper display, using only parts that are easily sourceable from digikey/mouser/etc in the USA.

For testing I was using a Teensy LC as I already had one connected to my PC. The simple SPI bitbanger function in the demo code should be easy enough to port to the esp8266, before optimizing using its hardware SPI.

#define D0_PIN 0  //SPI Clock
#define D1_PIN 1  //SPI Data
#define CS_PIN 2  //Chip Select, Low to select chip
#define DC_PIN 3  //When Sending Index set to Low, When sending Data set to High
#define RS_PIN 4  //Reset pin, hold High
#define BS_PIN 5  //Busy Pin, Low is busy

void softwareSpi( byte data ) {
  for ( int i = 0; i < 8; i++ ) {
    if ((( data >> (7-i) ) & 0x01 ) == 1 ) digitalWrite( D1_PIN, HIGH );
    else digitalWrite( D1_PIN, LOW );
    digitalWrite( D0_PIN, HIGH );
    digitalWrite( D0_PIN, LOW );
  }
}

void sendIndexData( byte index, byte *data, int len ) {
  digitalWrite( CS_PIN, LOW );
  digitalWrite( DC_PIN, LOW );
  softwareSpi( index );
  digitalWrite( DC_PIN, HIGH );
  for ( int i = 0; i < len; i++ ) softwareSpi( data[ i ] );
  digitalWrite( CS_PIN, HIGH );
}

void setup() {
  //set I/O registers for pin functions
  pinMode( D0_PIN, OUTPUT );
  pinMode( D1_PIN, OUTPUT );
  pinMode( CS_PIN, OUTPUT );
  pinMode( DC_PIN, OUTPUT );
  pinMode( RS_PIN, OUTPUT );
  pinMode( BS_PIN, INPUT_PULLUP );
  //set pins to initial states
  digitalWrite( RS_PIN, LOW );
  digitalWrite( CS_PIN, LOW );
  digitalWrite( D1_PIN, LOW );
  digitalWrite( D0_PIN, LOW );

  //Power on COG - VCC/VDD already connected
  delay( 50 );                         //Delay 50ms
  digitalWrite( RS_PIN, HIGH );        //RES# = 1
  delay( 1 );                          //Delay 1ms
  digitalWrite( CS_PIN, HIGH );        //CS# = 1

  //Initialize COG Driver              
  while( digitalRead( BS_PIN ) == HIGH ); //Make sure BUSY = LOW
  
  byte data1[] = { 0xCF, 0x00 };
  sendIndexData( 0x01, data1, 2 );     //Driver output control setting
  byte data2[] = { 0x00 };
  sendIndexData( 0x0F, data2, 1 );     //Gate scan start setting
  byte data3[] = { 0x03 };
  sendIndexData( 0x11, data3, 1 );     //Data entry mode setting
  byte data4[] = { 0x00, 0x0D };  
  sendIndexData( 0x44, data4, 2 );     //Set RAM X - Start-End position
  byte data5[] = { 0x00, 0xCF };  
  sendIndexData( 0x45, data5, 2 );     //Set RAM Y - Start-End position
  byte data6[] = { 0x00 };
  sendIndexData( 0x4E, data6, 1 );     //Set RAM X address counter
  byte data7[] = { 0x00 };
  sendIndexData( 0x4F, data7, 1 );     //Set RAM Y address counter

  //Send Image to Cog
  byte data8[2912];
  for ( int i = 0; i < 2912; i++ ) data8[ i ] = (i/8)%255;
  sendIndexData( 0x24, data8, 2912 );

  //Update command sequence
  byte data9[] = { 0x80 };
  sendIndexData( 0x3C, data9, 1 );     //Select border waveform
  byte data10[] = { 0x10, 0x0A };  
  sendIndexData( 0x03, data10, 2 );    //Set gate driving voltage
  byte data11[] = { 0x00 };
  sendIndexData( 0x05, data11, 1 );    //Normal analog mode
  byte data12[] = { 0x00, 0x00, 0x00 }; 
  sendIndexData( 0x75, data12, 3 );    //Normal analog mode
  byte data13[] = { 0x19, 0x00 };  
  sendIndexData( 0x1A, data13, 2 );    //Send the temperature value
  byte data14[] = { 0xF7 };
  sendIndexData( 0x22, data14, 1 );    //Set update sequence
  byte data15[] = { 0x00 };
  sendIndexData( 0x20, data15, 1 );    //Active display update sequence
}

void loop() {

}

Discussions