Go Down

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

Shrzpk

I am using SparkFun babysitter with 5000mAh battery, Waveshare e-paper ESP8266 driver board and Waveshare 7.5" 3C e-Paper. Instead of using standard SDA and SCL pins, I am using 2 as SCL and 4 as SDA i.e. Wire.begin(4,2); which works fine.

But problem appears when I use `display.print(HelloWorld);` because of pin mapping in
```cpp
GxEPD2 DC=4

Code: [Select]

GxEPD2_3C<GxEPD2_750c, GxEPD2_750c::HEIGHT / 4> display(GxEPD2_750c(/*CS=15*/ SS, /*DC=4*/ 4, /*RST=5*/ 5, /*BUSY=16*/ 16));


Shall I change DC to some other pin, I have tried but it shows in serial

_PowerOn=9
_FullUpdate=10
_PowerOff=1


and doesn't print over to display. If I change `DC=4` then display works fine but I can't get communicate with SparkFun babysitter via `SDA (4)`.

Is there any way to move DC mapping to another pin for display?

ZinggJM

@Shrzpk,

Good you found the right place to ask this question; you have a strange "Particle".

Waveshare chose to connect the DC line to the e-paper display to pin D4 of the ESP8266.

There is no chance to modify this in SW; you would need to cut traces and re-wire this line.

Search for a SW I2C implementation, but you would still be short of pins on ESP8266.

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.

Shrzpk

Thanks ZinggJM for the prompt reply.

Now I do undertand this and wants to get suggestion for the alternative SCL pin from ESP8266.

Unfortunately, i have damaged the pin D1(GPIO5) by one mistake and can't use for SCL communication.

Shall I change SCL from pin D4(GPIO2) to pin D7(GPIO13) or any other pin you suggest, as this can be change in software?


ZinggJM

Thanks ZinggJM for the prompt reply.

Now I do undertand this and wants to get suggestion for the alternative SCL pin from ESP8266.

Unfortunately, i have damaged the pin D1(GPIO5) by one mistake and can't use for SCL communication.

Shall I change SCL from pin D4(GPIO2) to pin D7(GPIO13) or any other pin you suggest, as this can be change in software?

GPIO13 is not free! As I wrote, you are short of pins!

Code: [Select]
// mapping of Waveshare e-Paper ESP8266 Driver Board
// BUSY -> GPIO16, RST -> GPIO5, DC -> GPIO4, CS -> GPIO15, CLK -> GPIO14, DIN -> GPIO13, GND -> GND, 3.3V -> 3.3V
// NOTE for ESP8266: using SS (GPIO15) for CS may cause boot mode problems, use different pin in case


I can't help you with 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.

03sarath

#1564
Nov 02, 2019, 10:13 am Last Edit: Nov 02, 2019, 11:33 am by 03sarath
Hey guys,


@ZinggJM thanks for your wonderful work, I'm working on a small project using 4.2-inch EPD-BW, I'm splitting my project into different CPP files. But now I'm struggling with ERRORS, I know that I'm making some stupid mistake. Looking for your suggestions regarding my mistake.

I'm trying to find out how can I call display(EPD) in different .cpp files.

Her I have displayed my ERROR:




Code: [Select]
MKRFULL:9:61: error: redefinition of 'GxEPD2_BW<GxEPD2_420, 300> display'

GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2));

                                                           ^

In file included from F:\Psitron Technologies\CONF DOC\R&D LoRa\WordWarp\MKRFULL\MKRFULL.ino:5:0:

sketch\display.h:6:49: note: 'GxEPD2_BW<GxEPD2_420, 300> display' previously declared here

extern GxEPD2_BW<GxEPD2_420,GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2));

                                               ^~~~~~~

bitmap.cpp:8:61: error: redefinition of 'GxEPD2_BW<GxEPD2_420, 300> display'

GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2));

                                                           ^

In file included from sketch\bitmap.cpp:5:0:

sketch\display.h:6:49: note: 'GxEPD2_BW<GxEPD2_420, 300> display' previously declared here

extern GxEPD2_BW<GxEPD2_420,GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2));

                                               ^~~~~~~


Her is my MKRFULL.ino file

Code: [Select]
#include <Arduino.h>
#include "bitmap.h"
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include "display.h"

#include <Fonts/FreeSansBold9pt7b.h>

GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2));

void setup() {

Serial.begin(115200);  
display.init(115200);



display.firstPage();
do
{
//display.setRotation(1);  
display.fillScreen(GxEPD_WHITE);
display.setFont(&FreeSansBold9pt7b);
display.setTextColor(GxEPD_BLACK);
display.setCursor(150, 160);
display.println("Loading :)");
}
while (display.nextPage());{
}


drawBitmaps400x300();




}

void loop() {

}




Here is my display.h file


Code: [Select]
#ifndef DISPLAY_EPD
#define DISPLAY_EPD
#include <Arduino.h>
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
extern GxEPD2_BW<GxEPD2_420,GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2));
#endif



Here is my bitmap.cpp file

Code: [Select]
#include <Arduino.h>
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include "bitmaps/Bitmaps400x300.h" // 4.2"  b/w
#include "display.h"
#include "bitmap.h"

GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2));

void drawBitmaps400x300()
{

const unsigned char* bitmaps[] =
{
 gImage_ashok,gImage_select,gImage_eye1,gImage_eyehand,gImage_eyeear,gImage_grees
};

if (display.epd2.panel == GxEPD2::GDEW042T2)
{

    display.firstPage();
    do
    {
      
      display.setPartialWindow(0, 0, 400, 60);
      display.drawInvertedBitmap(0, 0, bitmaps[1], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
    }
    while (display.nextPage());
    delay(500);

}
}




Here is my bitmap.h file

Code: [Select]
#ifndef MAP_BIT
#define MAP_BIT
void drawBitmaps400x300();
#endif



Thank you in advance :)

ZinggJM

@03sarath,

Please read How to use this forum - please read.

Edit your post and put the error messages and the code presented into code tags, using the </> command symbol.

Explain what you try to achieve. Looking at the attached code should be the last resort for helpers.

As soon as you did that, I will consider looking at your problem.

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.

03sarath

Hey @ZinggJM,

Sorry for the mistake, I have made the changes as per your suggested.

Thank you.

ZinggJM

Hi 03sarath,

thank you for the changes. I will look at this problem. I may need to check with code.

But I think it is an issue with "declaration" and "definition".

The compiler tells: 'GxEPD2_BW<GxEPD2_420, 300> display' previously declared here.

I think the extern statement defines a display instance, instead of declaring one.

Maybe 'extern GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display;' would be correct.

But now dinner is ready, I will check later.

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.

03sarath

Hey @ZinggJM,


But how can we define 'extern GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display;' without defining connection pins 'GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2)'.I'm bit confused  :smiley-confuse: ,No problem now you please enjoy your dinner, we can figure out.

ZinggJM

#1569
Nov 02, 2019, 01:28 pm Last Edit: Nov 02, 2019, 01:31 pm by ZinggJM
Hey @ZinggJM,


But how can we define 'extern GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display;' without defining connection pins 'GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2)'.I'm bit confused  :smiley-confuse: ,No problem now you please enjoy your dinner, we can figure out.
Hey @03sarath, you could have tried this yourself in the meantime. Learning by doing!

You can declare it extern multiple times, but it needs to be defined in one place only.
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.

03sarath

Hey  @ZinggJM,


The good thing is I have tried  :) , But now got this following error, 



Code: [Select]
sketch\bitmap.cpp.o:(.bss.display+0x0): multiple definition of `display'

