Go Down

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

ZinggJM

GxEPD Version 3.0.9 is available, installable or updated with Library Manager.

- fixed BMP handling, e.g. for BMPs created by ImageMagick
- see also Arduino Forum Topic https://forum.arduino.cc/index.php?topic=642343.0
- added support for GDEW075T7 7.5" b/w 800x480
- GDEW075T7 has differential update (1.6s) using a charge balancing waveform
- added "fast partial update" (differential update) for GDEW0371W7 3.7" b/w 240x416
- improved differential update waveform for GDEW026T0 2.6" b/w 152x256
- fixed init code & improved differential update for GDEW042T2 4.2" b/w 300x400
- note that all differential refresh waveforms are a compromise (ghosting, big font use)
- parameters for differential waveform for these display can easily be changed for experimenting
- GDEW042T2 would have greyed background without sustain phase
- GDEW042T2 needs multiple full refreshes after extended use of partial updates

Please note that I recommend to use GxEPD2 for Newbies or new projects.

Both GxEPD and GxEPD2 are known by Library Manager and can be installed directly.

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.

OleksiyM

#1576
Nov 05, 2019, 10:06 pm Last Edit: Nov 09, 2019, 05:39 pm by OleksiyM
Dear ZinggJM,

Could you, please, advise if there is a way to make the Cyrillic text a bit bigger. The following code works fine except that the text in Cyrillic font is small.

I could not find a bigger Cyrillic font in the U8g2 fonts. And I could not figure out how to add a custom font. There is no such issue with the French and German fonts as you can see on the photo.

I like this Cyrillic font, it works both for Russian and Ukrainian languages. If only there was a way to scale it a bit bigger.

[SOLVED] See: https://forum.arduino.cc/index.php?topic=644866.0

Code: [Select]
// mapping suggestion for AVR, UNO, NANO etc.
// BUSY -> 7, RST -> 9, DC -> 8, CS-> 10, CLK -> 13, DIN -> 11

// base class GxEPD2_GFX can be used to pass references or pointers to the display instance as parameter, uses ~1.2k more code
// enable or disable GxEPD2_GFX base class
#define ENABLE_GxEPD2_GFX 0

#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#include <U8g2_for_Adafruit_GFX.h>


#define MAX_DISPAY_BUFFER_SIZE 800 //
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPAY_BUFFER_SIZE / (EPD::WIDTH / 8))
// select one and adapt to your mapping
GxEPD2_BW<GxEPD2_154, MAX_HEIGHT(GxEPD2_154)> display(GxEPD2_154(/*CS=10*/ SS, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7));

#include "GxEPD2_boards_added.h"

U8G2_FOR_ADAFRUIT_GFX u8g2Fonts;

void setup()
{
  Serial.begin(115200);
  Serial.println();
  Serial.println("setup");
  display.init();
  u8g2Fonts.begin(display); // connect u8g2 procedures to Adafruit GFX
  helloWorld();
  delay(1000);

}

void loop()
{
}

void helloWorld()
{
  //Serial.println("helloWorld");
  uint16_t bg = GxEPD_WHITE;
  uint16_t fg = GxEPD_BLACK;
  u8g2Fonts.setFontMode(1);                 // use u8g2 transparent mode (this is default)
  u8g2Fonts.setFontDirection(0);            // left to right (this is default)
  u8g2Fonts.setForegroundColor(fg);         // apply Adafruit GFX color
  u8g2Fonts.setBackgroundColor(bg);         // apply Adafruit GFX color


  display.firstPage();
  do
  {
    display.fillScreen(bg);
    u8g2Fonts.setFont(u8g2_font_10x20_t_cyrillic);  // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall
    u8g2Fonts.setCursor(20, 30); // start writing at this position
    u8g2Fonts.print("Привет мир!");

    u8g2Fonts.setCursor(20, 60); // start writing at this positionu8g2Fonts.setCursor(20, 30); // start writing at this position
    u8g2Fonts.print("Прівєт мир!");

    u8g2Fonts.setFont(u8g2_font_timB18_tf);  // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall
    u8g2Fonts.setCursor(20, 100); // start writing at this position
    u8g2Fonts.print("S'il vous plaît.");

    u8g2Fonts.setCursor(20, 140); // start writing at this position

    u8g2Fonts.print("Grüßen.");

  }
  while (display.nextPage());

}

ZinggJM

#1577
Nov 06, 2019, 06:57 am Last Edit: Nov 06, 2019, 08:35 am by ZinggJM
@OleksiyM

Quote
Could you, please, advise if there is a way to make the Cyrillic text a bit bigger.
U8g2_for_Adafruit_GFX doesn't seem to have a setFontSize() method, but even this would not help, as you are looking for "a bit", not a multiple.

