Waveshare E-Paper has like two different pages

Hallo,

I try to control a Wavesher E-Paper 2.9 V2 with mit Heltec ESP32 Wifi Lora V2 with GitHub - ZinggJM/GxEPD2: Arduino Display Library for SPI E-Paper Displays Library.

Therefore I have a loop where I, everytime I get a keyboardinput, append/print/partial update the charactor on the display.

The problem is that it seems that there a two different pages, where the characters are stored and the display only shows these or that characters (little hard to explain - here is an example):

Keyboard-Input: "Hello World how are you"

Display-Outcome: Sometimes something like "H ll W rld ow ar y u" and sometimes "" a o o h e o " (the missing characters of the first string).

Everytime I update the display it changes (very fast) between the one an teh other string and randomly stop at on string an shows that.

Code:

#define ENABLE_GxEPD2_GFX 0
#define MAX_MESSAGES 10
#define MAILBOXGUI_LINES 5

#define MAX_EPD_PREVIEW_LINES 3
#define MAX_EPD_PREVIEW_ROWS 21

#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h> // from Adafruit // ..\Arduino\libraries\Adafruit_GFX_Library
#include <Fonts/FreeMono9pt7b.h> // from Adafruit // ..\Arduino\libraries\Adafruit_GFX_Library
#include <Fonts/FreeSans9pt7b.h> // from Adafruit // ..\Arduino\libraries\Adafruit_GFX_Library
#include <Fonts/FreeSerif9pt7b.h> // from Adafruit // ..\Arduino\libraries\Adafruit_GFX_Library
#include <Fonts/Org_01.h> // from Adafruit // ..\Arduino\libraries\Adafruit_GFX_Library
#include <Fonts/Picopixel.h> // from Adafruit // ..\Arduino\libraries\Adafruit_GFX_Library
#include <Fonts/TomThumb.h> // from Adafruit // ..\Arduino\libraries\Adafruit_GFX_Library
#include <Fonts/Tiny3x3a2pt7b.h> // from Adafruit // ..\Arduino\libraries\Adafruit_GFX_Library

#include "GxEPD2_display_selection_new_style.h"

void setup()
{
 // DISPLAY
  display.init(115200);

  displayInit(1, &FreeMonoBold9pt7b, GxEPD_BLACK, GxEPD_WHITE);
}

void loop()
{
// ....
// everytime a new keyboard-input occurs 
EPD_print_preview(EPD_preview_buffer);

// ...
}
void EPD_print_preview (char input[]) {

// ...

	for (int i = 0; i < MAX_EPD_PREVIEW_LINES; i++) {
	  int number = ((EPD_preview_lines - MAX_EPD_PREVIEW_LINES + 1 + i)*MAX_EPD_PREVIEW_ROWS);
	  Serial.println(number);

	  char line[MAX_EPD_PREVIEW_ROWS];
	  for (int c = 0; c < MAX_EPD_PREVIEW_ROWS; c++) {
		line[c] = input[c + number];  
	  }

	  Serial.printf("%d: ", i);
	  printArray(line, MAX_EPD_PREVIEW_ROWS);
	  display.firstPage();
	  do {
		display.setPartialWindow(0, (MAILBOXGUI_LINES + i)*16, 11*MAX_EPD_PREVIEW_ROWS, 16);
		display.fillRect(0, (MAILBOXGUI_LINES + i)*16, 11*MAX_EPD_PREVIEW_ROWS, 16, GxEPD_WHITE); // Delete everything at position
		display.setCursor(0, ((MAILBOXGUI_LINES + i)*16)+11); // set the postition to start printing text
		
		display.print(line); // print some text
		display.print("\n"); // print some text
	  }
	  
	  while (display.nextPage());
	  delay(50);
	  
	  preview_inputLine = MAX_EPD_PREVIEW_LINES - 1;
	}
    
 // ...
}

Do you know whats wrong?

Thank you
sut3

@sut3, Hi, welcome to the forum! Did you read How to get the best out of this forum?

Your post is the kind of posts I don't like to answer. I don't like to try to understand Newbie-code.
I rarely try posted code, only if it is complete, and the information is complete. But this is kind of a last resort.

Please always provide a link to the devices in question, to make things clear.
And provide either the constructor line (old style) or the panel selection (new style).

And in any case first check with GxEPD2_Example.ino. You will notice if there is something wrong. E.g. wrong display selected, or display not supported by GxEPD2.

Replace delay(50) with delay(5000), to have enough time to see what happens, in your code.

Jean-Marc

I've no experience with e-paper yet but it is on my radar. I was planning to use this e-paper Tutorial for my initial test of the display.

Yes, at least one error: your line has no terminating zero. print(line)is unsafe.

