GxEPD2 WiFi - image gets loaded multiple times before displaying

Hi, I have waveshare ESP32 Epaper driver board along with the waveshare 7 color 5.65". I modified the WiFi example little bit, so instead of downloading few images from preset url, it instead requests random file name from my server and then downloads that image.
I am running the unmodified show bitmap http buffered function, but for some reason, the image gets downloaded/loaded thrice before actually starting to display... even though the show function is called only once

void setup()
{
  Serial.begin(115200);
  Serial.println();
  Serial.println("setup");

  join_wifi(); //my custom WiFi manager function
  
  setClock();
  
  delay(200);
  // *** special handling for Waveshare ESP32 Driver board *** //
  // ********************************************************* //
#if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
  hspi.begin(13, 12, 14, 15); // remap hspi for EPD (swap pins)
  display.epd2.selectSPI(hspi, SPISettings(4000000, MSBFIRST, SPI_MODE0));
#endif
  // *** end of special handling for Waveshare ESP32 Driver board *** //
  // **************************************************************** //
  
  display.init(115200);
  String soubor = request_random_file(); //sends request to my webserver
  delay(3000);
  showBitmapFrom_HTTP_Buffered("tobikcze.eu", "/files/einkimages/", soubor.c_str(), 0, 0);
  Serial.println("GxEPD2_WiFi_Example done");
  Serial.println("sleeping...");
  sleep();
}

_GxEPD2_WiFi_tobik.zip (12.4 KB)

You should also post the constructor. Then we would see that the page_height is less than the height of the display (at least I believe so). Therefore, for buffered drawing, paged display is needed.
At this time in the evening that's all I provide immediately.
-jz-

#define ENABLE_GxEPD2_GFX 0

#include <GxEPD2_7C.h>

// 7-color e-paper
#define GxEPD2_DRIVER_CLASS GxEPD2_565c // Waveshare 5.65" 7-color
#define GxEPD2_DISPLAY_CLASS GxEPD2_7C

#define USE_HSPI_FOR_EPD

// somehow there should be an easier way to do this
#define GxEPD2_BW_IS_GxEPD2_BW true
#define GxEPD2_3C_IS_GxEPD2_3C true
#define GxEPD2_7C_IS_GxEPD2_7C 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_3C(x) IS_GxEPD(GxEPD2_3C_IS_, x)
#define IS_GxEPD2_7C(x) IS_GxEPD(GxEPD2_7C_IS_, x)
#define IS_GxEPD2_1248(x) IS_GxEPD(GxEPD2_1248_IS_, x)

#define MAX_DISPLAY_BUFFER_SIZE 65536ul // e.g.
#if IS_GxEPD2_BW(GxEPD2_DISPLAY_CLASS)
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))
#elif IS_GxEPD2_3C(GxEPD2_DISPLAY_CLASS)
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8) ? EPD::HEIGHT : (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8))
#elif IS_GxEPD2_7C(GxEPD2_DISPLAY_CLASS)
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= (MAX_DISPLAY_BUFFER_SIZE) / (EPD::WIDTH / 2) ? EPD::HEIGHT : (MAX_DISPLAY_BUFFER_SIZE) / (EPD::WIDTH / 2))
#endif
GxEPD2_DISPLAY_CLASS<GxEPD2_DRIVER_CLASS, MAX_HEIGHT(GxEPD2_DRIVER_CLASS)> display(GxEPD2_DRIVER_CLASS(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25));

//GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=*/ 15, /*DC=*/ 27, /*RST=*/ 26, /*BUSY=*/ 25)); // GDEH0154D67

#if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
SPIClass hspi(HSPI);
#endif

the zipped code is attached to the original post

MAX_HEIGHT = 65536 / (600 / 2) = 218

An error occurred: Body seems unclear, is it a complete sentence?

No, just part of the explanation.

Oh so its just that since the whole buffer doesnt fit into the RAM at once, it loads the image in 3 parts?

Yes, in three horizontal slices, in your case.

In an earlier topic about the same issue, I recommended to load the BMP to flash and draw it from flash, to avoid the additional downloads.

well I got it reduced to just 2 downloads by manually setting the MAX_HEIGHT to 224 instead of the 218
But, I noticed that completely stops after the image gets flashed, and it doesnt continue with the code i have after the showBitmapFrom_HTTP_Buffered()...


You got a corrupted stack space. This is a known effect on ESP32, if you try to use more than 65536 for graphics buffer. You can play with build parameters for ESP32, maybe.

#define MAX_DISPLAY_BUFFER_SIZE 65536ul // e.g.

"e.g." is a bit too weak, maybe. Seems a rather hard limit to work.

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