VS Arduino | |
>> >> can I develop and try class in the same solution?
https://www.visualmicro.com/forums/YaBB.pl?num=1428494292 Message started by pinkfloyd11 on Apr 8th, 2015 at 11:58am |
Title: can I develop and try class in the same solution? Post by pinkfloyd11 on Apr 8th, 2015 at 11:58am
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 |
Title: Re: can I develop and try class in the same solution? Post by Visual Micro on Apr 8th, 2015 at 3:19pm
Hi,
You forgot to #include your .h file in your sketch .ino code. Thanks |
Title: Re: can I develop and try class in the same solution? Post by pinkfloyd11 on Apr 8th, 2015 at 3:50pm |
Title: Re: can I develop and try class in the same solution? Post by Visual Micro on Apr 8th, 2015 at 3: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(); |
Title: Re: can I develop and try class in the same solution? Post by pinkfloyd11 on Apr 8th, 2015 at 6: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 |
Title: Re: can I develop and try class in the same solution? Post by Visual Micro on Apr 8th, 2015 at 6: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 |
Title: Re: can I develop and try class in the same solution? Post by pinkfloyd11 on Apr 8th, 2015 at 8: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 |
VS Arduino » Powered by YaBB 2.6.12! YaBB Forum Software © 2000-2024. All Rights Reserved. |