Go Down

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

wujek

#1845
May 27, 2020, 01:36 pm Last Edit: May 27, 2020, 06:39 pm by wujek
Hello,
I intend to use the Waveshare 1.54 V2 display to display engine speed. I need  refreshing the screen about every 0.5 second. Using the example that is included in the GxEPD library, I have prepared such a program, but I do not know why the screen refreshes every 3-4 seconds.
Is it possible to obtain faster refreshment time using this library?

By the way, can anyone have Adafruit_GFX fonts larger than 24?

I have alsow question of how to solve the problem of displaying text in 3 rows in each row of fonts in a different size, e.g. 24, 36, 16. Is it possible to align the text (left, right, center) in row?

There is any documentation for this library at all how it should be used.

Zbig
Code: [Select]

// mapping example for AVR, UNO, NANO etc.
// BUSY -> 7, RST -> 9, DC -> 8, C S-> 10, CLK -> 13, DIN -> 11

// include library, include base class, make path known
#include <GxEPD.h>
#include <GxGDEH0154D67/GxGDEH0154D67.h>
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>

// FreeFonts from Adafruit_GFX
#include <Fonts/FreeMonoBold24pt7b.h>

GxIO_Class io(SPI, /*CS=*/ SS, /*DC=*/ 8, /*RST=*/ 9); // arbitrary selection of 8, 9 selected for default of GxEPD_Class
GxEPD_Class display(io /*RST=9*/ /*BUSY=7*/); // default selection of (9), 7

uint32_t  days;
long x=0;

void setup(void)
{
  display.init();
  display.setTextColor(GxEPD_BLACK); 
  display.setFont(&FreeMonoBold24pt7b); 
  display.setRotation(1); 
}

void loop()
{
  days = x++;
  showPartialUpdate_AVR();
}

void drawCallback()
{
  uint16_t box_x = 10;
  uint16_t box_y = 10;
  uint16_t box_w = 170;
  uint16_t box_h = 170;
  uint16_t cursor_y = box_y + 30;
  display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  display.setCursor(box_x, cursor_y);
  display.print(days);
}

void showPartialUpdate_AVR()
{
  uint16_t box_x = 10;
  uint16_t box_y = 10;
  uint16_t box_w = 170;
  uint16_t box_h = 170;
  uint16_t cursor_y = box_y + 30;
  display.drawPagedToWindow(drawCallback, box_x, box_y, box_w, box_h);
}

ZinggJM

#1846
May 27, 2020, 05:51 pm Last Edit: May 27, 2020, 06:31 pm by ZinggJM
@wujek,

I am having holidays actually. But I may test this on UNO tomorrow.

In the meantime you could edit your post and put your code into code tags, the </> command.

Also read General Guidance and How to use the Forum.

Jean-Marc

from GxEPD2_154_D67.h

Code: [Select]
    static const uint16_t power_on_time = 100; // ms, e.g. 95583us
    static const uint16_t power_off_time = 150; // ms, e.g. 140621us
    static const uint16_t full_refresh_time = 2600; // ms, e.g. 2509602us
    static const uint16_t partial_refresh_time = 500; // ms, e.g. 457282us
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.

ZinggJM

#1847
May 28, 2020, 03:34 pm Last Edit: May 28, 2020, 04:34 pm by ZinggJM
@wujek,

thank you for asking this question! It is more interesting than I thought.

I "enhanced" your code to analyze:

Code: [Select]

// mapping example for AVR, UNO, NANO etc.
// BUSY -> 7, RST -> 9, DC -> 8, C S-> 10, CLK -> 13, DIN -> 11

// include library, include base class, make path known
#include <GxEPD.h>
#include <GxGDEH0154D67/GxGDEH0154D67.h>
#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>

// FreeFonts from Adafruit_GFX
#include <Fonts/FreeMonoBold24pt7b.h>

GxIO_Class io(SPI, /*CS=*/ SS, /*DC=*/ 8, /*RST=*/ 9); // arbitrary selection of 8, 9 selected for default of GxEPD_Class
GxEPD_Class display(io /*RST=9*/ /*BUSY=7*/); // default selection of (9), 7

uint32_t  days;
long x=0;

void setup(void)
{
  display.init(115200);
  display.setTextColor(GxEPD_BLACK);  
  display.setFont(&FreeMonoBold24pt7b);  
  display.setRotation(1);  
}

