WaveShare 3.52 e-paper

Hi -

I read through some posts, but could not find one matching my WaveShare 3.52inch E-Paper display. I have some code and got it working to a certain extent. Below is the example that comes with the library:


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

#define COLORED     0
#define UNCOLORED   1

void setup() {
    // put your setup code here, to run once:
    Serial.begin(115200);
    Epd epd;
    if (epd.Init() != 0) {
        Serial.print("e-Paper init failed");
        return;
    }
    Serial.print("3.52inch e-paper demo\r\n ");
    Serial.print("e-Paper Clear\r\n ");

    epd.display_NUM(EPD_3IN52_WHITE);
    epd.lut_GC();
    epd.refresh();

    epd.SendCommand(0x50);
    epd.SendData(0x17);

    delay(2000);

    // UBYTE image[700];
    // Paint paint(image, 200, 25);    // width should be the multiple of 8   

    // paint.SetRotate(ROTATE_0);
    // paint.Clear(COLORED);

    // Serial.print("Drawing:BlackImage\r\n ");
    // paint.DrawStringAt(0, 0, "e-Paper Demo", &Font24, UNCOLORED);
    // epd.display_part(paint.GetImage(), 0, 0, paint.GetWidth(), paint.GetHeight());
    // epd.lut_GC();
    // epd.refresh();
    // delay(2000);
    
    
    epd.display(IMAGE_DATA);
    epd.lut_GC();
    epd.refresh();
    delay(2000);
    
    Serial.print("clear and sleep......\r\n ");
    epd.Clear();
    delay(2000);
    epd.sleep();
    Serial.print("end\r\n ");
}

void loop() {
    // put your main code here, to run repeatedly:

}

Off the bat this does not compile. There seems to be an issue here:

    epd.display(IMAGE_DATA);

With the code below, I am at least able to print a single line of text and move it around, but for the life of me, I cannot get it to print two lines of text :exploding_head:

#include <SPI.h>
#include "../lib/E_Paper/src/EPD_3in52.h"
#include "../lib/E_Paper/src/imagedata.h"
#include "../lib/E_Paper/src/epdpaint.h"

#define COLORED     0
#define UNCOLORED   1

void setup() {
    // put your setup code here, to run once:
    Serial.begin(115200);
    Epd epd;
    if (epd.Init() != 0) {
        Serial.print("e-Paper init failed");
        return;
    }
     Serial.print("3.52inch e-paper demo\r\n ");
     Serial.print("e-Paper Clear\r\n ");

    epd.display_NUM(EPD_3IN52_WHITE);
    epd.lut_GC();
    epd.refresh();

    epd.SendCommand(0x50);      // not sure what this is for
    epd.SendData(0x17);         // not sure what this is for

    delay(2000);

       UBYTE image[1000];
       Paint paint(image, 240, 30);    // width should be the multiple of 8   
       paint.SetRotate(0);
       paint.Clear(COLORED);

      paint.DrawStringAt(25, 0, "WELCOME", &Font24, UNCOLORED);
      epd.display_part(paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight());
      epd.lut_GC();
      epd.refresh();


    //epd.display(IMAGE_DATA);

    // epd.lut_GC();
    // epd.refresh();
    // delay(2000);
    
    // Serial.print("clear and sleep......\r\n ");
    // epd.Clear();
     delay(2000);
     epd.sleep();
    // Serial.print("end\r\n ");
}

void loop() {
    delay(2000);

}

Also hoping I can increase the font size beyond 24, but I will deal with that once I get multiple text strings to print. Rotation also seem to be buggy, but will look into that a bit more.

Hoping someone can help.

Regards,
Friedl.

This is just a guess, but I'd try something like:

paint.DrawStringAt(25, 0, "WELCOME", &Font24, UNCOLORED);
paint.DrawStringAt(25, 30, "Another line", &Font24, UNCOLORED);

The missing IMAGE_DATA is probably because you're missing the ImageData.cpp file which is a static array of image data. But the string drawing example is probably more useful anyway.

Hi @rickkas7 -

I do have it included, but yes I agree, I will most likely not use images in this particular case as I will be displaying variables exclusively.

