Guys, as I'm new to Arduino IDE I have the following question. I made a program in which the main loop has 5 functions, I would like to organize the program so that each function is not in the same work tab, so that each function or part of the program is in a different tab to facilitate the work.
So what is the problem ?
Which version of the IDE are you using ?
Have you tried adding new tabs to the IDE ?
(and use .ino for the suffix of the new tabs)
maybe missing an opportunity to learn something about object oriented programming ??
Study using version 2.1.1.
So can I create new tabs ending in .ino?
Let's say eum has 2 tabs. Tab named PRG1 and another tab named PRG2. In the PRG1 tab I call a function with example reset();. In the PR2 tab, can I put all the lines of this function?
void reset() {
.........
}
Why not try it ?
Click on the ellipsis top/right of the IDE and add a tab or two and experiment
You will also have to #include the new tab that just got added.
Interesting. Non arduino compilers would never do that.
Non Arduino IDEs would also not add function prototypes to the code so that you didn't have to
Yep, sorry to derail
that's why it's called .ino and not .c or .cpp or .hpp or whatever
it's to tell you they apply their secret sauce before compiling
Admirable I suppose. The *.ino method suffers from the plain fact that all those file are concatenated, thus share one set of symbols. So you can't have variables with the same name defined more than once. This takes away much of the advantage of using tabs.
So if I were to, it would be with *.cpp and *.h files, then as pointed out one would need to include a header file to refer to things in other tabs. No big deal.
I do something a bit different. A wise person said here many years ago that the hole thing was a nightmare and his approach was to just go ahead and put everything in the one *.ino.
That made enough sense to me. So for small to medium anything, I use one file, we call it the soup. All the ingredients are in there somewhere. Here's where a bit of discipline and a good programmer's text editor come in handy. The IDE text editor is not a particularly good choice, but it is convenient.
As always YMMV.
a7
Project PRG.ino and then tab named PRG1.ino, PRG2.ino, PGR3.ino...
i'm curious what the 5 function do, if they are related?
here's an example of how i organized files. what they contain is obvious in some cases
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/Node2.ino
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/eeprom.cpp
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/eeprom.h
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/i2c.cpp
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/i2c.h
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/mpc23017.h
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/node.h
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/pcRead.cpp
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/pcRead.h
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/sigMap.cpp
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/signals.cpp
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/signals.h
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/wifi.cpp
/cygdrive/c/stuff/RR/MdWvClub/Code/Node2/wifi.h
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.