I understand that Arduino programming is procedural and not so much Object Orientated and also that the Arduino or AVR are only single core processors and any kind of "Multitasking" or "Threading" is emulated at best but I was wondering if there is a way to pause program execution in one area temporarily and give another area control? For example say we have the following class:
Class A{
void Test();
void ProgramLoop();
}
void A::Test(){
for (int i = 0; i < 10; i++){
//Lots of cool stuff going on here but need to give
//Control to someone else say ProgramLoop()
Sleep(10);
}
}
void A::ProgramLoop(){
Serial.println("In Program Loop");
}
Then in the main file:
A testClass;
void Setup(){
Serial.begin(57600);
}
void Loop(){
testClass.Test();
testClass.ProgramLoop();
}
I know I could do something like:
void Loop(){
if (!testClass.isBusy){
testClass.ProgramLoop();
}
}
But I am trying to find out if there is a way to control how the program execution gives control? I understand that this is more of a threading topic, thats not what I am trying to get at, I just want to know if this is possible maybe using some sort of built in function or something? Or do my programs have to "Fall Through" being ONLY Procedural?