Thank you for your answer! As you already noticed, I am new, so sorry for the wrong way of posting :slight_smile:

I tried to reduce complexity and (again) started with GxEPD2_Example and often, after uploading to the ESP the display just show pixels completely random - is this normal?

Information to th HW:
ESP32: https://heltec.org/project/wifi-lora-32/
Display https://www.waveshare.com/wiki/2.9inch_e-Paper_Module (V2)

Code:

// Display Library example for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
// Requires HW SPI and Adafruit_GFX. Caution: the e-paper panels require 3.3V supply AND data lines!
//
// Display Library based on Demo Example from Good Display: http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html
//
// Author: Jean-Marc Zingg
//
// Version: see library.properties
//
// Library: https://github.com/ZinggJM/GxEPD2

// Supporting Arduino Forum Topics:
// Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0
// Good Display ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0

// base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
// enable or disable GxEPD2_GFX base class
#define ENABLE_GxEPD2_GFX 0

#include <GxEPD2_BW.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include "GxEPD2_display_selection_new_style.h"

#include "bitmaps/Bitmaps128x296.h" // 2.9"  b/w
void setup()
{
  Serial.begin(115200);
  Serial.println();
  Serial.println("setup");
  delay(100);
  display.init(115200);

  display.setRotation(1);
  display.setFont(&FreeMonoBold9pt7b);
  display.setTextColor(GxEPD_BLACK);

  display.setFullWindow();
  display.firstPage();
  do
  {
    display.fillScreen(GxEPD_WHITE);
  }
  while (display.nextPage());
  
  delay(1000);
  Serial.println("setup done");

  //helloWorld();
}

void loop()
{
}

// note for partial update window and setPartialWindow() method:
// partial update window size and position is on byte boundary in physical x direction
// the size is increased in setPartialWindow() if x or w are not multiple of 8 for even rotation, y or h for odd rotation
// see also comment in GxEPD2_BW.h, GxEPD2_3C.h or GxEPD2_GFX.h for method setPartialWindow()

const char HelloWorld[] = "Hello World!";
const char HelloArduino[] = "Hello Arduino!";
const char HelloEpaper[] = "Hello E-Paper!";

void helloWorld()
{
  //Serial.println("helloWorld");
  display.setRotation(1);
  display.setFont(&FreeMonoBold9pt7b);
  display.setTextColor(GxEPD_BLACK);
  int16_t tbx, tby; uint16_t tbw, tbh;
  display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  // center bounding box by transposition of origin:
  uint16_t x = ((display.width() - tbw) / 2) - tbx;
  uint16_t y = ((display.height() - tbh) / 2) - tby;
  display.setFullWindow();
  display.firstPage();
  do
  {
    display.fillScreen(GxEPD_WHITE);
    display.setCursor(x, y);
    display.print(HelloWorld);
  }
  while (display.nextPage());
  //Serial.println("helloWorld done");
}

h-File:

// Display Library example for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
// Requires HW SPI and Adafruit_GFX. Caution: the e-paper panels require 3.3V supply AND data lines!
//
// Display Library based on Demo Example from Good Display: http://www.e-paper-display.com/download_list/downloadcategoryid=34&isMode=false.html
//
// Author: Jean-Marc Zingg
//
// Version: see library.properties
//
// Library: https://github.com/ZinggJM/GxEPD2

// Supporting Arduino Forum Topics:
// Waveshare e-paper displays with SPI: http://forum.arduino.cc/index.php?topic=487007.0
// Good Display ePaper for Arduino: https://forum.arduino.cc/index.php?topic=436411.0

// select the display class (only one), matching the kind of display panel
#define GxEPD2_DISPLAY_CLASS GxEPD2_BW

//#define GxEPD2_DRIVER_CLASS GxEPD2_290     // GDEH029A1   128x296, SSD1608 (IL3820)
//#define GxEPD2_DRIVER_CLASS GxEPD2_290_T5  // GDEW029T5   128x296, UC8151 (IL0373)
//#define GxEPD2_DRIVER_CLASS GxEPD2_290_T5D // GDEW029T5D  128x296, UC8151D
//#define GxEPD2_DRIVER_CLASS GxEPD2_290_T94 // GDEM029T94  128x296, SSD1680
#define GxEPD2_DRIVER_CLASS GxEPD2_290_T94_V2 // GDEM029T94  128x296, SSD1680, Waveshare 2.9" V2 variant
//#define GxEPD2_DRIVER_CLASS GxEPD2_290_M06 // GDEW029M06  128x296, UC8151 (IL0373)
//#define GxEPD2_DRIVER_CLASS GxEPD2_260     // GDEW026T0   152x296, UC8151 (IL0373)


