Waveshare e-ink with Adafruit GFX lib - drawLine()

Hi, can anyone help me with drawing a line with the GFX library on an e-ink display? I have the 2.9 inch version, everything works fine, but for drawing lines Adafruit recommends
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color); How do I use that? I can't call a method with the word "void" there, including the GFX library didn't help. Thanks!

Peet79:
Hi, can anyone help me with drawing a line with the GFX library on an e-ink display? I have the 2.9 inch version, everything works fine, but for drawing lines Adafruit recommends

void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);

How do I use that? I can't call a method with the word "void" there, including the GFX library didn't help. Thanks!

Did you try to use Adafruit_GFX without a display library? It needs to be used with a display library that inherits from it. Adafruit has a library for their own e-paper display module.

For the Waveshare e-paper display you could use GxEPD2, which uses Adafruit_GFX, and is available with Library Manager.

I'm using the GxEPD2 AVR library, I didn't have the #include <GxEPD2.h> in my code before, I included it but it still doesn't compile. How do you call the function? I have this currently:

#include <GxEPD2.h>
#include <GxEPD2_AVR_BW.h>
#include <GxEPD2_AVR_3C.h>

void setup()
{
  Serial.begin(9600);
  display.init();

  display.setFullWindow();
  display.setRotation(3);
  display.firstPage();

  do
  {

    uint16_t x0 = 50;
    uint16_t y0 = 50;
    uint16_t x1 = 67;
    uint16_t y1 = 83;
    uint16_t color = 1;
    
    void drawLine(x0, y0, x1, y1, color);
    }

  while (display.nextPage());

}

void loop() 
{
}

as the bare minimum. Also, does "color" take an integer as an input or the GxEPD_BLACK that you use for fonts?

EDIT: Okay, I found out that you use it with the display object, like the rest of the commands, and color takes 0x0000 for black. I don't have the arduino with me right now, but I hope this will work.

You need to create a display instance. Look at the example. Then you can use display.drawLine(…).

But sorry, I am not patient enough to teach you C++.

Note that GxEPD2 and GxEPD2_AVR are different libraries.

Sorry, that was just an error in copying, I do have the display instance created: GxEPD2_AVR_BW display(GxEPD2::GDEH029A1, /*CS=*/ 10, /*DC=*/ 8, /*RST=*/ 9, /*BUSY=*/ 7);