Skip to content

click-analyzer

Description

The click-analyzer block is used to analyze a logical signal representing the state of a button or another two-state input. It recognizes the moment of pressing, long pressing, and releasing the button and exposes these events on separate outputs.

The block has one input and six outputs. It does not require the use of inputs labeled with the tag block.

Configuration parameters

Parameter name Value
time_limit Required parameter that defines the long-press threshold in milliseconds. It must be a positive integer greater than zero. If the button stays in the true state for at least this long, the block reports a long press.

Input handling

The block requires at least one input connection. If the input is not connected to anything during initialization, the block enters the Input disconnected. error state.

The block supports only values that can be interpreted as logical true or false. Values that cannot be read as a logical state are ignored.

Detailed behavior:

  • a false -> true change is treated as a press and immediately triggers the press output
  • the time_limit timer starts when the press is detected
  • if the input remains in the true state for at least time_limit, the block triggers the long-press output once
  • a true -> false change is treated as a release and always triggers the release output
  • if the release happens before time_limit elapses, the block additionally triggers the short-release output
  • if the release happens after time_limit elapses, the block additionally triggers the long-release output
  • receiving the same value as before is ignored, so the block reacts only to an actual state change
  • while the button remains pressed after a long press has been detected, the long-press signal is generated only once; continuing to hold the button does not generate additional pulses
  • the last output of the block always reflects the current input state as a logical value

Block outputs

Output number and name Output description
1. Press. A short logical pulse false -> true -> false generated when the input changes from false to true.
2. Long press. A short logical pulse false -> true -> false generated after time_limit has elapsed if the input is still in the true state.
3. Release. A short logical pulse false -> true -> false generated when the input changes from true to false.
4. Short release. A short logical pulse false -> true -> false generated when the button is released before time_limit elapses.
5. Long release. A short logical pulse false -> true -> false generated when the button is released after time_limit elapses.
6. Current input state. The current logical value of the input. This output emits true when the input is active and false when the input is inactive.

Block status description

The description shown under the block reflects the last recognized state:

  • ready means the initial state after successful initialization
  • pressed means the input is currently in the true state
  • released (short) means the last release happened before time_limit elapsed
  • released (long) means the last release happened after time_limit elapsed

Errors returned by the block

The block may return the following errors:

Error code Error description
Invalid time_limit. The time_limit parameter is missing, is not a valid integer, or has a value less than or equal to zero.
Input disconnected. No other block is connected to the block input.

Examples

  • If time_limit = 500, then an input change false -> true followed by true -> false after 200 ms triggers the outputs: Press, Release, and Short release.
  • If time_limit = 500, then an input change false -> true, keeping the state for 700 ms, and only then changing true -> false triggers the outputs: Press, Long press, Release, and Long release.
  • If the input remains in the true state longer than time_limit, the Long press output is generated only once.
  • If the block receives true and then receives true again without an earlier false, the second event is ignored.