Go Down

Topic: Waveshare e-paper displays with SPI (Read 74726 times) previous topic - next topic

johweb

One important step for me...
Setting serial to 74880 give me translation of junk characters at boot. With e-paper module connected on spi, Nodemcu hangs saying "Bootmode (7,7) Waiting for host"  :o

johweb

My screen is working !!!  :)
What I found on others forums :
Quote
Ok, after debugging for a while: the problem is with the CSN pin on GPIO pin 15. Pin 15 is also used in the ESP8266 to define boot from SD card.
This user had the same problem : bootmode 7 7 with a spi sensor connected. So I did the same as him : I moved the CS wire from GPIO 15 to GPIO 5 (D1) and changed this line in the demo code :
Code: [Select]
//GxIO_Class io(SPI, /*CS=D8*/ SS, /*DC=D3*/ 0, /*RST=D4*/ 2); // arbitrary selection of D3(=0), D4(=2), selected for default of GxEPD_Class
GxIO_Class io(SPI, /*CS=D1*/ 5, /*DC=D3*/ 0, /*RST=D4*/ 2); // arbitrary selection of D3(=0), D4(=2), selected for default of GxEPD_Class


And now, everything is working fine ! I'm so happy !!
Thanks for your hints, have a nice day.

Khayanna

Hi ZinggJM,

I want to use a Waveshare 2.9 inch B&W EPD with a MEGA 2560 R3.
The display works with a arduino nano pretty well, but the small memory is the problem, so I want to port this to an mega R3.

A few month ago (https://forum.arduino.cc/index.php?topic=487007.390) the was already a thread concerning this, but he never posted a whole code example how he got the display working with the mega.

First Im not clear about the pin allocation. Then, a small code expamle would be great.

Hope you can help me with this,

Khay.

ZinggJM

Hi Khay,

I hope you can be helped with a quick answer; come back if you need more detailed help.

You can use the suggested pin mapping for AVR Arduino (SCK, MOSI, SS, …), just note that the SPI pins are at the ISCP header (6 pin block), not at pin 13, 11, 10.

And although you have slightly more RAM, you still need paged drawing for buffered drawing.

Start with example PagedDisplayExampleSmallRam.ino, if you use GxEPD.

GxEPD2_AVR has a "smaller" example GxEPD2_AVR_Example.ino

Don't forget the series resistors on the data lines.

Jean-Marc
No personal message please; any question may be useful for other users. Use code tags for code. Make links clickable with URL tags. Provide links to the product in question.

Khayanna

Hello Jean-Marc,

thank you for the quick reply.

Now my  Nano is connected like this...

GxEPD2_AVR_BW display(GxEPD2::GDEH029A1, /*CS=*/ SS, /*DC=*/ 9, /*RST=*/ 8, /*BUSY=*/ 7);
D13=CLK
D11=DIN
D10=CS
D09=DC
D08=RST
D07=BUSY
and of course 3V3,GND (RST and DC are swapped, I started with the waveshare example)

...without any serial resistors (?) I didn't get what value to put in here. Seems to work directely with the nano.

Now, how do I need to connect the MEGA in detail?
SS=Digital 53
MOSI=Digital 51
MISO=Digital 52
SCLK=Digital 53
...
(also connected to the ISP header, as you mentioned), see my attachnemt of the MEGA-Pins

what about busy, rst, DC?
Dont have any clue, what has to be connected how to the MEGA
Then, how do I need to change then display(GxEPD2::....) parameters then?

Sorry for those "basic" questions". I already read the complete thread without getting out this info clearly.

Ok, I know that it will be still a paged drawing. Maybe the page size can be increased somehow?

Thanks for your help in advance,
Khay.

ZinggJM

I am short of time today, sorry.

connect MOSI to DIN, use e.g. 4.7k,
SCLK to CLK
SS to CS
eigher from the pins you mentioned, or from the ISCP header.

The other pins just need to correspond to the values in the constructor.
No personal message please; any question may be useful for other users. Use code tags for code. Make links clickable with URL tags. Provide links to the product in question.

Khayanna

Hi Jean-Marc,

after tinkering around, I've found out a setup which works for the MEGA 2560 with the 2.9inch waveshare.

Here's my pin-allocation.

D52=CLK/SCLK
D51=DIN/MOSI
D53=CS/SS
D44=DC
D45=RST
D43=BUSY

and 3v3,GND.

The display-init should look like this:
GxEPD2_AVR_BW display(GxEPD2::GDEH029A1,53, 44, 45, 43);

Probably it's possible to connect them to any other free digital pin.
All data lines have also a 3k9 resistor in series to the Mega-digital pin.

Didn't realize, that the display init-function handles also pin-numbers like '45'.
Where in the lib are the pins assigned? How does the lib know, that there is a MEGA-CPU and  not a AT328?

Khay.

ZinggJM

Hi Khay,

I prefer to not give lessons on C++ programming here, I am not a teacher and not good at teaching or explaining.

Quote
The display-init should look like this:
GxEPD2_AVR_BW display(GxEPD2::GDEH029A1,53, 44, 45, 43);
This is not a display-init; it is the construction of an object instance named "display" of type (aka class) named "GxEPD2_AVR_BW".

The constructor of the class GxEPD2_AVR_BW can be found in the corresponding header file GxEPD2_AVR_BW.h : GxEPD2_AVR_BW.h


as you can see it uses no default parameter values, so you have to specify them, e.g. as you did.

Code: [Select]
    GxEPD2_AVR_BW(GxEPD2::Panel panel, int8_t cs, int8_t dc, int8_t rst, int8_t busy);



The code of the GxEPD2_AVR_BW class does not distinguish between MEGA and 328.
You could make the buffer size dependent on the processor, but this will not make a noticeable performance difference. The value chosen is a "good compromise" for AVR processors.

Code: [Select]
  private:

    static const uint16_t buffer_size = 800;



Jean-Marc
No personal message please; any question may be useful for other users. Use code tags for code. Make links clickable with URL tags. Provide links to the product in question.

opendocumentary

Hi everybody :)