void loop()
{
  days = x++;
  showPartialUpdate_AVR();
}

void drawCallback()
{
  uint32_t start = millis();
  uint16_t box_x = 10;
  uint16_t box_y = 10;
  uint16_t box_w = 170;
  uint16_t box_h = 170;
  uint16_t cursor_y = box_y + 30;
  display.fillRect(box_x, box_y, box_w, box_h, GxEPD_WHITE);
  uint32_t fill = millis();
  display.setCursor(box_x, cursor_y);
  display.print(days);
  uint32_t print = millis();
  uint32_t elapsed = millis() - start;
  Serial.print("drawCallback() took "); Serial.print(elapsed); Serial.print(" fill "); Serial.print(fill - start); Serial.print(" print "); Serial.println(print - fill);
}

void showPartialUpdate_AVR()
{
  uint16_t box_x = 10;
  uint16_t box_y = 10;
  uint16_t box_w = 170;
  uint16_t box_h = 170;
  uint16_t cursor_y = box_y + 30;
  uint32_t start = millis();
  display.drawPagedToWindow(drawCallback, box_x, box_y, box_w, box_h);
  uint32_t elapsed = millis() - start;
  Serial.print("drawPagedToWindow() took "); Serial.println(elapsed);
}


This is the diagnostic output that I got, running the code on Arduino UNO:

Code: [Select]
_InitDisplay : 2036
_PowerOn : 91416
_Update_Part : 599252
_InitDisplay : 2044
_PowerOn : 91428
drawCallback() took 401 fill 391 print 10
drawCallback() took 431 fill 426 print 5
drawCallback() took 430 fill 425 print 5
drawCallback() took 430 fill 426 print 4
drawCallback() took 373 fill 369 print 4
_Update_Part : 599188
drawCallback() took 402 fill 392 print 10
drawCallback() took 430 fill 425 print 5
drawCallback() took 430 fill 426 print 4
drawCallback() took 431 fill 426 print 5
drawCallback() took 374 fill 368 print 6
_PowerOff : 232584
drawPagedToWindow() took 9863
_InitDisplay : 2040
_PowerOn : 91416
drawCallback() took 398 fill 390 print 8
drawCallback() took 430 fill 426 print 4
drawCallback() took 429 fill 425 print 4
drawCallback() took 429 fill 426 print 3
drawCallback() took 371 fill 368 print 3
_Update_Part : 599220
drawCallback() took 398 fill 391 print 7
drawCallback() took 429 fill 424 print 5
drawCallback() took 429 fill 426 print 3
drawCallback() took 429 fill 426 print 3
drawCallback() took 372 fill 369 print 3
_PowerOff : 232592
drawPagedToWindow() took 5812
_InitDisplay : 2036
_PowerOn : 91416
drawCallback() took 401 fill 391 print 10
drawCallback() took 432 fill 426 print 6
drawCallback() took 431 fill 426 print 5
drawCallback() took 430 fill 425 print 5
drawCallback() took 373 fill 368 print 5
_Update_Part : 599248
drawCallback() took 401 fill 390 print 11
drawCallback() took 430 fill 426 print 4
drawCallback() took 431 fill 426 print 5
drawCallback() took 430 fill 426 print 4
drawCallback() took 372 fill 368 print 4
_PowerOff : 232572
drawPagedToWindow() took 5824


Note that the times reported by the library are microseconds, by the test milliseconds.

You can see that most of the time is spent in fillRect. This is because the rect is filled pixel by pixel.
The drawPixel() method in GxEPD (and GxEPD2) is expensive, because of the limits checks and page range checks, although drawing is to buffer memory.

You can also see that drawCallback is called 8 times, 4 times before update because of 4 pages used, and 4 times after update to make current and previous controller buffer equal, for next differential update.

Conclusion: Arduino UNO is not usable for fast updates on e-paper displays.

You can improve dramatically, if you use fillScreen() instead of fillRect().

But your goal to reach 2 updates per second is still out of reach, even with ESP8266 and GxEPD2.

And I don't recommend such frequent updates because of life expectancy specs, number of refreshes.

Jean-Marc

Quote
There is any documentation for this library at all how it should be used.
Ok, I should add this to the README.MD of GxEPD also:

