Call a function in INO from a CPP file

Hello

I need to move some functions from INO to a CPP file to make the program more readable.

the INO contains:
// stuff
#include "CheckSerial.h"
void loop {
//do stuff
CheckSerialInput();
//do stuff
}
void SwitchLight(int number, bool state) {
//do stuff
}
// stuff

the CheckSerial.cpp contains:
// stuff
void CheckSerialInput(){
//do stuff
SwitchLight(number, state); <--- Error
//do stuff
}
// stuff

How can i #include main INO file in CheckSerial.h/cpp to call a function back?

Thank you

Jack

The best way is to move the function in the cpp or create another cpp and include its header file in both your cpp and the ino.
If you realy want to keep it int the ino file, you must give it as parameter of the function

In your cpp

void CheckSerialInput(void (*f)(int, bool) )
{
  //do stuff
  (*f)(number, state);
  //do stuff
}

In your .ino

void SwitchLight(int number, bool state);

void loop {
  //do stuff
  CheckSerialInput(SwitchLight);
  //do stuff
}

void SwitchLight(int number, bool state) {
  //do stuff
}

If you are using the Arduino IDE, you could put the functions into tabs. The tabs will be saved as .ino files in the sketch folder.

Thank you for the quick answer!

Both solutions works perfectly

The solution from xartefact (function pointer) is more flexible, while the solution from groundFungus (just add another file) is easyer for newbie on Arduino and seems to use 70 bytes of program storage less.

Thanks
Jack