-
-
Notifications
You must be signed in to change notification settings - Fork 26
Using CalEPD in a C project
via D1sconnected, he asked this in a CalEPD issue and found a nice way to do it. Since the Issue is closed, in order to make the solution available to everyone, I decided to add it here in the WiKi. Background info: You are working in a C project but you want to use a C++ component like CalEPD. What is the right step? Should I update all my code to C++?
If that's the not the right answer for you then keep on reading!
In D1sconnected own words here is his explanation on how to do it.
- I left my entire code-base in C language with no changes
- Create additional cpp wrapper component, where placed CalEPD functions and left all cpp-related includes in cpp file
- Include wrapper header in
main.c
, function declaration hasextern C
directive
This works just fine. ESP32 Cmake pretty "smart" and there is no need to add any additional build steps.
And I suppose that the main issue was that I forget to remove cpp includes from header, which I tried to include in main.c
.
main.c
#include <eink_interface.h>
eink_interface.h
#ifdef __cplusplus
extern "C"
#endif
void EinkInterface_Demo(void);
eink_interface.cpp
#include "eink_interface.h"
#include "goodisplay/gdey0154d67.h"
#include <Fonts/ubuntu/Ubuntu_M8pt8b.h>
EpdSpi io;
Gdey0154d67 display(io);
void EinkInterface_Demo(void)
{
display.init(false);
display.setCursor(10, 40);
display.setFont(&Ubuntu_M8pt8b);
display.println("CalEPD display test\n");
display.update();
}
CMakeLists.txt
set(component_srcs "eink_interface.cpp")
idf_component_register(SRCS "${component_srcs}"
REQUIRES freertos driver CalEPD
INCLUDE_DIRS ".")
And here is stackoverflow topic, which perfectly describes what's going on. https://stackoverflow.com/a/20325642
Revision v.1.3 | Firmware for ESP-IDF >= v. 4.3 Documentation written by Fasani Corp.
We are also launching a new company called Marespa.es that will help EU citizens find an affordable apartment in Spain. With the price of Rent going through the roof in 2024, this might be the moment to make an investment, if you plan to work from the spanish coast. With this project we are also supporting our open source projects.