If I create a project named MyProject.ino, the .ino is where the main code is written.
If I create a module or second tab with additional code, I may create the following:
At the top of MyProject.ino I do:
This allows calling functions in the ExtraFunctions module from the main MyProject.ino
However, how do you go the other direction? If I want to reference a function or variable or object from the ExtraFunctions module that exists in MyProject.ino, it should work if I #include a reference to MyProject.ino in ExtraFunctions, but I don’t know how to do that as MyProject.ino doesn’t have a header.
I understand this may be bad practice, so I can possibly include the items from MyProject in the ExtraFunctions module, though I haven’t been able to do this with Timer.
I have tried adding the Timer object to the .hpp header in the module ExtraFunctions.hpp like this:
Timer tmr_1minute(60000, tmr_1minute_service);
The callback tmr_1minute_service exists in ExtraFunctions.cpp with the declaration in ExtraFunctions.hpp
I attempt to start this timer from setup() in the main MyProject.ino like this:
But I get compile errors:
multiple definition of `tmr_1minute'
I have run into essentially the same problem with any objects being created in Particle, which forces me to add a lot of code to the main MyProjrect.ino when I would rather put it in separate files.