Hello,
I have a ping_sensor() function that reads data from a sensor and I need to use imp.sleep every time I ping the sensor.
function ping_sensor()
{
…
trigPin.write(0);
imp.sleep(0.01);
trigPin.write(1);
…
}
Then I have an imp.onidle function that is activated by any imp.sleep call, but I also have an imp.sleep call in my loop function that will trigger a call to imp.onidle. I only want the imp.onidle function to be called from the loop function, not from the ping_sensor() function. Is there a way to accomplish that?
function loop()
{
// Doing something…
imp.sleep(1);
}
imp.onidle(function() {
loop();
server.sleepfor(3600);
});
Thank you