There are very few that know what the IDE exactly does. There is a process called the arduino builder and we know what it is supposed to do and we can point out where it miserably fails.
The arduino builder (IDE) creates one big file from all ino files. It starts with the file that has the same name as the holding dirtectory and next appends all other ino files to the the end in alphabetical order. That is the file that is passed to the compiler.
The arduino builder is also supposed to add function prototypes in the right place in the final file.
The result of this will be a file with the double extension .ino.cpp.
When the compiler encounters a call to a function (e.g. to PROGRAM_LED_IDEL_PUMP_UP()
) the compiler needs to know what the arguments and return value of that function are.
If you look at your original that I successfully compiled, PROGRAM_LED_IDEL_PUMP_UP()
is defined before it is used in loop().
When you did split your main code it will be after loop (as mentioned above) and hence the compiler does not know about it.
For the given problem you can add a so-called function prototype before the first function in your main code.
...
...
const int L_SlowBlow = 5;
const int brightnessMax = 180; // % brightness = x%+254/100
const int interval = 3500; // 5 seconds
// sterretje: function prototype
void PROGRAM_LED_IDEL_PUMP_UP(DM13A_LedSegment LedSegment, NextExcecutionTime &functionCycleTimer, bool reset = false);
void SlowBlowLed_Boot() {
for (int i = 0; i <= brightnessMax; i++) {
int pwmValue = pow(2, i / 32.0) - 1; // Logarithmic scale
analogWrite(L_SlowBlow, pwmValue);
delay(interval / brightnessMax);
}
}
...
...
The IDE is supposed to add this prototype for you but it did not (or put it in the wrong place). And hence your problem.
To find what the compiler actually compiles, you can enable verbose output during compilation under file/preferences in the IDE. If the IDE gets to the point where it has created this big sketch file, you will be able to find a file called something like yourSketch.ino.cpp. You can search the verbose output (easiest to copy it to a text editor) and search for .ino.cpp.
Below the result for your code where a function was moved; note the .ino.cpp near the end of the second line.
...
...
Detecting libraries used...
/home/wim/Downloads/1_arduino_ide_1.x/arduino-1.8.19-1284188_error_moving/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10819 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -I/home/wim/Downloads/1_arduino_ide_1.x/arduino-1.8.19-1284188_error_moving/hardware/arduino/avr/cores/arduino -I/home/wim/Downloads/1_arduino_ide_1.x/arduino-1.8.19-1284188_error_moving/hardware/arduino/avr/variants/eightanaloginputs /tmp/arduino_build_514557/sketch/2024_07_19_Ghostbuster_ProtonPack.post09.ino.cpp -o /dev/null
...
...
Note that the given solution works for this specific problem; it might not work for all problems that you will encounter with multiple ino files. In that case you have to use .h and .cpp files.