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 Sketch with C++ Class (Read 10850 times)
LLSB
Junior Member
**
Offline


Posts: 14
Location: Tucson, AZ
Joined: Jun 10th, 2014
Sketch with C++ Class
Aug 23rd, 2014 at 4:05pm
Print Post  
When starting a new Arduino Project the user has three choices for the Visual Micro Plug-in if I’m correct.

File:
       New->”Sketch Project”

File:
New->Project (Templates)
                   C/C++ -> “Arduino Sketch”
                   Visual Micro->”Arduino Sketch with      
C++ Class Example”

My question, “Sketch Project” or Project (Templates) “Ardunio Sketch”, are they same Template or is there some special features between the two Sketch Templates?

Also, I tried using ”Arduino Sketch with C++ Class Example”  but I don’t understand were the Class Library files need to “live” for a good build?  I tried a working Sketch (LED13) which I copied (.h with .cpp) files inside into Solution Explore (renamed the Class files and code) but it seems the Class files are not found during the Build. I then tried to move Class Files from (Atmel Project folder) to the “Arduino-User Library folder” but Amtel Studio IDE will not allow the files to be relocated out side the Solution Explorer. What I’m I doing wrong? I would like to keep the Class Files part of my Solution Explorer so my editing can be done on the fly.
Thank you, Mr. Visual Micro Guru!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Sketch with C++ Class
Reply #1 - Aug 23rd, 2014 at 4:52pm
Print Post  
Smiley

Quote:
My question, “Sketch Project” or Project (Templates) “Ardunio Sketch”, are they same Template or is there some special features between the two Sketch Templates?


No difference and you can add cpp/h files manually or using the Visual Micro menus) to any sketch at any time.
http://www.visualmicro.com/page/User-Guide.aspx?doc=Add-Source-Files.html


The discussion is really a discussion about the simplicity/quirks of Arduino and Arduino compatibility.

Quote:
don’t understand were the Class Library files need to “live” for a good build


If you bear in mind that Visual Micro performs an identical build to the Arduino Ide and therefore you can always build programs in the Arduino IDE that were created with Visual Micro.

So with this in mind consider that the Arduino IDE does not know (or care) about the Atmel project files or anything other than the ino/cpp/h sources directly in the sketch folder.

You should use the c++ project that Visual Micro creates for you via the "File>New>Project Wiazard" because it should build correctly and show you what is required to use cpp files in any Arduino project.

1) The files must exist in the sketch folder
2) The sketchName.ino must #include the .h file which is how c++ projects work

I hope this helps. The library discussion would be best in a different thread but steer clear until you have mastered the "Arduino way" of doing things locally in a sketch.
  
Back to top
WWW  
IP Logged
 
LLSB
Junior Member
**
Offline


Posts: 14
Location: Tucson, AZ
Joined: Jun 10th, 2014
Re: Sketch with C++ Class
Reply #2 - Aug 23rd, 2014 at 8:58pm
Print Post  
Quote:
"File>New>Project Wizard"

I don't see a "Project Wizard" listed, just "Project", "File", "Example Project" and "Sketch Project"? 

Quote:
Arduino IDE does not know (or care) about the Atmel project files or anything other than the ino/cpp/h sources directly in the sketch folder.

So, if I understand you correctly, if (ino/cpp/h, sources files) are located together in the same directory, no matter were, these dependency files will be found by Arduio IDE and build with out any issue? 
Thank you Mr. Guru!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Sketch with C++ Class
Reply #3 - Aug 23rd, 2014 at 9:02pm
Print Post  
Sorry I thought you were using Atmel Studio which has a File>New>Project option.

1)

Instead, you can right click any project in the solution tree and see the Visual Micro menus to add cpp/h file

If the name you give ends with the word Class then a call will be setup for you and a global object example created.

2)

You have to #include "myclass.h" in the sketchname.ino otherwise the compile will not pick it up. This is also  documented on the arduino.cc wiki.

Thanks

  
Back to top
WWW  
IP Logged
 
LLSB
Junior Member
**
Offline


Posts: 14
Location: Tucson, AZ
Joined: Jun 10th, 2014
Re: Sketch with C++ Class
Reply #4 - Aug 24th, 2014 at 4:10pm
Print Post  
Quote:
Sorry I thought you were using Atmel Studio which has a File>New>Project option.

I'm using both Ardino 1.05-r2 and Atmel Studio 6.2.1153 IDE, but
Quote:
"Project Wizard"
is not listed in the Atmel IDE.

File->> New ->> Project
                     ->> File
                     ->> Example Project
                     ->> Sketch Project

My method to my “madness”  in learning the 'How To" I first try the Sketch inside Arduino IDE to make sure it at least the code build or compile without any errors, then I move or copy the code into Atmel IDE to take advantage of tools-sets, which lead to my posting.

I first down load a Sketch named “ LED13”  which uses a C++ Class that build/compile in Ardunio IDE without any errors, then I move the code to the Atmel IDE, change the file names (i.e. Led16_lib.ino, Led_16.cpp and Led_16.h) and then change the sketch code to the new Class file names.  Maybe this were I’m going wrong. I noticed there is more than one way to copy a Class into Atmel IDE, Solution Explorer. 

The method I used
Solution Explorer->>Add->>Existing Item

or

Maybe I should of used
Project ->> Add/Import Sketch Library ->> User or Core

I then change Compile Preprocessing Directive [#include' Search locating]

From:      
#include <old file name>.
Searches for a file named file in a standard list of system directories.

To: 
#include "new file name". 
Searches for a file named file first in the directory containing the current file, then in the same    
directories used for <file>.

I’m I correct? Hopefully not leading other down the wrong path with this posting?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Sketch with C++ Class
Reply #5 - Aug 24th, 2014 at 5:31pm
Print Post  
Hi there,

It's worth reading the docs. Visual Micro makes Atmel work the same way as the Arduino Ide. You can open the sketches that Visual Micro creates in the arduino ide as normal and open sketches in Visual Micro that are created in the arduino ide. Both use the same code and structure.

The wizard is a generic term for the file>new>project dialog that opens in atmel. You can see it in the lower section of the page here http://www.visualmicro.com/page/User-Guide.aspx?doc=Create-New-project.html

You can open existing arduino projects either by using the guide in the link http://www.visualmicro.com/page/User-Guide.aspx?doc=Open-existing-sketch.html or by closing the current solution and clicking File>Open>File then picking a pde.ino

The arduino rules are that a sketch must be in a folder and contain a .ino of the same name. Visual Micro also expects the atmel project to have the same name.

You can not configure any atmel project proeprties because visual micro overrides and uses an Arduino compatible build process which atmel does not natively support.

For arduino, you can not add files from outside of the sketch folder unless you use libraries. Libraries must conform to the arduino rules.

So everything on arduino.cc applies to visual micro and that means you can also read the arduino.cc wiki and use their forum for standard code, compile, upload questions
« Last Edit: Aug 24th, 2014 at 5:33pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Sketch with C++ Class
Reply #6 - Aug 26th, 2014 at 3:16pm
Print Post  
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint