Different types of buttons presses are quite well described In the building_common.lib documentation. I will try to make it even simpler:
Each input can, besides detecting simple switching, be bound to a function block detecting for example a double click or differentiating long and short presses. As a result one 4-button wall switch can execute 8 commands: 2 for each button.
In my installation I use the detection of short/long presses to launch complex task like closing all blinds or turning the power sockets and network off (“I go to bed”). Launching them with a regular button (short press) could be accidental. Guest do visit your home and not knowing what is what they press and test everything. To avoid ‘accidents’ I bind complex task to long button presses. For example:
A short pres switches the light (a regular thing….)
A long, 2-second press launches a complex function.
Detecting short/long clicks
In definitions:
SWITCH_IN1 : FbShortLong;
In the program:
SWITCH_IN1(xSwitch:=IN1, uiTS_10tel_s:=1, uiTS_10tel_s:=1, uiT_10tel_s :=20);
Where:
IN1- input connected to the button
uiTS_10tel_s – defines the length of the impulse after SHORT press
uiTL_10tel_s – defines the length of the impulse after the LONG press
uiT_10tel_s – time of a short press; In the ex ample above every press longer than 2 seconds will be considered as LONG.
The distinction of press type is executed by returning output variables xShort and xLong (i.e. SWITCH_IN1.xShort, SWITCH_IN1.xLong).
Detecting double clicks
In definitions:
SWITCH_IN2 : FbClick;
In the program:
SWITHCH_IN2(xSwitch:=IN2, uiT_10tel_s:=10);
Where :
IN2 – input connected to the button
uiT_10tel_s – time span of awaiting for the double click. In the example above if two clicks happen during 1 second the output variable .xDouble will be set to TRUE for one program cycle.
I personally do not use the detection of a double click – the short/long detection is much more natural to me.