I have tried something similar which did not work, but let me try again. I have a little better understanding of how the X and Y values are used with rotation (I think, hehe) so maybe I will het it working. I will post an update.

Thanks!!
Friedl.

Hi @rickkas7

       UBYTE image[4000];
       Paint paint(image, 60, 310);    // width should be the multiple of 8   
       paint.SetRotate(3);
       paint.Clear(COLORED);

      paint.DrawStringAt(0, 0, "WELCOME TO THE", &Font24, UNCOLORED);
      paint.DrawStringAt(0, 30, "EVENT!", &Font24, UNCOLORED);
      //paint.DrawStringAt(0, 60, "ROOM: 123", &Font24, UNCOLORED);
      //paint.DrawStringAt(0, 120, "STARTS: 16:00", &Font24, UNCOLORED);

Ok, so I am amble to print two strings.... If I want ti add more, I need to increase the

Paint paint (image,60, 310) 

to e.g.

Paint paint (image,120, 310) 

At the same time then it seems I need to increase

UBYTE image[4000];

which then leads to the Argon flashing red. Do you know what the purpose is of UBYTE ?? In the example it us set to 700, but I have not been able to get it working at 700. The other major downside of this display seems to be the max font size of 24 :pensive:

Regards, Friedl.

It looks like the image buffer size should be width * height / 8.

Also the width you pass in must be a multiple of 8.

Hi @rickkas7

This display / library getting the better of me :pensive: I am able to get some info on the screen, but not enough and also not in the matter I would think it should be done. Below is code I am trying to simply print 4 lines of info

UBYTE image[10800];

   Paint paint(image, 240, 360);     // width should be the multiple of 8   
   paint.SetRotate(3);              // Top right (0,0)
   paint.Clear(COLORED);

   paint.DrawStringAt(10, 10, "ROOM: ", &Font24, UNCOLORED);
   paint.DrawStringAt(170, 10, "BALLROOM", &Font24, UNCOLORED);

   paint.DrawStringAt(10, 35, "TITLE: ", &Font24, UNCOLORED);
   paint.DrawStringAt(170, 35, "WORKSHOP 01", &Font24, UNCOLORED);

   paint.DrawStringAt(10, 60, "START: ", &Font24, UNCOLORED);
   paint.DrawStringAt(170, 60, "14:00", &Font24, UNCOLORED);

   paint.DrawStringAt(10, 90, "END: ", &Font24, UNCOLORED);
   paint.DrawStringAt(170, 90, "16:00", &Font24, UNCOLORED);

   epd.display_part(paint.GetImage(), 0, 0, paint.GetWidth(), paint.GetHeight());  // (Y, X)

As is, this code causes the Argon to flash RED briefly, then returns to normal but never passes the text to the display. If I reduce the buffer size to 4000 and reduce the Paint paint (image, 240, 360) to e.g. 88 x 360, I can al least get some data on the screen. Is there a cap on the buffer size? I am using an Argon as, if I am not mistaken, it has the same memory size as the B404x which I will be using for the final product.

My idea was to rather have several small images that could be updated individually, similar to what I am used to doing with a TFT display, but so far I gave not been able to get this working.

Regards, and many thanks!!

Friedl.

Declare this as a global variable. Within a function, it's allocated on the stack and that size is larger than the stack and may cause an SOS or can cause the device to lock up.

1 Like

Hi @rickkas7

EDIT:

Worked like a charm, thanks!!

IMHO... aside from the obvious in terms of low power consumption, these screens fail to impress. Then again might just me my lack of programming skills :sweat_smile:

I tried to implement two regions, the first all the static content e.g. headers. The second then all the variables, but I have not been successful in doing this.

Kind Regards,
Friedl.

I tried to implement two regions

The hardware may not support this. Because of the way the ePaper displays work, with some displays you have to refresh the entire display in one pass because that's just how the hardware works.

1 Like

Hi @rickkas7

Thanks. It is the first time I use ePaper displays, so all new to me :slight_smile: Have a good weekend and thanks again, really appreciate the help!

Regards,
Friedl

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