I have a function F1 that loops continuously (while loop). I have set a condition, if met, calls another function F2 inside function F1. Once called, the function F2 shouldn't be called again for a few seconds, say 3 secs, even if the condition is met again within 3 seconds. But function F1 has to be looping continuously. How do I achieve it?
Save time when you call F2 (say time_f2). Next time the condition is met, compare now with time_f2 and call F2 only if the difference is more than 3 seconds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With