While migrating my codes from arduino.ino to idf project. I have some difficulties to initiate RGBmatrixPanel.
I have installed the library thru arduino as idf components and is able to build and flash.
The issue that i have is,
1. i did not know how to instantiate the library using c++ .h and .cpp files.
2. i not able to light up the led on standard idf main_app() file.
For issue 1:
In eclipse, my codes are separated into different files, where calling function require static declaration as such. Similar like using arduino ide. but if using arduino ide, i did not have to include the .h and my matrix variable that was declared are become public variable and can be refers from other files automatically.
i have tried two approaches which both fail to light my led panel
1. as a pubic variable, use extern in h and init in .cpp files as below:
.h:
Code: Select all
extern RGBmatrixPanel matrix;
Code: Select all
uint8_t rgbpins[6] = { 25, 26, 27, 14, 12, 13 };
RGBmatrixPanel matrix(23, 19, 5, 17, 16, 4, 15, true, 64, rgbpins);
.h:
Code: Select all
public:
static Matrix* Instance();
RGBmatrixPanel matrix() {
uint8_t rgbpins[6] = { 25, 26, 27, 14, 12, 13 };
RGBmatrixPanel matrix(23, 19, 5, 17, 16, 4, 15, true, 64, rgbpins);
return matrix;
}
private:
static Matrix* m_pInstance;
Code: Select all
Matrix* Matrix::m_pInstance = NULL;
Matrix* Matrix::Instance()
{
if (!m_pInstance){
m_pInstance = new Matrix();
}
return m_pInstance;
}
Matrix::Matrix(){}
I might think this is probably because of i did not properly include the arduino components inside my idf project.
The way i include in CMake is as below:
idf_component_register(
SRCS "src/variable.cpp"
INCLUDE_DIRS "./include"
REQUIRES arduino
PRIV_REQUIRES main nvs_flash
)
Please help me. Thank you.