Code: [Select]
### Note on documentation
- GxEPD2 uses Adafruit_GFX for Graphics and Text support, which is well documented there
- GxEPD2 uses meaningful method names, and has some comments in the header files
- consult the header files GxEPD2_BW.h, GxEPD2_3C.h and GxEPD2_GFX.h
- for the concept of paged drawing and picture loop see:
- https://github.com/olikraus/u8glib/wiki/tpictureloop


But I recommend GxEPD2 for Newbies. (where I have already added 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.

wujek

Hello,

I understand that all display refreshing support is done by Arduino. I wanted to ask if there are e-ink display which refresh id made by the display control module?

Wujek

fremitus

Hi all,

I'm complete lost. I'm not able to get the Waveshare 1.54 V2 display running on my different nodemcu clones (AliExpress clones). My first Waveshare 1.54 V1 display did work very well with my installed fonts/grafics but the display crashed after some month of disuse... (another story).

In use:
a. Nodemcu Clones (esp8266)
b. Arduino IDE with GxEPD2
c. Waveshare 1.54 V2 display
d. GxEPD2_GFX_Example


As I now learned from this forum the new version didn't work like the version before. I tried several solutions, which I found on the forum, to get the display online:

1. Move CS from D8 to D2 or other pins (what means I have to move my BME260 back to another pin)
2. Disconnect busy (use -1)
3. connect 4k6 resistor between D8 and ground

Nothing works at the end. My issues:

I. with RST on GPIO2 and connected display upload didn't work (issue was notice in #822) too but I didn't find a final solution....)
Code: [Select]

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

II. Uploads with disconnected displays works.
III. After reconnect the display again -> Nodemcu/displays runs the script for one round...hurra but ->
IV. After reconnect the Nodemcu again from power the blue led comes on (ESP Wifi Modul), all is frozen
V. after disconnect RST from Nodemcu uploads are possible but display didn't work
VI. Connect RST to e. g. gpio16 (D0) allows uploads too but display didn't work

May be the new displays have some trouble with the Reset functionality, I'm not able to fix it.

It would be very helpful if someone could give me a running config with Nodemcu and 1.54 V2.1 waveshare epaper display.

regards

Peer











ZinggJM

@fremitus,

https://www.waveshare.com/wiki/1.54inch_e-Paper_Module

Quote
The 1.54inch e-Paper is updated to 1.54inch e-Paper V2 version. Codes of the two version are not compatible with each other. Except for the controller and codes, the new V2 version is exactly the same as the old one. If you are users of the old version, you need to update your codes as well for your new order.
You didn't tell the constructor you used, so I don't know if this is the cause of your problem.

Please read General Guidance and How to use the Forum.

And for questions regarding e-paper displays: please post (clickable) links to all parts, processor board, e-paper board or panel, connection module if bare panel used, library used, constructor used, board selected to compile for in Arduino IDE.

As you seem to have read some posts in this topic, I would have expected you would provide all this information. But congratulations: you provided more information than most Newbies, thank you!

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.

fremitus

#1851
May 30, 2020, 11:50 pm Last Edit: May 31, 2020, 12:02 am by fremitus
Hi Jean-Marc

I try to do my best ..... and I'm back again. May be it was too late last night. At the end I followed your advice (given in one of your posts here ;-) to check gpio by gpio what could cause the trouble. In my post before I wrote that I identified RST as troublemaker. I tried another gpio but without success. Now I checked my script again and hurra I put the wrong gpio number for RST.

With

BUSY -> D2 = 4
RST -> D0 = 16
DC -> D3 = 0
CS -> D1 = 5
CLK -> D5 = 14
DIN -> D7 = 13

Nodemcu Clone and Waveshare 1.54 V2.1 works very well. And yes, my original script (BME280 with own graphics/types built for my motorbike)  works too...

a. Nodemcu: Aliexpress Nodemcu. Classic Nodemcu Clone. 
b. Constructor: your one scripts...
Code: [Select]
#if defined (ESP8266)
GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display(GxEPD2_154_D67(/*CS=D1*/ 5, /*DC=D3*/ 0, /*RST=D0*/ 16, /*BUSY=D2*/ 4));

No more change.
c. GxEPD2 Version 1.2.8, Arduino 1.8.12, Mac OS Catalina

What is still open: BME280 with D6/D8 as SDA/SCL. I changed it inside "pins_arduino.h" but I have current no access to my sensor to check if all together runs really well.

Peer





ZinggJM

Hi Peer,

On ESP8266 you can't change HW I2C pins.

