# import time
from time import sleep, ticks_ms, ticks_diff
def nonblocking_delay_passed(delay_ms=1000, delay_index=0):
global time_stamp
if ticks_diff(ticks_ms(), time_stamp[delay_index]) > delay_ms:
time_stamp[delay_index] = ticks_ms()
return True
return False
DELAY_2 = 2000 #ms
DELAY_5 = 7000 #ms
time_stamp = [ticks_ms()] * 10 #huidige tijd
while True:
if nonblocking_delay_passed(DELAY_2, 0):
print(f"Delay {DELAY_2} ms.")
if nonblocking_delay_passed(DELAY_5, 1):
print(f"Delay {DELAY_5} ms.")