finding data at the right place [fixed]

Hello,

I’m writing a menu library. The main application testMenu.ino is somewere in a folder testMenu. The library is in the libraries’ folder, it’s included with <arduinoMenu.h> instead of “arduinoMenu.h”.

The problem is that arduinoMenu needs data specific to each application, I can’t store menuData.cpp in my library folder, because each application needs different data… So I have to put it in the application folder.

In arduinoMenu, I’ve tried to include data with <menuData.cpp> and “menuData.cpp”, none of them works. Have somebody much more experienced than me a way to solve this problem?

In arduinoMenu, I’ve tried to include data with <menuData.cpp> and “menuData.cpp”, none of them works

Do you really mean that you have tried to #include the .cpp file or was that a typo ?

That depends on how customized each of your applications’ menus needs to be. One way would be to have each class in an application’s menu inherit from the base class of your generic menu. The generic menu .cpp would be stored (with the generic .h) in the libraries folder while the customized .h and .cpp would be stored in the sketch directory.

If only the data for each application is different, write your menu class to accept the customizing data as part of the constructor or a begin() method.

UKHeliBob:
Do you really mean that you have tried to #include the .cpp file or was that a typo ?

Sorry, it’s of course dataMenu.h! As a non native speaker, I know now what is a typo, thanks for that.

gfvalvo:
If only the data for each application is different, write your menu class to accept the customizing data as part of the constructor or a begin() method.

Thanks, it’as a good idea, but I don’t think I can do it, there is too much data for that. Here is a sample of this data, generated from a python script which parses an xml file. There are not only tables, which can be passed without problem, but also declarations as extern.

menuData.h (14.4 KB)

Hello,

Finally, the python gererator adds a PROGMEM array of words which contains addresses of all needed tables. Its a little bit tricky (array of arrays of arrays with PROGMEM) but it works, for the user, it is that:

#include <arduinoMenu.h>
#include "menuData.h"
ARDUINO_MENU menu = ARDUINO_MENU();

void setup()
{    
    menu.begin(MENU_DATA_nbEntries, MENU_DATA_tables);
}

void loop()
{
    menu.sequencer();
}

The project is here arduinoMenu