delay(1) falls in line with the
millis() test which won’t change for 1ms anyway. And don’t forget that, at best, the
loop() thread runs every millisecond. As @rickkas7, points out, both
os_thread_yeild() will allow other threads to run as the
while() runs. Either way,
loop() generally gets back control every ms or so.
The challenge is with your synchronous call of
Particle.function() where you call a function and expect to return a (delayed) value as a result.
Another approach might be to decouple the status from the
Particle.function() by having a
Particle.variable() to represent the status. You could even decouple further and set a flag in the
loop() picks up and runs a small FSM to do the
call_this_function(value), wait for the prescribed period and set the
Particle.variable() status variable accordingly. You get the idea.