-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Allow library to include a configuration file located in the project folder #1734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not so sure if the proposed fix is a good idea: adding more paths to the include path increases the chances of conflicts (and random unpredictable failures) when a filename is reused. I could imagine two alternatives:
I think I like the first option better, since it's less messy. However, the second option has less magic, which can also be a good idea... |
Your right, it could be an issue, but it can be easily managed! These issues could only be fixed by using strong naming rules for filenames, constants and defines. It is the responsibility of the library writer to follow such rules and therefore avoid as much as possible such issue. Some remarks regarding the 2 alternatives you mentioned
My proposal
For Library use
That’s all folks ! (1) Next possible improvement: As I previously said, it is only a proposal that can surely be improved. So feel free to leave comments and suggestions about it. |
I'm not following what the problem here is. If a library offers user-configurable values, it seems that it should properly document them in all cases anyway? Or are you saying that, with your initial suggestion, the library foo author could just provide a foo-config.h file for the user to copy into his sketch directory to modify? If so, as you suggested, you could also just copy-paste the relevant config bits into the main config.h file (if that approach is chosen).
Regarding your proposal, it looks good to me. However, I'd still suggest to put the config files into a "Configuration" subdirectory within the sketch directory, to keep things more clear. Furthermore, were you considering to put the "Configuration" subdirectory of a library in the include path as well? If we'd do that, if the user does not copy the configuration file, the default file from inside the library will be included instead. The alternative is to put the defaults in the main XYZ.h (with #ifndefs for example), but then there's a chance of the real defaults and the ones documented in the libXYZConf.h file becoming different, so I like the first option better. |
OK, I followed your suggestions and some of mine:
|
When an application uses a library supporting configuration: - the library configuration file is stored in the sketch folder as a project ressource. - a sketch tab is created in Arduino IDE to edit the library configuration file This commit manages following actions: - create configuration file tab when opening a sketch which uses a Library configuration file - copy the configuration file in the sketch folder and create a configuration file tab when importing a library which uses a library configuration file - add the library configuration file (from sketch) as include file when compiling the library only Added as an example, Morse library supporting configuration file
Writing a generic library that can be fine tuned for several projects seems difficult (impossible) without adding extra code and having a bad impact on th project memory footprint.
The idea is to have a library configuration file located in the project folder to allow this fine tuning.
The text was updated successfully, but these errors were encountered: