This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Determine short/long pushbutton press from script
#1
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:

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
Reply


Messages In This Thread
Determine short/long pushbutton press from script - by edgars - 05.10.2015, 08:37

Forum Jump: