Before someone replies “use a library”, read why that likely won’t work.
Maybe there is a way to do this, but I am not aware of it.
I have some functions I share between projects. The projects are for different boards - a MEGA and a Pro Mini. An example file is one for GPS. On the MEGA, I connect that to Serial 1 and so in the main file I have this defined:
#define GPSSer Serial1
on the Pro Mini, I use nss instead and have this declaration:
NewSoftSerial GPSSer (2,3);
So then in GPS.pde (a secondary file with a tab in the IDE), I can just use GPSSer.available() and GPSSer.read().
The two different meanings for GPSSer are source compatible, but not object compatible so I can’t make a library that I call with the serial port object.
There are other ways to get around it like coding the input in the main and only having the character passed to the GPS function, but this is just one example. I have a few files with similar issues.
I also like that it is all there in the IDE and I don’t have to go wok on the library for one thing and back in the program for another.
What would be ideal is a way to have some way of indicating to the IDE that there are files outside the project folder tat are part of the interactive project.