Just playing around with the GxEPD2_32_SD_BitmapExample and it is working great :)
Thanks Jean-Marc for your work.

Does anybody has a tip on how I can create a 3 color bitmap for the 3 color dispays?
I tryed a few programms but could not find any programm that can do it :)

Cheers,
Christian

ZinggJM

Hi Christian,

I am still working on this topic, on enhancements and bugfixes, and on problems with WiFi download of big bitmaps on ESP8266.

You can create a normal bitmap with 24bit per pixel containing e.g. black, white and red (or yellow) parts. Support for bitmaps with 2bpp, 4bpp, 8bpp with palette will follow.

Jean-Marc
No personal message please; any question may be useful for other users. Use code tags for code. Make links clickable with URL tags. Provide links to the product in question.

opendocumentary

#640
Jun 14, 2018, 09:38 am Last Edit: Jun 14, 2018, 09:48 am by opendocumentary
Hi Jean-Marc,

how do I get the third color (yellow/red) to work with bitmap?
I always get just black/white images.

Right now i'm working on finishing my bike for the "climate change tour" :)

It would be perfect if I could run 3 screens with 3 color bitmaps from one ESP32. Right now working with the TTGO T8 V1.3 and the LOLIN32 Pro V1 (both have SD Card reader onboard).

As an Attacement you can see the e-paper displays installed in the back, right now 6 on each side.

Cheers,
Christian

ZinggJM

Hi Christian,

Great, looks good! Hope you pass through Luzerne on your tour.

I have just updated GxEPD2_32 with enhanced version of GxEPD2_32_SD_Example (renamed).
It handles colored bitmaps, e.g. 24bit or 4bit (color depth).

I just discovered that the large WiFi download issue of ESP8266 seems ok on ESP32.
So I need to check with the actual ESP8266 package from Espressif, or check if it is a known issue.

Jean-Marc
No personal message please; any question may be useful for other users. Use code tags for code. Make links clickable with URL tags. Provide links to the product in question.

kid1000000000

Hi ZinggJM, first a note that your library is awesome and thank you for supporting it for as long and as much as you have.

To get started with your library, I must initialize using this code:

Code: [Select]
#include <GxEPD.h>
#include <GxGDEH029A1/GxGDEH029A1.h>//cpp //specify the correct 2.9" screen                                                                                                                   
#include <GxIO/GxIO_SPI/GxIO_SPI.cpp>//cpp
#include <GxIO/GxIO.cpp>//cpp
#include <Fonts/FreeMonoBold9pt7b.h>
GxIO_SPI io = GxIO_SPI(SPI, /*CS=*/ SS, /*DC=*/ 8, /*RST=*/ 14);
GxEPD_Class display = GxEPD_Class(io, /*RST=*/ 14, /*BUSY=*/ 12);


I'm interested in passing `display` to other classes in other files, but because *cpp files get included, my compiler complains of duplication errors. If it were possible to follow the regular standard and only include header files, that would allow your package to intercalate with the language better. Do you know if it would be possible to do with your library?

Thanks again for what you have already given us.

ZinggJM

#643
Jun 14, 2018, 05:33 pm Last Edit: Jun 14, 2018, 05:55 pm by ZinggJM
Hi kid,

thanks for the feedback!

I invite you to try to change the structure of the GxEPD source tree to your needs.
I know this source structure does not fit well with the capabilities of the Arduino IDE; it didn't with 1.6.x and still doesn't with 1.8.x.

The .cpp source file needs be included where the instance of the display class is created, because it is not automatically included in the build from a second level subdirectory.

However there should be no problem to pass a reference or pointer to the display instance to classes or methods in other files; in these only the header file needs be included to make the type/class of the instance known.

You could also consider to use one of the libraries GxEPD2_32, GxEPD2_AVR or GxEPD2, which have a simpler source structure.

Btw: why do you use the old-fashioned style of instance creation with copy assign operator?

I know the compiler optimizes this sequence of two creations, one assignment and one destruction, but C++ fans don't like to see this.
No personal message please; any question may be useful for other users. Use code tags for code. Make links clickable with URL tags. Provide links to the product in question.

Davste

#644
Jun 17, 2018, 08:22 pm Last Edit: Jun 17, 2018, 08:27 pm by Davste
Hi, first of all, thank you for the amazing library!

I'm trying to get updateWindow to work, but so far have been unsuccesful.
I've been able to get display.update() and pagedUpdate() to work however.
If it helps, I'm using the 1.54(B) Waveshare screen.

Example:
Code: [Select]
  display.setCursor(0, 0);
  display.setTextColor(GxEPD_BLACK);
  display.print("TEST");
  display.updateWindow(0, 0, 50, 50, true);


I've also tried:
Code: [Select]
display.updateWindow(0, 0, GxEPD_WIDTH, GxEPD_HEIGHT, false);

My objective actually - but I do not know if this is possible from the reading so far - is to just update a single pixel at a time to make some sort of animation without refreshing the whole display.

Go Up