#ifndef EPD_CS
#define EPD_CS 4 //SS
#endif

#if defined(GxEPD2_DISPLAY_CLASS) && defined(GxEPD2_DRIVER_CLASS)

// somehow there should be an easier way to do this
#define GxEPD2_BW_IS_GxEPD2_BW true
#define GxEPD2_1248_IS_GxEPD2_1248 true
#define IS_GxEPD(c, x) (c##x)
#define IS_GxEPD2_BW(x) IS_GxEPD(GxEPD2_BW_IS_, x)
#define IS_GxEPD2_1248(x) IS_GxEPD(GxEPD2_1248_IS_, x)

#include "GxEPD2_selection_check.h"

#define MAX_DISPLAY_BUFFER_SIZE 65536ul // e.g.
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))

// adapt the constructor parameters to your wiring

GxEPD2_DISPLAY_CLASS<GxEPD2_DRIVER_CLASS, MAX_HEIGHT(GxEPD2_DRIVER_CLASS)> display(GxEPD2_DRIVER_CLASS(/*CS=5*/ EPD_CS, /*DC=*/ 15, /*RST=*/ 17, /*BUSY=*/ 36)); // Heltec LORA

#endif

Thank you
sut3

No. The reduced code you posted should just clear the display to white.

It seem you have installed Version 1.3.6 I just released, and am waiting to be available with Library Manager.

I didn't notice that you referred to a display that wasn't working with GxEPD2 until just now.

I did my release test with a LOLIN32 Lite, and with Wemos D1 mini. There was no problem.

Jean-Marc

Yes. I get the library directly from \documents\Arduino\libraries... which I downloaded from your GitHub.

So you mean, that this should work and I have an other problem?
sut3

Yes. Next step would be to provide diagnostic output from Serial Monitor, in a code window, please. Best from the full GxEPD2_Example.ino.

Do you mean somathing like that? Thats from GxEPD2_Example.ino . At the very beginning the display also pixels.

setup
_PowerOn : 3
_Update_Full : 1
_PowerOff : 3040001
_PowerOn : 1
_Update_Part : 47001
_Update_Part : 2001
_Update_Part : 1
_Update_Full : 1
_PowerOff : 3039001
_PowerOn : 1
_Update_Full : 1
_PowerOff : 3039001
_PowerOn : 1
_Update_Full : 1001
_PowerOff : 3038001
_PowerOn : 1
_Update_Full : 2001
_PowerOff : 3037001
_PowerOn : 1
_Update_Full : 2001
_PowerOff : 3037001
_PowerOn : 3
_Update_Full : 1
_PowerOff : 3039001
_PowerOn : 2001
_Update_Full : 5001
_PowerOff : 3034001
_PowerOn : 1001
_Update_Part : 90001
_Update_Part : 1001
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1001
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 2001
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1001
_Update_Part : 1
_Update_Part : 2001
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1001
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1001
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1001
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1
_Update_Part : 1001
_Update_Part : 1
_Update_Part : 2001
_Update_Part : 2001
_Update_Part : 1001
_Update_Part : 1
_PowerOff : 1
_PowerOn : 117001
_Update_Full : 1
_PowerOff : 3039001
_PowerOn : 1
_Update_Full : 1
_PowerOff : 3039001
_PowerOn : 1
_Update_Full : 1
_PowerOff : 3039001
setup done

You have random behavior. Many of your BUSY times are wrong. All _Update_Part are wrong.

Did you buy your display from a Waveshare shop?

Check the VCC voltage to the display. It should work with stable 3.3V, but the voltage after the LDO to the panel is marginal. I use a USB 3.0 connector on my notebook, to be sure the supply to the ESP32 or ESP8266 board is strong enough. I don't know how good the LDO on Heltec is.

You can try to supply 5V to the display, but should use a 10k series resistor in the BUSY line then, to protect the processor.

Make sure the white connector to the display is firmly in. And check continuity of the cable. I had one with a bad DuPont connector.

I bought it on Amazon. But it looks like a "original" Waveshare-display.

Maybe the USB-Connector does not delivery enough VCC - I will check that
Thank you!

Version 1.3.6 of library GxEPD2 is available, install or update with Library Manager.

Somehow my second notebook still doesn't see that version, but the third one does.

Jean-Marc

I tried it - did not work...

Could you post an reference diagnostic output from Serial Monitor of the example? So I can compare?

Thank you a lot

Yes, I could, but I don't want to. You can find examples in Waveshare e-paper displays with SPI.

I don't want to waste more time with your confusing topic.

This might be the root cause of your problems. These Heltec boards are known to use unconventional pin assignments. You can search for Heltec in the above topic. You can try different pins, e.g. for BUSY.