I want to use a push-button to activate a feature but only after it has been pressed for x amount of seconds. to prevent accidental bumps etc.
I've tried using the time.ticks_ms() but I can for the life of me get it to work.
heres a snip of the code:
Code: Select all
def manual_set_mode():
global clock_set_mode
global ts
if btn0.value() == 0:
btn0_press_time = time.ticks_ms()
if time.ticks_diff(time.ticks_ms, btn0_press_time) > 2000:
clock_set_mode = True
print('clock set mode true')
if clock_set_mode == True:
so here you can see I want to set clock_set_mode as True. only after the button has been pressed for 2 seconds... however, looking at how I've done it, it will turn Tre regardless of whether I let go of the button within that 2 second period.
If you can help that would be greatly appreciated.
Ollie