Congratulations on solving part of the problem.
Unfortunately, your source code looks terrible again.
Please make your code more readable by paying attention to How to post logs and code in PlatformIO Community Forum.
This will significantly increase the chance of getting help from a forum member.