It is possible to split the project into server files. However, it looks like they all must be in the same folder with the.ino file.
Is it possible to split project into several folders? I’ve got several git repositories which I want to use in the same project and I can’t use them as libraries. Each repository must have its own folder...
1 Answer 1
I will try to give an answer as it is not easy to understand what you mean.
Probably it is also better if you know how the Arduino IDE works, before try to make complex projects.
Short answer: Yes, it is possible
Normally, you have an ino-file, some other files and many libraries. If you want create something for your project, you can just create a folder inside the library folder.
But this is not what you want right?
You can create many folders inside your project and include any header inside your folders just with
#include "subfolder/yourfile.h"
The files will not be opened with your Arduino IDE.
You can also create your "mini library", so the compiler will compile it with your project. This library need to be in a subfolder called src
. At this point it will be converted and compiled for your project.
Simple working example:
testsub.ino
#include "src/test.h"
Test *test = new Test();
void setup(){
Serial.print(test->number());
}
void loop(){
}
Create a subfolder src
and place your files:
test.h
class Test
{
public:
Test();
int number();
};
and
test.cpp
#include "test.h"
Test::Test() {
}
int Test::number() {
return 95;
}
If you want another "library", you can create another subfolder called src
.
-
You know, that's finally quite something! Thank so much! However, how can I have extra subfolder with the same name
src
?zhekaus– zhekaus2019年12月16日 16:42:24 +00:00Commented Dec 16, 2019 at 16:42 -
1You need to place the second subfolder inside the src folder. And there, you can place another src folder. This is the only way at the moment.Adriano– Adriano2019年12月16日 22:42:19 +00:00Commented Dec 16, 2019 at 22:42
simple
? Looks like things are simple only for simple deeds.#include "subfolder/header.h"
and it works. You can see this big project for example: github.com/xoseperez/espurna/tree/dev/code/espurna - but you will not see the files inside the Arduino IDE. Simple means, that if you don't have programming skills, you are able to open and edit something without loose time to find out what an IDE is and how it works. In future, with the PRO version, it will be easier to develop something... I hope ;)