user23997: Im working on a RGB LED matrix project (10 x 10 Neopixels) and I'm using classes to handle the different hardware components. Whats the best way to deal with multiple files in the project eg, I have a class which holds the various display functions such as writing text and drawing circles, but every time I change something it takes ages to compile (Greater than 30 seconds) is there a way to have multiple files without using classes?
Any help would be greatly appreciated.
Cheers

user31105: I noticed that it is very hard to use classes with the default IDE.
Each file will be in a different tab, but normally each class has a header (.h) and implementation (.c) file, so 2 extra tabs per class.
If you have just 3-4 classes you can use the default IDE.
However, if you want to use more, you have to use e.g. Eclipse or Visual Studio, whatever IDE you like best.
Search for Eclipse/Arduino, I think there are multiple options.
Myself I use visualmicro ... it is free except you cannot use the debugger option.
I used several classes in my sketch and don't think the compile time was 30 seconds; it might be depending also on the amount of include files.
Also a complex program is not necessarily a program with many classes. I would say, that if you put too much functionality in one class (or one single sketch), you get a complex program.

user10394: Yes you can have multiple files without classes.
Functions don't have to go in classes, see loop and setup for an example. All you have to do is declare the function in a header file and then implement it in a body.
so:
// File Bob.h
#ifndef __BOB_H__
#define __BOB_H__

int SomeFunction(const char val);

#endif // __BOB_H__ 

// File Bob.cpp
#include Bob.h
int SomeFunction(const char val)
{  
   return (int)val;
}


// File SketchName.ino
#include "Bob.h"

setup()
{
  ......... Stuff

Now in theory the compiler will only rebuild Bob.cpp when you change code in it.  In practice you will change code in it and the compiler won't rebuild it and you'll tare your hair out until you remember that if all else fails, rebuild all!
In SketchName.ino some people will say you should always put your includes first, some will say last and some will say it makes no difference.  In my experience its easier to fix duplicate definitions by changing your code so I always put 'my' includes last, because that way the compiler will report the errors against my code.
BTW 30 seconds is not a long build time.  I've worked on projects taking 12+ hours, and missing a semi colon on those projects does not make you popular :)

23997: <p>Im working on a RGB LED matrix project (10 x 10 Neopixels) and I'm using classes to handle the different hardware components. Whats the best way to deal with multiple files in the project eg, I have a class which holds the various display functions such as writing text and drawing circles, but every time I change something it takes ages to compile (Greater than 30 seconds) is there a way to have multiple files without using classes?</p>

<p>Any help would be greatly appreciated.</p>

<p>Cheers</p>
 31105: <p>I noticed that it is very hard to use classes with the default IDE.
Each file will be in a different tab, but normally each class has a header (.h) and implementation (.c) file, so 2 extra tabs per class.</p>

<p>If you have just 3-4 classes you can use the default IDE.</p>

<p>However, if you want to use more, you have to use e.g. Eclipse or Visual Studio, whatever IDE you like best.</p>

<p>Search for Eclipse/Arduino, I think there are multiple options.</p>

<p>Myself I use <a href="http://www.visualmicro.com/page/Arduino-Visual-Studio-Downloads.aspx" rel="nofollow noreferrer">visualmicro</a> ... it is free except you cannot use the debugger option.</p>

<p>I used several classes in my sketch and don't think the compile time was 30 seconds; it might be depending also on the amount of include files.</p>

<p>Also a complex program is not necessarily a program with many classes. I would say, that if you put too much functionality in one class (or one single sketch), you get a complex program.</p>
 10394: <p>Yes you can have multiple files without classes.</p>

<p>Functions don't have to go in classes, see loop and setup for an example. All you have to do is declare the function in a header file and then implement it in a body.</p>

<p>so:</p>

<pre><code>// File Bob.h
#ifndef __BOB_H__
#define __BOB_H__

int SomeFunction(const char val);

#endif // __BOB_H__ 

// File Bob.cpp
#include Bob.h
int SomeFunction(const char val)
{  
   return (int)val;
}


// File SketchName.ino
#include "Bob.h"

setup()
{
  ......... Stuff
</code></pre>

<p>Now in <strong>theory</strong> the compiler will only rebuild Bob.cpp when you change code in it.  In practice you will change code in it and the compiler won't rebuild it and you'll tare your hair out until you remember that if all else fails, rebuild all!</p>

<p>In <code>SketchName.ino</code> some people will say you should always put your includes first, some will say last and some will say it makes no difference.  In my experience its easier to fix duplicate definitions by changing your code so I always put 'my' includes last, because that way the compiler will report the errors against my code.</p>

<p>BTW 30 seconds is not a long build time.  I've worked on projects taking 12+ hours, and missing a semi colon on those projects does not make you popular :)</p>
