Help with live adjusting feedrate with temperature control

Hey guys,

I would like to ask you for some help with a project that I have in hands.

I am using a CNC setup to control the position of an IR heat source.

Now I'm using Marlin that I've been modifying to meet my needs, running on a Arduino mega with ramps 1.4.

I have been using 4 axis with 5 motors: X, Y, 2 motors in Z and a E axis por a pressing routine.

My goal now is to install an IR temperature sensor to read the values on the surface of the material and have live adjustment to the feedrate of X and Y to achieve a set temperature.

I couldn't find so far a straightforward manner to implement this, so I'm asking for your help for some options that I might have.

I have read, but couldn't find exactly how it works, That GRBL with arduino can be used t have real time feedrate change, but as far as I've seen it's not easy to have a 4th motor (now E axis), and also I understood that is used mainly in CNC so, it's not prepared to have temperature readings.

Any kind of suggestions or help is welcome so I can do more research.

Thank you and hope that you are all safe and healthy.