I am seeking a good tutorial that covers all of this. I need to break the project into multiple tabs/ino files, just to make it more clear.
So after you open a new tab, there are a few questions I would like to ask:
If the main project file, let's say main
, has another 2 tabs let's say A
and B
, so, every function in B would be visible to main
and also A
?
What happens with interrupts? If I have some interrupt that I define in file A
, can it call the function of the interrupt in the main
file?
What happens with defines
? and includes
? if file A
including some library lets say Wire
, does the main
file also see it and vice versa?
What's the strategy to work with files? Do you add all your libraries to the main, or should you also add them to other files? (For example a file that deal with gyro and has to include some library).
I have always had trouble using the Arduino IDE for more than one source file. I would lean towards using something like Arduino-Makefile which gives you more control over the build process of your Arduino project.
.ino
file.interrupt_handler()
function outside of the ISR.A
or B
removes #include <Wire.h>
, your main file will still include the dependency. The file will not be included twice because of header include guards. Interrupt Handler
#include <avr/interrupt.h>
#include "A.h"
/* Declare our ISR */
ISR(interrupt_vector)
{
/* Call our handler (located in A) */
interrupt_handler();
}