sketch\MKRFULL.ino.cpp.o:(.bss.display+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board ESP32 Dev Module.



Only changes made in display.h file

Code: [Select]

#ifndef DISPLAY_EPD
#define DISPLAY_EPD
#include <Arduino.h>
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
extern GxEPD2_BW<GxEPD2_420,GxEPD2_420::HEIGHT> display;
#endif



I guess 'extern' is not working for defining oin connections.

ZinggJM

Still learning by doing!

You just need to believe the error message from the compiler/linker:

sketch\bitmap.cpp.o

sketch\MKRFULL.ino.cpp.o

You still have 2 definitions in the corresponding source files.

I had noticed, but wanted you to learn by yourself.

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.

03sarath

#1572
Nov 02, 2019, 04:49 pm Last Edit: Nov 02, 2019, 04:55 pm by 03sarath
Hey @ZinggJM,


I'm feeling that you're a great mentor, Yes I have removed 'GxEPD2_BW<GxEPD2_420,GxEPD2_420::HEIGHT> display;' in all other .cpp files.

Now I got this error which I have expected.

Code: [Select]
sketch\MKRFULL.ino.cpp.o:(.literal._Z5setupv+0x4): undefined reference to `display'

sketch\MKRFULL.ino.cpp.o:(.literal._Z5setupv+0x18): undefined reference to `display'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board ESP32 Dev Module.



I hope it is asking for pin definitions 'GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2)'  for EPD now, But really, I don't have any idea, how to define that now. Can you please suggest some way.

ZinggJM

#1573
Nov 02, 2019, 05:16 pm Last Edit: Nov 02, 2019, 05:38 pm by ZinggJM
Ok, I may be a bad teacher, I know that. But to be a good teacher I would first need to know the capabilities of the learner.
I didn't expect you don't get it.

You need to have exactly one definition of display. First you had several, then you had two, now you have none.

You need to keep one definition of display, usually the one in the .ino file, MKRFULL.ino in your case.

I hope this has become clear now.

Jean-Marc

just in case...

Code: [Select]
#include <Arduino.h>
#include "bitmap.h"
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include "display.h"

#include <Fonts/FreeSansBold9pt7b.h>

GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2));

