[SOLVED]
Here is my solution, using ONLY wasPressed and wasReleased events :)
from time import ticks_ms
ms_down = 0; ms_up = 0; ms_last_up = ticks_ms()
click_timer = Timer(0)
def btnA_wasPressed_event(state):
global ms_down
ms_down = ticks_ms()
click_timer.init(period=250, mode=Timer.ONE_SHOT, callback=btnA_longclick)
def btnA_wasReleased_event(state):
global ms_up, ms_last_up
click_timer.deinit()
ms_up = ticks_ms(); click_length = ms_up - ms_down
click_delay = ms_up - ms_last_up; ms_last_up = ms_up
if (click_delay < 250):
ms_last_up = 0
btnA_doubleclick()
elif (click_length < 250):
click_timer.init(period=250, mode=Timer.ONE_SHOT, callback=btnA_simpleclick)
With the functions here :
def btnA_simpleclick(timer):
pass
def btnA_doubleclick():
pass
def btnA_longclick(timer):
click_timer.init(period=250, mode=Timer.ONE_SHOT, callback=btnA_longclick)
pass