Hello. I am trying to convert one of my Arduino projects to esp32 in PlatformIO. I am trying to run the SerialMonitor Sketch from LCDMenuLib2.
I already converted all the .ino files to .cpp and created a header file header.h containing most of the essential functions.
My problem at the moment is the positioning of the two functions, which are needed in most of the .cpp files of the library.
LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL);
LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows-_LCDML_DSIP_use_header, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control);
if i put them into my header.h like this
#ifndef HEADER_H
#define HEADER_H
#include <Arduino.h>
#include <stdint.h>
#include <LCDMenuLib2.h>
void lcdml_menu_display();
void lcdml_menu_clear();
void lcdml_menu_control();
extern uint8_t _LCDML_DISP_cols;
extern uint8_t _LCDML_DISP_rows;
extern uint8_t _LCDML_DSIP_use_header;
LCDMenuLib2_menu LCDML_0 (255, 0, 0, NULL, NULL);
LCDMenuLib2 LCDML(LCDML_0, _LCDML_DISP_rows-_LCDML_DSIP_use_header, _LCDML_DISP_cols, lcdml_menu_display, lcdml_menu_clear, lcdml_menu_control);
void mDyn_para(uint8_t line);
void mFunc_information(uint8_t param);
...
#endif
PlatformIO gives me several errors like:
multiple definition of `LCDML_0’; PlatformIO/Projects/LCDMenuLib2_esp32/lib/LCDML/header.h:18: first defined here
wich makes sense to me, because the functions seem to be already defined and is redefined every-time i #include my header.h in the other .cpp files
On the other hand, if i just leave them in the main.cpp and remove them from the header.h i get errors for every other .cpp file that wants to access LCDML
‘LCDML’ was not declared in this scope
Is there any way i can figure out the declaration of the two functions, so i can add them to my header or is there maybe a way to make my first definition in main.cpp global so the other .cpp files can access them?