05.10.2015, 08:37
In case a pushbutton doesn't have a long press feature or you need to be more flexible with long press time, here is a script which will do the job.
In the settings specify "Send 1" on rising edge, "Send 0" on falling edge. And add the following event-based script:
In the settings specify "Send 1" on rising edge, "Send 0" on falling edge. And add the following event-based script:
Code:
resolution = 0.25 -- short press check resolution
longpress = 5 -- long press time in seconds
value = event.getvalue()
if value then
timeout = longpress / resolution
-- wait for timeout or OFF signal
while timeout > 0 do
os.sleep(resolution)
timeout = timeout - 1
value = grp.getvalue(event.dst)
if not value then
break
end
end
if timeout > 0 then
alert('short press')
else
alert('long press')
end
end