void setup() {

  Serial.begin(115200);
  display.init(115200);



  display.firstPage();
  do
  {
    //display.setRotation(1);
    display.fillScreen(GxEPD_WHITE);
    display.setFont(&FreeSansBold9pt7b);
    display.setTextColor(GxEPD_BLACK);
    display.setCursor(150, 160);
    display.println("Loading :)");
  }
  while (display.nextPage()); {
  }


  drawBitmaps400x300();




}

void loop() {

}


Code: [Select]
#ifndef DISPLAY_EPD
#define DISPLAY_EPD
#include <Arduino.h>
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
//extern GxEPD2_BW<GxEPD2_420,GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2));
extern GxEPD2_BW<GxEPD2_420,GxEPD2_420::HEIGHT> display;
#endif

Code: [Select]
#include <Arduino.h>
#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include "bitmaps/Bitmaps400x300.h" // 4.2"  b/w
#include "display.h"
#include "bitmap.h"

//GxEPD2_BW<GxEPD2_420, GxEPD2_420::HEIGHT> display(GxEPD2_420(/*CS=5*/ 5, /*DC=*/ 4, /*RST=*/ 3, /*BUSY=*/ 2));

void drawBitmaps400x300()
{

  const unsigned char* bitmaps[] =
  {
    //gImage_ashok,gImage_select,gImage_eye1,gImage_eyehand,gImage_eyeear,gImage_grees
  };

  if (display.epd2.panel == GxEPD2::GDEW042T2)
  {

    display.firstPage();
    do
    {

      display.setPartialWindow(0, 0, 400, 60);
      display.drawInvertedBitmap(0, 0, bitmaps[1], display.epd2.WIDTH, display.epd2.HEIGHT, GxEPD_BLACK);
    }
    while (display.nextPage());
    delay(500);

  }
}

Code: [Select]
#ifndef MAP_BIT
#define MAP_BIT
void drawBitmaps400x300();
#endif
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.

03sarath

Hey @ZinggJM,


Thanks a lot that is working perfectly good now, I hope I will become good learner, thanks for your lesson again.

Have a nice day,
Best regards,

Sarath

Go Up