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:
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
#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
#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
#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
#ifndef MAP_BIT
#define MAP_BIT
void drawBitmaps400x300();
#endif
Thank you in advance 
bitmap.cpp (790 Bytes)
bitmap.h (68 Bytes)
display.h (240 Bytes)
MKRFULL.ino (700 Bytes)