I'm using VS2015 and because of my sketch size, I've split the single ino file into 6.
I'm trying to set the background color of a button based on an arduino variable.
I can declare the following:
InterfacePanel Panel; // The VS editor accepts this enty
But
Panel.set blah blah blah //The VS editor only accepts this before Setup(). Anywhere else i.e. loop() and beyond, it will give me an error during compiling.
What am I doing wrong?
Thanks
RoboBill
Unable to set data to send back to the UI
Hi Bill, could you please send me a copy of the code to
support@megunolink.com? I'll check it out and see if I can get it working here.
What build tool are you using? Visual Micro or the MegunoLink one?
Cheers
Phil
support@megunolink.com? I'll check it out and see if I can get it working here.
What build tool are you using? Visual Micro or the MegunoLink one?
Cheers
Phil
Since I'm not a programmer, I don't know what build tool I'm using. I'm also not comfortable sending out my code. Since its well over a thousand lines, I'll step aside and work with a simple sketch then work it into the main code.
I'll keep you in the loop.
Thanks
RoboBill
I'll keep you in the loop.
Thanks
RoboBill
To begin, I am using VisualMicro Pro with VS 2015.
My first step to better understand this problem was to run the MLP example: Data Receiver Demo by itself... No problem there.
Next I put the following lines from the MLP example into a single file version of my current code.
// Progress value
int Progress;
// The interface panel we are sending data to
InterfacePanel Panel;
and
Panel.SetProgress("Progress", Progress);
Panel.SetNumber("Current", Progress);
NO Problem
Lastly I put the same MLP lines in the multi-file (and current) version of my code and BURP... NO GOOD
It appears your "talk back to UI" stuff doesn't like multi file versions of Arduino codes
Thanks,
RoboBill
My first step to better understand this problem was to run the MLP example: Data Receiver Demo by itself... No problem there.
Next I put the following lines from the MLP example into a single file version of my current code.
// Progress value
int Progress;
// The interface panel we are sending data to
InterfacePanel Panel;
and
Panel.SetProgress("Progress", Progress);
Panel.SetNumber("Current", Progress);
NO Problem
Lastly I put the same MLP lines in the multi-file (and current) version of my code and BURP... NO GOOD
It appears your "talk back to UI" stuff doesn't like multi file versions of Arduino codes
Thanks,
RoboBill
Hi RoboBill,
Great idea to start breaking your program up into smaller chunks. 1,000 lines is quite a bit for a single file. And breaking your problem down to the simplest example is a good idea too.
Without the actual source it is a little hard to be sure what the problem is but my best guess is you're not sharing the global variables across multiple code files.
The solution is to put the common variables declarations into a shared file that gets included into each program file (shared.h here) and the implementation into a source file (Shared.cpp here). Use #include "Shared.h" to get access to the globals for each source file (.cpp or .ino) that needs them.
Shared.h
-----------
Shared.cpp
-------------
MainProgram.ino
--------------------
Its possible I didn't quite understand your question. If that doesn't make any sense, please zip up the simple sketch example and send it through.
Have a great day,
Paul.
Great idea to start breaking your program up into smaller chunks. 1,000 lines is quite a bit for a single file. And breaking your problem down to the simplest example is a good idea too.
Without the actual source it is a little hard to be sure what the problem is but my best guess is you're not sharing the global variables across multiple code files.
The solution is to put the common variables declarations into a shared file that gets included into each program file (shared.h here) and the implementation into a source file (Shared.cpp here). Use #include "Shared.h" to get access to the globals for each source file (.cpp or .ino) that needs them.
Shared.h
-----------
Code: Select all
// The Panel object is declared external so that all who include this file know about it.
// This doesn't actually make an InterfacePanel it just lets everyone know what Panel is.
extern InterfacePanel Panel;
// This is the declaration for a function that we want to make available to multiple files.
void MyFunction(int p);
-------------
Code: Select all
// This is the actual instance of the object. It sets aside the memory and other things for the panel.
InterfacePanel Panel;
// Here's the definition of the function. Notice it is using Panel
void MyFunction(int p)
{
Panel.SetProgress("Progress", p);
Panel.SetNumber("Current", p);
}
--------------------
Code: Select all
#include "Shared.h" // so we know what Panel is.
void loop()
{
// The panel can be used here because there is a declaration for it in Shared.h (which got included above)
Panel.SetProgress("Progress", Progress);
Panel.SetNumber("Current", Progress);
// Also, we can use the function we declared in Shared.h
MyFunction(Progress);
//etc.
}
Have a great day,
Paul.
Hi Paul,
Thanks for the explanation. When I split the large program file into multiple files, I kept the global variable declarations, the setup() and loop() in the "main" file. All called functions were grouped in numerous multiple files. I didn't add any "#include other files "stuff in the main file. It compiles and runs your megunolink.h & SerialCommandHandler.Process(); stuff just fine. I can put SerialCommandHandler.Process(); anywhere in any of the files.
But when I add "int Progress;" & "InterfacePanel Panel;" to the global area of the main file of a multi file program, I'm unable to put "Panel.blah blah" in the loop() section which is still located in the main file.
My question is; while using VS 2015, have you guys been able to send data back to the UI with a multi file program? If so then its somehow me.... which would not be too surprising.
Thanks again
RoboBill
Thanks for the explanation. When I split the large program file into multiple files, I kept the global variable declarations, the setup() and loop() in the "main" file. All called functions were grouped in numerous multiple files. I didn't add any "#include other files "stuff in the main file. It compiles and runs your megunolink.h & SerialCommandHandler.Process(); stuff just fine. I can put SerialCommandHandler.Process(); anywhere in any of the files.
But when I add "int Progress;" & "InterfacePanel Panel;" to the global area of the main file of a multi file program, I'm unable to put "Panel.blah blah" in the loop() section which is still located in the main file.
My question is; while using VS 2015, have you guys been able to send data back to the UI with a multi file program? If so then its somehow me.... which would not be too surprising.
Thanks again
RoboBill