Issues porting Adafruit EPD ThinkInk library

Hey there everyone. I’ve been trying to port over Adafruit’s EPD library v4.4.0 in order to use Adafruit’s 2.9" Grayscale eInk / ePaper Display FeatherWing. I’ve been having a couple issues with this, so here is what I have done thus far.

I first forked @rickkas7 Adafruit_EDP_RK library and tried to check for similarities before woking off of the new version. Then I imported the new v4.4.0 library and encountered a couple errors related to MISO declarations. I fixed these errors by manually renaming each MISO int to spi_miso. You can see this in my commit here.

The example titled ThinkInk_gray4.ino now compiles and flashes to my Argon, but I still don’t see any activity on the display. I can also see the serial output on my computer, so I know that the example program is running. I’m relatively new to migrating Arduino libraries into the Particle platform, so I’d greatly appreciate any help here. I’m more than happy to provide any more info that I missed. Thanks!

@RAkerman @ZinggJM may be able to help you or you may learn enough from his great EPD libraries. Personally, not Adafruit EPD library, I find the Adafruit libraries can be tricky to understand and port because they have been written for multiple processors. If the program compiles then are you sure of a. the waveform being used and b. even simpler - is it correctly connected/there isn’t a connection wire broken?

Thanks for the insight. I’ve triple checked the pinouts, tried with another identical board, and set the SRAM_CS pin to -1, but still no dice. As far as the waveform goes, I have no idea what it is and I cannot find a variable/function that could modify it. I guess I will continue to tinker around with the library, but there are still no updates at all on the display.

And you have pull-ups on SPI MOSI, DC/RS and CS?

The waveform is an array of bytes that contain commands and values that are unique to each display.

Without these correct the display can just sit there blank. I tried to write a drive from scratch and it worked sort of but not fully - because some specified command values don’t work - so experience and trial and error is needed.

Mr Zingg has very diligently tested the settings for a number of EPDs.

I’ve been pulling out all the stops, but still no progress. The waveforms should be correct, there is a big directory full of drivers for each display type. I lack the experience to be able to look at all of those hex values and pick something out that is wrong. As far as the pinMode declarations, it seems that they are marking most of them as an OUTPUT and using a couple port masks. Here is a snippet that might be useful:

  pinMode(_dc_pin, OUTPUT);
  pinMode(_cs_pin, OUTPUT);

  csPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(_cs_pin));
  csPinMask = digitalPinToBitMask(_cs_pin);
  dcPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(_dc_pin));
  dcPinMask = digitalPinToBitMask(_dc_pin);

At first I though the variable _dc_pin was messing things up because it is of type int8_t, but I am thinking that it should be fine when we declare D5 as the pin. I also tried to fiddle with how the MOSI and SPI variables are declared, but I hit a wall with that too. I have a firm grasp on C++, but in terms of the larger scope of this library, I am lost.

This illustrates my point about the libraries being written to handle many types of processor - these macros are unnecessary for Particle/Argon - you could rule them out by a global replacement with pinSetFast(_cs_pin) and pinResetFast(_cs_pin) etc. Likely there will be a function to write to SPI. On that topic has the settings of SPI been made correctly; Mode, speed?

I think you are right with regards to how the library interfaces with the SPI pin. The EPD ThinkInk library transitioned to using the Adafruit_BusIO library for SPI, which handles most of the IO transactions. I’ve traced the declaration path for my particular display, hopefully someone will see something that I missed.


// 2.9" Grayscale Featherwing or Breakout:
ThinkInk_290_Grayscale4_T5 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);


ThinkInk_290_Grayscale4_T5(int8_t DC, int8_t RST, int8_t CS, int8_t SRCS,
                             int8_t BUSY = -1, SPIClass *spi = &SPI)
      : Adafruit_IL0373(296, 128, DC, RST, CS, SRCS, BUSY, spi){};


Adafruit_IL0373::Adafruit_IL0373(int width, int height, int8_t DC, int8_t RST,
                                 int8_t CS, int8_t SRCS, int8_t BUSY,
                                 SPIClass *spi)
    : Adafruit_EPD(width, height, DC, RST, CS, SRCS, BUSY, spi) {
  buffer1_size = ((uint32_t)width * (uint32_t)height) / 8;
  buffer2_size = buffer1_size;

  if (SRCS >= 0) {
    use_sram = true;
    buffer1_addr = 0;
    buffer2_addr = buffer1_size;
    buffer1 = buffer2 = NULL;
  } else {
    buffer1 = (uint8_t *)malloc(buffer1_size);
    buffer2 = (uint8_t *)malloc(buffer2_size);


Adafruit_EPD::Adafruit_EPD(int width, int height, int8_t DC, int8_t RST,
                           int8_t CS, int8_t SRCS, int8_t BUSY, SPIClass *spi)
    : Adafruit_GFX(width, height), sram(SRCS) {
  _cs_pin = CS;
  _reset_pin = RST;
  _dc_pin = DC;
  _busy_pin = BUSY;
  if (SRCS >= 0) {
    use_sram = true;
  } else {
    use_sram = false;

  spi_dev = new Adafruit_SPIDevice(CS,
                                   4000000,               // frequency
                                   SPI_BITORDER_MSBFIRST, // bit order
                                   SPI_MODE0,             // data mode

  singleByteTxns = false;
  buffer1_size = buffer2_size = 0;
  buffer1_addr = buffer2_addr = 0;
  colorbuffer_addr = blackbuffer_addr = 0;
  buffer1 = buffer2 = color_buffer = black_buffer = NULL;

At that last part there spi_dev = new Adafruit_SPIDevice(); that is the only declaration related to SPI that I can find within the scope of the project.

Also, does anyone know of a way to help narrow down what portion of this library is failing communication wise? Thanks.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.