Hi all, for a while I've been working on BMC, it's a MIDI Controller library with it's own Editor App, if you're interested you can check it out here https://github.com/neroroxxx/BMC and install it via the Arduino library manager.
BMC handles everything from button presses to midi communication and so on, there is a main BMC.h file which includes a bunch of dependencies to read buttons, encoders, send/receive/merge/filter midi etc. All and all it works great.
Now BMC is scalable so it lets you have any combination of buttons/encoder/leds/pots etc and BMC also uses EEPROM (built-in/24LC256/SD Card) to store data that can then be edited with the Editor app and in order to do this it needs a global configuration for the program that is being uploaded, this configuration file contains things like the number of buttons, which pin each button is connected to, what pins are uses for serial midi (if any) weather EEPROM will be the builtin or the 24LC256 or the built-in SD card etc.
This configuration file must be seen by the BMC.h file and by all other files that are being included by BMC.h, so I had a few options:
#1 have a config.h as part of the library, when you want to upload a sketch just go and update that config.h file with the config.h generated by the editor app. The downside is that anytime you update the library that file would be reset to it's default! also if you have to build multiple midi controller with different configurations then you would have to constantly update this file.
#2 add a global config file that would reside in the sketch folder along with the .ino the upside of this method is that you can have a sketch for one midi controller and then another sketch for a larger midi controller and so on. The problem with this method is that there is no default way to include this config file for all libraries and it's dependencies to it's definitions. The only way to make this work is by modifying the boards.txt by appending to the "build.flags.cpp" for each teensy the following:
-include "{build.source.path}/config.h"
the issue with this is that now every sketch must have a config.h file in it's folder (event if the config.h is empty)
the solution to that is to add a new option to the Tools Menu on Arduino in the boards.txt, this is a mod that is required for BMC to work, this mod is appended at the bottom of the boards.txt flle
# ----- Include BMC Config Mod Starts -----
menu.bmcsketchconfig=Require BMC Config
teensy41.menu.bmcsketchconfig.no=No
teensy41.menu.bmcsketchconfig.yes=Yes
teensy41.menu.bmcsketchconfig.yes.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -include "{build.source.path}/config.h"
teensy40.menu.bmcsketchconfig.no=No
teensy40.menu.bmcsketchconfig.yes=Yes
teensy40.menu.bmcsketchconfig.yes.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -include "{build.source.path}/config.h"
teensy36.menu.bmcsketchconfig.no=No
teensy36.menu.bmcsketchconfig.yes=Yes
teensy36.menu.bmcsketchconfig.yes.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -include "{build.source.path}/config.h"
teensy35.menu.bmcsketchconfig.no=No
teensy35.menu.bmcsketchconfig.yes=Yes
teensy35.menu.bmcsketchconfig.yes.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -include "{build.source.path}/config.h"
teensy31.menu.bmcsketchconfig.no=No
teensy31.menu.bmcsketchconfig.yes=Yes
teensy31.menu.bmcsketchconfig.yes.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -include "{build.source.path}/config.h"
teensyLC.menu.bmcsketchconfig.no=No
teensyLC.menu.bmcsketchconfig.yes=Yes
teensyLC.menu.bmcsketchconfig.yes.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -include "{build.source.path}/config.h"
# ----- Include BMC Config Mod Ends -----
With this mod the user will now see a new option under Tools "Require BMC Config" that option will have 2 selections "Yes" and "No" if the user selects yes then when the sketch is compiled the config.h file will be included into the build, if the user selects No then that file will not be include.
This works fine for BMC except for the fact that users have to go in and find the boards.txt file and then add the mod and whenever they update Teensyduino it will remove this mod so the user has to go back and add it again.
I'm wondering if Paul would consider adding this option as a default to Teensyduino and maybe just label "Import Sketch config.h" or anything like that so that users don't have to use this mod.
I do see a few issues specially with newbies, for example, if you upload a sketch with library that requires this config.h and you don't check that option then you would get an error because the definitions are not there, or if you upload a sketch that doesn't have a config.h file in it's folder and they have the option checked then the user would see an error because the config.h wasn't found.
I hope this post makes sense, in my view Teensy boards are too powerful not to have more complex libraries that do all the work for the user and instead the user can use a simple app to communicate with the teensy and control them there as BMC does.
BMC handles everything from button presses to midi communication and so on, there is a main BMC.h file which includes a bunch of dependencies to read buttons, encoders, send/receive/merge/filter midi etc. All and all it works great.
Now BMC is scalable so it lets you have any combination of buttons/encoder/leds/pots etc and BMC also uses EEPROM (built-in/24LC256/SD Card) to store data that can then be edited with the Editor app and in order to do this it needs a global configuration for the program that is being uploaded, this configuration file contains things like the number of buttons, which pin each button is connected to, what pins are uses for serial midi (if any) weather EEPROM will be the builtin or the 24LC256 or the built-in SD card etc.
This configuration file must be seen by the BMC.h file and by all other files that are being included by BMC.h, so I had a few options:
#1 have a config.h as part of the library, when you want to upload a sketch just go and update that config.h file with the config.h generated by the editor app. The downside is that anytime you update the library that file would be reset to it's default! also if you have to build multiple midi controller with different configurations then you would have to constantly update this file.
#2 add a global config file that would reside in the sketch folder along with the .ino the upside of this method is that you can have a sketch for one midi controller and then another sketch for a larger midi controller and so on. The problem with this method is that there is no default way to include this config file for all libraries and it's dependencies to it's definitions. The only way to make this work is by modifying the boards.txt by appending to the "build.flags.cpp" for each teensy the following:
-include "{build.source.path}/config.h"
the issue with this is that now every sketch must have a config.h file in it's folder (event if the config.h is empty)
the solution to that is to add a new option to the Tools Menu on Arduino in the boards.txt, this is a mod that is required for BMC to work, this mod is appended at the bottom of the boards.txt flle
# ----- Include BMC Config Mod Starts -----
menu.bmcsketchconfig=Require BMC Config
teensy41.menu.bmcsketchconfig.no=No
teensy41.menu.bmcsketchconfig.yes=Yes
teensy41.menu.bmcsketchconfig.yes.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -include "{build.source.path}/config.h"
teensy40.menu.bmcsketchconfig.no=No
teensy40.menu.bmcsketchconfig.yes=Yes
teensy40.menu.bmcsketchconfig.yes.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -include "{build.source.path}/config.h"
teensy36.menu.bmcsketchconfig.no=No
teensy36.menu.bmcsketchconfig.yes=Yes
teensy36.menu.bmcsketchconfig.yes.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -include "{build.source.path}/config.h"
teensy35.menu.bmcsketchconfig.no=No
teensy35.menu.bmcsketchconfig.yes=Yes
teensy35.menu.bmcsketchconfig.yes.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -include "{build.source.path}/config.h"
teensy31.menu.bmcsketchconfig.no=No
teensy31.menu.bmcsketchconfig.yes=Yes
teensy31.menu.bmcsketchconfig.yes.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -include "{build.source.path}/config.h"
teensyLC.menu.bmcsketchconfig.no=No
teensyLC.menu.bmcsketchconfig.yes=Yes
teensyLC.menu.bmcsketchconfig.yes.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti -include "{build.source.path}/config.h"
# ----- Include BMC Config Mod Ends -----
With this mod the user will now see a new option under Tools "Require BMC Config" that option will have 2 selections "Yes" and "No" if the user selects yes then when the sketch is compiled the config.h file will be included into the build, if the user selects No then that file will not be include.
This works fine for BMC except for the fact that users have to go in and find the boards.txt file and then add the mod and whenever they update Teensyduino it will remove this mod so the user has to go back and add it again.
I'm wondering if Paul would consider adding this option as a default to Teensyduino and maybe just label "Import Sketch config.h" or anything like that so that users don't have to use this mod.
I do see a few issues specially with newbies, for example, if you upload a sketch with library that requires this config.h and you don't check that option then you would get an error because the definitions are not there, or if you upload a sketch that doesn't have a config.h file in it's folder and they have the option checked then the user would see an error because the config.h wasn't found.
I hope this post makes sense, in my view Teensy boards are too powerful not to have more complex libraries that do all the work for the user and instead the user can use a simple app to communicate with the teensy and control them there as BMC does.