It would be great to have this grbl feature on esp32.
https://github.com/fschill/grbl-Mega/tree/spindle_sync
It implements a feed per revolution mode (G95), based on encoder-measured spindle speed. Further, the G4 pause command waits for the given time, and then waits a bit more for the next spindle zero crossing. This allows to line up multiple passes.