TMC Adaptive Microstep Table

No,
this code is not near the phase where it can be tested on real print.

Ironically, in the end, I reinvented the wheel from this thread: Motion analysis by stepper phase
I read about it some time ago and have completely forgotten it since May.