Learning how to use multiple tabs in IDE

Hi there - I don't have a specific question here sorry, but working on the Due and have a big project planned, no time pressure or anything it's just for fun. I'm thinking that down to the scale of the project, it will be a nightmare to navigate the sketch if it is all in a single tab. I've been experimenting with using multiple tabs but I am having trouble figuring out how you send data between tabs, and how you call a user defined void from a seperate tab and things like that (I am sure I will run into more problems as I go!!)

Can anyone point me towards a decent tutorial on multi-tab sketches in the IDE? Something a bit more than the basics,

many thanks

but I am having trouble figuring out how you send data between tabs

You don't. Data is stored in variables that may, or may not, be in the same scope on two different tabs. That depends, in part, on the type of file open in each tab.

and how you call a user defined void from a seperate tab

You don't call voids. C and C++ use functions, not voids. I don't know of any programming language that calls subroutines voids, so I'm pretty sure that no language lets you call a void.

The digitalRead() function returns an int. You don't talk about calling an int, when you refer to calling digitalRead(), do you? Then, why do you talk about calling a void?

You can call any function, regardless of which file it is defined in, as long as the compiler knows that the function exists, and what it's inputs and outputs are.

That, again, depends in part on what type of file is opened in each tab.

Something a bit more than the basics,

What it comes down to is that pesky thing called experience.

Tab's in the IDE is nothing more then the sketch split (as long as you don't give them the .c, .h or .cpp prefix!) and are just glued into one big text file before compiling.

PaulS:
You don’t. Data is stored in variables that may, or may not, be in the same scope on two different tabs. That depends, in part, on the type of file open in each tab.
You don’t call voids. C and C++ use functions, not voids. I don’t know of any programming language that calls subroutines voids, so I’m pretty sure that no language lets you call a void.

The digitalRead() function returns an int. You don’t talk about calling an int, when you refer to calling digitalRead(), do you? Then, why do you talk about calling a void?

You can call any function, regardless of which file it is defined in, as long as the compiler knows that the function exists, and what it’s inputs and outputs are.

That, again, depends in part on what type of file is opened in each tab.
What it comes down to is that pesky thing called experience.

Ok thankyou for explaining that for me - I am totally self taught and I think I can do a fair amount but pehaps don’t know how to describe it, so this is really useful.

septillion:
Tab’s in the IDE is nothing more then the sketch split (as long as you don’t give them the .c, .h or .cpp prefix!) and are just glued into one big text file before compiling.

Ok great thanks, this is exactly what I want, so do I need to use a different prefix or just no prefix?

do I need to use a different prefix or just no prefix?

No. You need to use a .ino suffix if you want the files all merged into one. Keep in mind that the order that the tabs were created has nothing to do with the order in which the files are merged. They are merged alphabetically, by tab name.

Uhm, yeah, meant suffix :frowning: But if you just give it a name without extension/suffix the IDE will just make it a .ino :slight_smile:

Ah yep "suffix". I will try this this afternoon thank you both!

Got it working, thanks a lot!

SineHacker:
Hi there - I don't have a specific question here sorry, but working on the Due and have a big project planned, no time pressure or anything it's just for fun. I'm thinking that down to the scale of the project, it will be a nightmare to navigate the sketch if it is all in a single tab. I've been experimenting with using multiple tabs but I am having trouble figuring out how you send data between tabs, and how you call a user defined void from a seperate tab and things like that (I am sure I will run into more problems as I go!!)

Can anyone point me towards a decent tutorial on multi-tab sketches in the IDE? Something a bit more than the basics,

many thanks

Well, you don't need a tutorial. I recently found out how to use the IDE tabs and it is quite simple. The following works well. I suppose you use C++ and organise your program with classes:

In the main tab, with the name of the project, you place all global constants, #defines, class declarations, global variables (object instances) and the body of the Setup and Loop functions. Then you create a tab for every class and there you place the implementations of the methods of the class. Thats it. You should of course make sure that the amount of code in Setup() and Loop() is minimal; Let the objects do the work; the Loop() should only contain the main logical flow. But that is just good coding practice, another topic.

So you see using tabs is really easy:

  1. Globals, class declarations, Setup() and Loop() in the main tab
  2. Method definitions of each class in a separate tab
1 Like