Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic can I develop and try class in the same solution? (Read 5725 times)
pinkfloyd11
Junior Member
**
Offline


Posts: 18
Joined: Apr 10th, 2014
can I develop and try class in the same solution?
Apr 8th, 2015 at 11:58am
Print Post  
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
« Last Edit: Apr 8th, 2015 at 12:04pm by pinkfloyd11 »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: can I develop and try class in the same solution?
Reply #1 - Apr 8th, 2015 at 3:19pm
Print Post  
Hi,

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

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


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

It is out of screenshot:


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


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: can I develop and try class in the same solution?
Reply #3 - Apr 8th, 2015 at 3:54pm
Print Post  
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
Joined: Apr 10th, 2014
Re: can I develop and try class in the same solution?
Reply #4 - Apr 8th, 2015 at 6:48pm
Print Post  
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
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: can I develop and try class in the same solution?
Reply #5 - Apr 8th, 2015 at 6:58pm
Print Post  
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
Joined: Apr 10th, 2014
Re: can I develop and try class in the same solution?
Reply #6 - Apr 8th, 2015 at 8:02pm
Print Post  
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 TopicPrint