The code is not too bad… you should consider reading the analog signal less often, you don’t have to read it at every iteration of the main loop? Maybe 10 to 20 times per second will be enough?
But I think there may be a problem with ESP32 and using the analogRead function alongside current sensing. Try chainging analogRead(potPin) to adcRead(potPin)
I don’t know, I think if you want to control them both separately, then you need to use 2 inputs… encoding them both into the same PWM signal would be complicated, I think, and probably lead to errors/problems.
But limiting the current will at the same time limit the maximum velocity, so perhaps (depending on your application) limiting the current is enough?