Understanding how Waveshare e-paper displays work

I bought a 4.2 inch Waveshare e-Paper display and have interfaced it to an Arduino Mega. What I'm trying to figure out is how to program it properly. I have a demo up and running, but I have several questions. My code is below for reference and a photo of what the display looks like.

Here are my questions.

  1. This display is 400x300 pixels. What size image[] array should I use? What is that array used for?

  2. Does the Mega have enough memory to treat the entire display as a single image?

  3. Right now, I am creating smallish windows (with paint.SetWidth and paint.SetHeight) to hold individual text strings and lines? Is this the correct way to approach programming this display? This relates to question 2.

  4. What exactly does epd.SetPartialWindowBlack do?

  5. Looking at the TITLE component, first I set the width and height as a 400x24 pixel window. Next I do a Clear and then Drawstring at x=175. My attempt to center the text. Then comes the SetPartialWindowBlack command. Does this sequence make sense?

I guess ideally I'd like to know if I can simply declare the display to be 400x300 and then pick different coordinates for the various test strings and lines.

  1. I want to load up the display with labels and then insert changing values, like temperature. I'm not there yet, but hopefully it is easy to do without the 10+ flashes I see now whenever I run this simple sample.

Feedback appreciated.

#include <SPI.h>
#include "epd4in2b_V2.h"
#include "imagedata.h"
#include "epdpaint.h"

#define COLORED     0
#define UNCOLORED   1

void setup() {
  Serial.begin(9600);
  Epd epd;

  if (epd.Init() != 0) {
    Serial.print("e-Paper initialization failed");
    return;
  }

  epd.ClearFrame();                // This clears the SRAM of the e-paper display
  unsigned char image[3000];       // how do I calculate what value I need?
  Paint paint(image, 400, 24);     // width should be the multiple of 8

  // Title
  paint.SetWidth(400);
  paint.SetHeight(24); 
  paint.Clear(UNCOLORED);
  paint.DrawStringAt(175, 0, "TITLE", &Font24, COLORED);
  epd.SetPartialWindowBlack(paint.GetImage(), 0, 0, paint.GetWidth(), paint.GetHeight());

  // horizontal line
  paint.SetWidth(400);
  paint.SetHeight(2);
  paint.Clear(UNCOLORED);
  paint.DrawHorizontalLine(0, 0, 400, COLORED);
  epd.SetPartialWindowBlack(paint.GetImage(), 0, 25, paint.GetWidth(), paint.GetHeight());

  // Subtitle
  paint.SetWidth(400);
  paint.SetHeight(24);
  paint.Clear(UNCOLORED);
  paint.DrawStringAt(170, 0, "SubTitle", &Font16, COLORED);
  epd.SetPartialWindowBlack(paint.GetImage(), 0, 35, paint.GetWidth(), paint.GetHeight());

  // horizontal line
  paint.SetWidth(400);
  paint.SetHeight(2);
  paint.Clear(UNCOLORED);
  paint.DrawHorizontalLine(0, 0, 400, COLORED);
  epd.SetPartialWindowBlack(paint.GetImage(), 0, 55, paint.GetWidth(), paint.GetHeight());

  // vertictal line
  paint.SetWidth(1);
  paint.SetHeight(245);
  paint.Clear(UNCOLORED);
  paint.DrawVerticalLine(0, 0, 245, COLORED);
  epd.SetPartialWindowBlack(paint.GetImage(), 100, 56, paint.GetWidth(), paint.GetHeight());


  /* This displays the data from the SRAM in e-Paper module */
  epd.DisplayFrame();

  /* This displays an image */
  // epd.DisplayFrame(IMAGE_BLACK, IMAGE_RED);

  /* Deep sleep */
  epd.Sleep();
}

void loop() {


}

Have you read the display library documentation?

The documentation at https://www.waveshare.com/wiki/4.2inch_e-Paper_Module_(B) doesn't really explain it very well.

That isn't the library documentation.

Also this is a duplicate thread...
https://forum.arduino.cc/t/how-to-update-only-a-portion-of-a-e-paper-display/1002196

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