I had this limited pins issue with ESP8266 with e-paper display with I2C SHT31 sensor.
I solved it using MISO (D6) for BUSY, see example IoT_SHT31LP_Example_1.54inchEPD.ino

Code: [Select]
// SPECIAL mapping for IoT from Waveshare 1.54inch e-Paper to Wemos D1 mini
// BUSY -> D6, RST -> D4, DC -> D3, CS -> D8, CLK -> D5, DIN -> D7, GND -> GND, 3.3V -> 3.3V


Try to use a 3.3k pull-down resistor on SS (D8). 4.7k doesn't always work.

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.

fremitus

#1853
Jun 02, 2020, 12:55 am Last Edit: Jun 02, 2020, 01:14 am by fremitus
Hi  Jean-Marc,

it is .... how to say, not really working, BME280 and Nodemcu with ePaper Display. As you could see in the attached picture just the temperature is visible. The sensor is working (serial monitor):
Code: [Select]

sensor = 4
25.87
30.66
1014.40


The ePaper display is lightly pulsing. I tried to use - as you recommended - a 3.3k pull-down resistor on SS (D8 - GND) but without any success. I checked the Volt value between D8 and GND with resistor and without - no different (3.2 V).  I played a little bit with the gpio ports, overall the same picture (see attached jpg). CS works on D8, D0 or other ports without any change, only temperature is visible. 

More Infos, what is in use:

a. Nodemcu: Lolin NodeMcu datasheet
b. output esptool:
Code: [Select]
esptool.py v2.6
Serial port /dev/cu.usbserial-1410
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Uploading stub...
Running stub...
Stub running...
Manufacturer: c8
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

c. Some more information about esp8266-pinout-reference-gpios
d. Code on Pastebin. More or less your own code, worked very well with the old (buggy) display...

Any Ideas?

Peer

ZinggJM

#1854
Jun 02, 2020, 05:42 pm Last Edit: Jun 02, 2020, 05:50 pm by ZinggJM
Hi Peer,

yes, I have an idea:

Code: [Select]
 display.firstPage();
  do
  {    
    display.fillScreen(bg);
    u8g2Fonts.setCursor(65, 180);
    u8g2Fonts.print(ha,1);
    Serial.println(ha);
  }
}


Does it compile?

This will loop forever, but never update the screen.

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.

fremitus

#1855
Jun 02, 2020, 06:11 pm Last Edit: Jun 02, 2020, 06:13 pm by fremitus
Hi Jean-Marc,

Sorry and yes, because I did a c&p error. My original script includes  "while (display.nextPage());"....

Pls notice the correct version on Pastebin

Peer

ZinggJM

@fremitus,

I should not have answered to code put on Pastebin or whatever place.

Please read General Guidance and How to use the Forum.

You first need to post clearly if your original issue is solved, and you want help on a new issue.
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.

fremitus

Hi Jean-Marc,

it was not solved. Although your test scripts didn't work perfect. So forget my code, I'm very sure the issue is not  related with it. It was just an example.

I tried your solution with
Code: [Select]
// SPECIAL mapping for IoT from Waveshare 1.54inch e-Paper to Wemos D1 mini
// BUSY -> D6, RST -> D4, DC -> D3, CS -> D8, CLK -> D5, DIN -> D7, GND -> GND, 3.3V -> 3.3V

Both Wemos mini and my nodemcu are using the same ESP8266 12-E Chip, however it didn't work for me....I will recheck it today again (I have two more nodemcu in my pool). It is very silly, I'm a little bit frustrated. Your solution needs the resistor, I got it right?

And I will check today how the display works together with my Arduino Nano. This was my first idea but - as you surely know - the nano is limited and my graphics are to big for the nano. But I could optimize this.

Peer


fremitus

Nodemcu china clone and Waveshare 1.54 V2.1 epaper b&w display

With

BUSY -> TX = 3
RST -> D0 = 16
DC -> D3 = 0
CS -> D8 = 15
CLK -> D5 = 14
DIN -> D7 = 13

And (BME280)
D1 -> SCL
D2 -> SDA

it is working now. RST/busy (epaper) didn't work on the recommended ports. I'm not the really display expert, at the end the different standard high/low conditions on the gpio's during the boot process on my china nodemcu's are not compatible with the epaper conditions. So it is more a try & error result and not a scientific story.

Peer


steevie85

Hi,

Is it possible to do a partial update with the waveshare e-paper 2,9" b/w/r display module?

Go Up