I am creating a number of class libraries, many of them abstract with multiple alternative concrete classes beneath them. For example, I support at least four different motor types, but any given robot will need only one. If I include all four, I blow the UNO's memory capacity, so I must be able to select only one.
My solution (which doesn't yet work) is to create an "Options.h" file that contains a series of #define statements. E.G.:
#define USE_MotorA true
#define USE_MotorB false
Then I want MotorA.h to read the options file and decide whether to include its code:
#include "Options.h"
#if USE_MotorA
... generate the code here
#endif
This approach works fine when all the files are in the same folder as the .ino file, but it breaks down completely when I put MotorA into Libraries/MotorA and Libraries/MotorB, etc.
The problem is that MotorA cannot read the "Options.h" file in the sketch folder.
So as an alternative, I tried to include MotorA.h and MotorB.h libraries in the .ino definition but this still doesn't make Options.h visible to these files, and I cannot pass the "USE_MotorA" value to MotorA and MotorB.
My research tells me that this is only true with .INO files (not generally true of all C++ environments.
Can anybody suggest a direction that will work here? My goals are:
1) Each class library is reusable without modification
2) Only the classes required by this INO sketch are included
3) Fits in an UNO.