I tried the obvious, searching for "Cyrillic" in the forum, but didn't find something obvious.

I suggest you create a new topic, e.g. "Cyrillic fonts for Adafruit_GFX or U8g2_for_Adafruit_GFX", as this is of general interest. Don't just copy the text of your post (cross-posting is disliked), but add a link to your post. I am sure the experts will have an answer, or hints where to look.

Jean-Marc

Added:

Found available Fonts to use with Adafruit_GFX

see also: Adafruit_GFX fork extended for UTF-8 by Bodmer.
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.

mattard

@ZinggJM

Great work with the library! I am working on a ESP32 based project, using a Waveshare 2.9 B/W EPD and your GxEPD2 library.

I have the code setup currently so the ESP32 hosts a web form where the user enters a few text fields and hits submit and the data is first stored to nvram, then written to the EPD, and then everything goes to deep sleep. It works OK, except when words don't fit perfectly.  Then the user has wake the device up, re-enter setup mode to adjust spacing and try again.

What I'd like to do is provide some kind of live or easy to refresh preview, either on the website, EPD, or both.  For the live web preview, I was wondering if it would be possible to export the display buffer to a bitmap that would then be loaded by the browser showing the user what their changes would look like when written to the EPD.

For the on-device preview, I was thinking of just using a partial refresh every time the user switches text fields on the browser.  I can conceive how to code this part but i'm still open to suggestions.

Thanks,

Matt

ZinggJM

#1579
Nov 07, 2019, 06:03 am Last Edit: Nov 07, 2019, 06:24 am by ZinggJM
@mattard

Quote
I was wondering if it would be possible to export the display buffer to a bitmap that would then be loaded by the browser showing the user what their changes would look like when written to the EPD.
Yes, this is possible and quite easy, as your processor has enough RAM for full-buffered graphics, and you have a b/w e-paper display.

The quick and dirty approach is to add an accessor method to the class GxEPD2_BW that returns the _buffer pointer. The buffer content is still valid after update to the display.

The clean approach is to use a Adafruit_GFX GFXcanvas1 for buffered graphics instead. The content of the canvas can be presented on the display through the drawBitmap() method, using the getBuffer() accessor.

You would then need to send the buffer content in BMP format to the client. This is quite easy if you use a depth of 1. I attach an example that writes BMP depth 1 format to SD.

Note: GxEPD2_SD_WriteBitmap.ino is a quick and dirty example, it was not really meant to get published.

Quote
I was thinking of just using a partial refresh every time ..
You could use partial refresh to full screen for this.

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.

mattard

Thanks for the reply, glad to hear it shouldn't be too hard. I might have to come back for more specific help but I want to try to code a example first along the lines of this first
Code: [Select]

display.print("Hello World");
writeBitmap(getbuffer()); //no idea but hoping to figure out
//browser refreshes page to get bmp
display.display(true);



Matt

OleksiyM

#1581
Nov 08, 2019, 01:59 pm Last Edit: Nov 08, 2019, 04:06 pm by OleksiyM
Is it possible to connect the 1.54inch e-ink display to the Arduino MKR 1310 WAN board?

I tried to connect it as MKR 1000 in the file GxEPD2_boards_added.h but it did not work. The display refreshes and then there is just one dot on it almost in the middle.

The Arduino MKR 1310 WAN is close to MKR 1300 WAN as far as I know.
[SOLVED. It works, see my message below.]

ZinggJM

#1582
Nov 08, 2019, 02:18 pm Last Edit: Nov 08, 2019, 03:40 pm by ZinggJM
@OleksiyM,

If you expect a fast and relevant answer, you should add clickable links to the processor board, e-paper used and connection board used.
I am sure Arduino has a picture with the connection pins and their use.

You get faster answer if I don't need go searching by myself.

If you don't get the expected result on the e-paper, you should observe diagnostic output in the Serial Monitor.
Post this output using code tags, the </>-command symbol.

Quote
The pinout in PNG format will be availabe next week!
as of 08.11.2019.

https://store.arduino.cc/mkr-wan-1310
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.

OleksiyM

Jean-Marc,
I connected the Arduino MKR 1310 WAN board again, and I tried the example GxEPD2_U8G2_Fonts_Example, and it works OK. I selected mapping suggestion for Arduino MKR1000 in the file GxEPD2_added_boards.h.

I wanted to copy the serial output for debugging, but it turned out there is nothing to debug. It works.

The only thing I changed, I re-soldered a loose wire to the two 1.5V batteries container. Probably, there was not enough current, or I just was not attentive enough. Sorry for trouble.

1.54inch Waveshare black&white e-ink display works all right with the Arduino MKR 1310 WAN board and the GxEPD2 library.

