OK, I have a bit if a confusing issue here.. The project is a little big to all post here, so i'll post the relevant parts...
The following doesn't work if I have it outside the Setup or Loop routines, it does work inside them... Problem is I'd like to initialize them as global variables
Is there something I'm doing wrong or is it just not possible? Would I have to have the class constructor accept all the variables and set them all that way? (get a little long when you have a lot of them);
MyVar Blah; //Myvar is a class I've defined.. code later
float blahSmoothing = Blah.Smoothing; // This works
Blah.Smoothing = 1.0f; //This fails, "Blah does not name a type"
Attached is the entire project... At this point I'm just trying to figure out what works as far as layout, and the flow of things is yet to be determined
I'm still getting the grasp of how the header and cpp files interact, I have now commented out all the extra variables you mentioned and avoided the duplication.
Your code needs to be inside setup( ) or loop( ) or some other function.
You can't have regular executable statements just sitting around anywhere in your source code file, they need to be inside the functions, or inside the class definitions.
float blahSmoothing = Blah.Smoothing; // This works
Blah.Smoothing = 1.0f; //This fails, "Blah does not name a type"
The first line here works, because it is the declaration, with initialization, of your variable blahSmoothing, which will have global scope in that source code file, because it apparently is declared outside any of your functions.
The second line doesn't work, because it is a regular assignment statement ( not a declaration ), and therefore it has to be inside a function somewhere.
All those variables which you declare at the top of your MyVar.cpp file would seem to be pointless, and probably wrong.
It's fine to have global variables, if they are managed properly. But to consider them as associated with a particular class, is not in the spirit of OO. Even if you can somehow force them to interact. Generally, C++ was designed to support OO, but not enforce it. So you can't assume that you're doing something correctly, just because it's permitted.
Rx7man:
The following doesn't work if I have it outside the Setup or Loop routines, it does work inside them... Problem is I'd like to initialize them as global variables
Initialise them in setup(), which works. That's what setup() is for.
Because of the forcasted size of this project, I have a call to another function in setup where it all happens.. I'm trying very hard to not write spaghetti code and the jury is out on that
Thanks for the help... I do have another little issue with drastically varying loop times but I'll work on it myself a while first.