#include sub-folders?

If you link them like this then incidentally that’s the only way this works. By themselves, your header files are probably not valid (=“being able to be included from everywhere without error”) because they expect that certain files have been included before them in which e.g. some global variables are.

All in all, if you want to split code, you shouldn’t put the C++ implementation code in a header file and then #include it, but properly split it as a .h header file with only function and variable prototypes / declarations and a .cpp file with the implementation.

This is already covered in topics like Splitting cpp files and Tutorial for creating multi cpp file arduino project. It’s a pure C/C++ development topic and has nothing to do with PlatformIO itself really, but we’re still here to give support of course.

I’m sure if you read through the above links and tutorials on how to split C++ code in header and implementations, plus how to declare and define global variables using the extern keyword and friends, you’ll be able to rewrite your project properly.

If you need concrete help, you’d need to post the complete project, in e.g. Github or google drive.