ZinggJM

@OleksiyM, thank you for the feedback! :)
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.

axelleap

Hello,

I am testing a Waveshare ePaper 1.54'' module, black and white model, on a Wemo D1 mini.
The code compiles and runs (the debug messages print on the serial console), but nothing prints on the screen  :smiley-confuse:
Note that the ePaper screen works, because I tested it previously on a RPi Zero W, with success.
But it does not work on the Wemo.

Could you please advise?

I use the GxEPD library with the following settings:

Code: [Select]

#include <GxGDEP015OC1/GxGDEP015OC1.h>  
...
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
GxEPD_Class display(io, /*RST=D4*/ 2, /*BUSY=D2*/ 4); // default selection of D4(=2), D2(=4)


I have connected the screen as follows:

  • 3.3 V to 3.3V, GND to GND
  • Screen's DIN to Wemo D7
  • Screen's CLK to Wemo D5
  • Screen's CS to Wemo D8
  • Screen's DC to Wemo D3
  • Screen's RST to Wemo D4
  • Screen's BUSY to Wemo D2


My code is the following:

Code: [Select]

#include <GxEPD.h>

// select the display class to use, only one
#include <GxGDEP015OC1/GxGDEP015OC1.h>    // 1.54" b/w
#include GxEPD_BitmapExamples

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

#include <GxIO/GxIO_SPI/GxIO_SPI.h>
#include <GxIO/GxIO.h>


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
GxEPD_Class display(io, /*RST=D4*/ 2, /*BUSY=D2*/ 4); // default selection of D4(=2), D2(=4)

void setup()
{
  // put your setup code here, to run once:

  Serial.begin(115200);
  Serial.println();
  Serial.println("setup");
  display.init();
  display.setRotation(3);
  Serial.println("setup done");
 }

void loop()
{
  Serial.println("loop()");
  showFont("FreeMonoBold24pt7b", &FreeMonoBold24pt7b);

  Serial.println("drawLine");
  display.drawLine(0,60,264,60,GxEPD_BLACK);
  display.drawLine(0,90,264,90,GxEPD_BLACK);
  
  delay(10000);
}

void showFont(const char name[], const GFXfont* f)
{
  Serial.println("showFont()");
  display.fillScreen(GxEPD_WHITE);
  display.setTextColor(GxEPD_BLACK);
  display.setFont(f);
  display.setCursor(0, 0);
  display.println();
  display.println(name);
  display.println("Hello World!");
  Serial.println("< out of showFont()");
}


Thanks!

Axelle

ZinggJM

Hi Axelle

Code: [Select]
  display.update();
is missing.

With GxEPD and full buffered graphics you need to call update() to display the buffer content on the screen.

Did you try GxEPD_Example.ino? This should be the first step.

I recommend to use GxEPD2 for Newbies or new projects.

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.

flyingbaloon

Hi ,

I have a query , The Wave paper 6 inch epaper
https://www.waveshare.com/product/modules/oleds-lcds/e-paper/6inch-e-paper-hat.htm

has <1s refresh rate and it connects to the raspberry pi via spi . I have seen the demo code in the examples show how to display an image on the screen and was wondering

Is it possible to use it as a raspberry pi monitor for simple tasks like using a web browser etc ?

axelleap

Hi Jean-Marc

Code: [Select]
 display.update();
is missing.
Thanks I had forgotten that indeed :( How silly. Unfortunately it still does not work.
I have taken GxEPD_Example.ino as you have suggested, to be sure.

With GxEPD and full buffered graphics you need to call update() to display the buffer content on the screen.

Did you try GxEPD_Example.ino? This should be the first step.
But nothing is shown on the screen. The serial console shows:

Code: [Select]

_PowerOff : 1
_PowerOn : 9
_Update_Full : 1
_PowerOff : 1
_PowerOn : 1
_Update_Full : 2
_PowerOff : 1
_PowerOn : 1
_Update_Full : 1
_PowerOff : 1
_PowerOn : 1


Can you suggest something more?

Thanks!
Axelle

ZinggJM

Hi ,

I have a query , The Wave paper 6 inch epaper
https://www.waveshare.com/product/modules/oleds-lcds/e-paper/6inch-e-paper-hat.htm

has <1s refresh rate and it connects to the raspberry pi via spi . I have seen the demo code in the examples show how to display an image on the screen and was wondering

Is it possible to use it as a raspberry pi monitor for simple tasks like using a web browser etc ?
It would be possible, I think, but I don't know how. And I wouldn't recommend.

You would need to specify what you mean by "as a raspberry pi monitor".
If you mean "for output of a program running on RasPi using EPD driver SW", ok.
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.

Go Up