Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
can I develop and try class in the same solution? (Read 4687 times)
pinkfloyd11
Junior Member
**
Offline



Posts: 18
can I develop and try class in the same solution?
Apr 8th, 2015 at 12:58pm
 
Hello

I'm developing my first class for my project.
I need to test this class, so I would use it in the same solution.
I should set and get string in every method of class.

My problem is that I cannot set value in .ino

Why?

cpp:
...
free image hosting

.h
...
upload immagini gratis

.ino
...
invia immagini



Thanks
Back to top
« Last Edit: Apr 8th, 2015 at 1:04pm by pinkfloyd11 »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10464
United Kingdom
Re: can I develop and try class in the same solution?
Reply #1 - Apr 8th, 2015 at 4:19pm
 
Hi,

You forgot to #include your .h file in your sketch .ino code.

Thanks
Back to top
« Last Edit: Apr 8th, 2015 at 4:20pm by Visual Micro »  
WWW  
IP Logged
 
pinkfloyd11
Junior Member
**
Offline



Posts: 18
Re: can I develop and try class in the same solution?
Reply #2 - Apr 8th, 2015 at 4:50pm
 
No, the header there is.

It is out of screenshot:

...
url immagine
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10464
United Kingdom
Re: can I develop and try class in the same solution?
Reply #3 - Apr 8th, 2015 at 4:54pm
 
Okay so you have to instantiate the class or set the methods and properties to be static.

You should follow the guides on arduino.cc to learn how to use a class.

One option is to use the visual micro option to create the cpp/h that I mentioned earlier. When you enter the name for the new files add the word "Class" to the end of the name you provide. For example MyButtonClass. Visual Micro will then create a cpp/h and add the code for the new class and also instantiate it as a global object. The cpp class will be called MyButtonClass and will be instantiated as MyButton. So in the sketch code you could then use MyButton.something();
Back to top
 
WWW  
IP Logged
 
pinkfloyd11
Junior Member
**
Offline



Posts: 18
Re: can I develop and try class in the same solution?
Reply #4 - Apr 8th, 2015 at 7:48pm
 
If I have understad correctly in my case I should use Class Wizard and choose as name Pacchetto_DT_Class.

Visual Micro will generate .cpp and .h files.

Then I should copy all code in this new class.

In .ino file I will write something like:

Pacchetto_DT.Set_Mittente = ('012345');

Correct?


Can you suggest me good link  for learn how to use a class?

Thanks
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10464
United Kingdom
Re: can I develop and try class in the same solution?
Reply #5 - Apr 8th, 2015 at 7:58pm
 
Hi,

The class wizard is for experienced arduino users.

When you use the visual micro right click menu items to "add Cpp/H" this does not use the wizard. After using the menu item to create Pacchetto_DTClass a .cpp and an .h will be created with your class inside. It should also contain an example method and variable.

As I said earlier, the arduino.cc web site is the best place for tutorials and code structure. You should ignore the class wizard for the time being.

Thanks
Back to top
 
WWW  
IP Logged
 
pinkfloyd11
Junior Member
**
Offline



Posts: 18
Re: can I develop and try class in the same solution?
Reply #6 - Apr 8th, 2015 at 9:02pm
 
Hi

I had create new sketch, then in solution explorer area I have done  right click Add -> Class...


...
upload

If I continue I will go always on Class Wizard.

Could you explane better please?

Thanks
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print