Help optimizing a function

I haven't read everything here but I spotted this line in your code

if(millis() == thermocouple.timeout)

That is not the correct way to use millis() for 2 reasons.

First millis() does not return every successive value so it might never actually equal the timeout value - you should use >=

Second, the code will fail gloriously when millis() rolls over to 0.

Your test should be "millis() - prevMillis >= interval"

You need to post the entire code rather than little pieces that have no context. If it's a large program perhaps you can write a short sketch that illustrates the problem.

...R