Writing ontop of a Bitmap with gxepd2

Hi!

I recently bought a 1.54inch Waveshare E-Paper Display and got it working with gxepd2. I designed a Background image that covers the whole screen and now I want to write a string on a part of it. I already tried the following code which seems like it should work to me, but the text is not visible. After commenting out the image drawing, I can see the text which makes me believe that it is some kind of "layer" problem.

#include <GxEPD2_BW.h>
#include <Fonts/FreeSans12pt7b.h>
#include "imagedata.h"
#include "DHTesp.h"

GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(SS, 0, 5, 4)); // CS, DC, RST, Busy  // GDEH0154D67

double temperatur = 0.0;

void setup() {
  Serial.begin(115200);
  display.init();
  display.setRotation(0);
  display.setFullWindow();

  // Background
  display.fillScreen(GxEPD_BLACK);
  display.drawBitmap(0, 0, Background, 200, 200, GxEPD_WHITE);
  while (display.nextPage());

  temperatur = 21.2;
  updateTemp(temperatur);
}

void loop() {

}

void updateTemp(float temperatur) {
  int16_t tbx, tby;
  uint16_t tbw, tbh;

  uint16_t x = 30;
  uint16_t y = 178;
  String temp_string = String(temperatur) + "°C";
  
  display.setFont(&FreeSans12pt7b);
  display.setTextColor(GxEPD_BLACK);
  display.getTextBounds(temp_string, x, y, &tbx, &tby, &tbw, &tbh);
  
  display.setPartialWindow(tbx, tby, tbw, tbh);
  
  display.firstPage();

  do {
    display.fillScreen(GxEPD_WHITE);
    display.setCursor(x, y);
    display.print(temp_string);
    delay(50);

  } while (display.nextPage());    
}

Any ideas what I am doing wrong?
Thanks!

Hi!

Maybe it helps if you use a complete page loop in your code part for the bitmap drawing:

  display.firstPage();

  do {

(and the } before while) is missing.

And it helps if you add a baud rate to display.init(), e.g. display.init(115200), and then look at and post the diagnostic output in Serial Monitor.

Tell us which processor and board you use. I don't like to have to guess.
-jz-

First of all thanks for your fast supply!
I am using a D1 Mini (ESP8266). I tried your suggestion but didn't have any luck.

#include <GxEPD2_BW.h>
#include <Fonts/FreeSans12pt7b.h>
#include "imagedata.h"

GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(SS, 0, 5, 4)); // CS, DC, RST, Busy  // GDEH0154D67

double temperatur = 0.0;

void setup() {
  Serial.begin(115200);
  display.init(115200);
  display.setRotation(0);
  display.setFullWindow();
  
  // Background
  display.firstPage();
  do {
    display.fillScreen(GxEPD_BLACK);
    display.drawBitmap(0, 0, Background, 200, 200, GxEPD_WHITE);
  } while (display.nextPage());

  temperatur = 21.2;
  updateTemp(temperatur);
}

void loop() {
}

void updateTemp(float temperatur) {
  
  int16_t tbx, tby;
  uint16_t tbw, tbh;
 
  uint16_t x = 30;
  uint16_t y = 178;
  String temp_string = String(temperatur) + "°C";

  display.setFont(&FreeSans12pt7b);
  display.setTextColor(GxEPD_BLACK);
  display.getTextBounds(temp_string, x, y, &tbx, &tby, &tbw, &tbh);

  display.setPartialWindow(tbx, tby, tbw, tbh);

  // Ausgabe  
  display.firstPage();

  do {
    display.fillScreen(GxEPD_WHITE);
    display.setCursor(x, y);
    display.print(temp_string);
    delay(50);

  } while (display.nextPage());    
}

In the Serial Monitor I now get the following:

_PowerOn : 94256

_Update_Full : 3860132

_PowerOff : 139847

_PowerOn : 94817

_Update_Part : 94346

Quick answer: try with DEPG0150BN, your display has no wft for differential refresh in OTP.
-jz-

Thanks! I see the text now, is it going to be a problem that DEPG0150BN is for 1.50 inch displays?

No. Did you measure the diagonal dimension of the active part of your display? Is it one millimeter too short? What is the inking on the flexible connector of the panel?
I have added the inking found on the panels I have to GxEPD2_display_selection_new_style.h
-jz-

Seems like DEPG0150BN is the right one then, I was already confused by all those comments in the selection file. :sweat_smile:
Thanks again.

I didn't pay enough attention to that part of your post.
I know that Waveshare actually uses the DEPG0150BN on this display.
Maybe because it is slightly less expensive, as it slightly shorter. :grinning:
Panels from DKE are less expensive, they are produced for a more price sensitive market than the ones from Good Display.
-jz-

Thanks for the hint, just out of interest, how would I hook such an GoodDisplay Display up to my D1 Mini. It doesn't seem to have a driver board.

With the DESPI-C02. It isn't a driver board, but a connection module. It has also the external components to complete the booster circuit for the panel driving voltages.
The controller is on the panel, the silvery slab near the flexible connector.
Epaper HAT Connection Adapter Board for E Ink Display, DESPI-C02
Connection Adapter Board E-Ink HAT For Epaper Display DESPI-C02
I recommend the DESPI-C02 for use with 3.3V processors, especially for low power use.