Implementing keypad multi-click events/triggers

Posted on
Sun Dec 01, 2019 9:41 pm
FlyingDiver offline
User avatar
Posts: 7265
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Implementing keypad multi-click events/triggers

I'm working on some major upgrades to the Lutron plugin. One of the open feature requests is a different way to handle double/triple button clicks.

The way it works now is pretty simplistic. The plugin keeps track of the last button press detected with a timestamp. When a button press message is received, any single-click triggers are executed. If the same button press is received within a timeout (currently hard-coded at 1 second), then a "click count" is incremented and any matching triggers (double or triple clicks) are executed. Which means if the same button is pressed three times, each press no more than 1 second after the last, then all three triggers will execute. This is fine for "cumulative" type actions, like adding more lights or making them brighter. Not so good if you want to do totally different actions based on the number of clicks.

It was done that way to eliminate any "timeout" delays. That is, a long delay after a button press before the first ("single press") trigger fires. Using the current time-out, it would be a full second (or longer) before an event would be triggered.

I've been trying to come up with a good way to implement non-overlapping triggers. That is, an "only one" trigger, and "only two" trigger, and so on. And what the appropriate time-out would be. It's got to be long enough that it's a comfortable to press the button, but not so long that it feels like an inordinate delay before execution. I've already re-worked major portions of the plugin to eliminate code paths with timeouts in them. I had to get rid of them anyway to support multiple "gateways" (which is what I'm calling RRA repeaters, Caseta bridges, etc).

Has anyone done anything like this in a different plugin?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Dec 01, 2019 11:02 pm
kw123 offline
User avatar
Posts: 8392
Joined: May 12, 2013
Location: Dallas, TX

Re: Implementing keypad multi-click events/triggers

There is

Single
Double
Long

press
In pibeacon actions It is executed directly on the rpi

As I recall it’s in action.py if you want to look.

Karl


Sent from my iPhone using Tapatalk

Posted on
Mon Dec 02, 2019 7:25 am
FlyingDiver offline
User avatar
Posts: 7265
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Implementing keypad multi-click events/triggers

Thanks, I'll take a look.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests