Configuration

This is the default configuration of the middleware. When any of the settings shall be modified, it shall be done in dedicated application config lwbtn_opts.h file.

Note

Check Getting started for guidelines on how to create and use configuration file.

group LWBTN_OPT

Default configuration setup.

LWBTN_CFG_GET_STATE_MODE_GROUP

Get button state options

Configuration option for LWBTN_CFG_GET_STATE_MODE configuration

LWBTN_GET_STATE_MODE_CALLBACK 0

Callback-only state mode

LWBTN_GET_STATE_MODE_MANUAL 1

Manual-only state mode

LWBTN_GET_STATE_MODE_CALLBACK_OR_MANUAL 2

Callback or manual state mode

Defines

LWBTN_MEMSET(dst, val, len) memset((dst), (val), (len))

Memory set function.

Note

Function footprint is the same as memset

LWBTN_MEMCPY(dst, src, len) memcpy((dst), (src), (len))

Memory copy function.

Note

Function footprint is the same as memcpy

LWBTN_CFG_USE_KEEPALIVE 1

Enables 1 or disables 0 periodic keep alive events.

Keep alive events are periodically sent to the application, when input is kept in active state.s

Default keep alive period is set with LWBTN_CFG_TIME_KEEPALIVE_PERIOD macro

LWBTN_CFG_TIME_DEBOUNCE_PRESS 20

Minimum debounce time for press event in units of milliseconds.

This is the time when the input shall have stable active level to detect valid onpress event.

When value is set to > 0, input must be in active state for at least minimum milliseconds time, before valid onpress event is detected.

To be safe not using this feature, external logic must ensure stable transition at input level.

Note

If value is set to 0, debounce is not used and press event will be triggered immediately when input states goes to inactive state.

LWBTN_CFG_TIME_DEBOUNCE_PRESS_DYNAMIC 0

Enables 1 or disables 0 dynamic settable time debounce.

When enabled, additional field is added to button structure to allow each button setting its very own debounce time for press event.

If not used, LWBTN_CFG_TIME_DEBOUNCE_PRESS is used as default debouncing configuration

LWBTN_CFG_TIME_DEBOUNCE_RELEASE 0

Minimum debounce time for release event in units of milliseconds.

This is the time when the input shall have minimum stable released level to detect valid onrelease event.

This setting can be useful if application wants to protect against unwanted glitches on the line when input is considered “active”.

When value is set to > 0, input must be in inactive low for at least minimum milliseconds time, before valid onrelease event is detected

Note

If value is set to 0, debounce is not used and release event will be triggered immediately when input states goes to inactive state

LWBTN_CFG_TIME_DEBOUNCE_RELEASE_DYNAMIC 0

Enables 1 or disables 0 dynamic settable time debounce for release event.

When enabled, additional field is added to button structure to allow each button setting its very own debounce time for release event.

If not used, LWBTN_CFG_TIME_DEBOUNCE_RELEASE is used as default debouncing configuration

LWBTN_CFG_TIME_CLICK_MIN 20

Minimum active input time for valid click event, in milliseconds.

Input shall be in active state (after debounce) at least this amount of time to even consider the potential valid click event. Set the value to 0 to disable this feature

LWBTN_CFG_TIME_CLICK_MIN_DYNAMIC 0

Enables 1 or disables 0 dynamic settable min time for click.

When enabled, additional field is added to button structure, allowing application to manually set min pressed time for click for each button instance. Default value is set to LWBTN_CFG_TIME_CLICK_MIN

LWBTN_CFG_TIME_CLICK_MAX 300

Maximum active input time for valid click event, in milliseconds.

Input shall be pressed at most this amount of time to still trigger valid click. Set to -1 to allow any time triggering click event.

When input is active for more than the configured time, click even is not detected and is ignored.

LWBTN_CFG_TIME_CLICK_MAX_DYNAMIC 0

Enables 1 or disables 0 dynamic settable max time for click.

When enabled, additional field is added to button structure, allowing application to manually set max pressed time for click for each button instance. Default value is set to LWBTN_CFG_TIME_CLICK_MAX

LWBTN_CFG_TIME_CLICK_MULTI_MAX 400

Maximum allowed time between last on-release and next valid on-press, to still allow multi-click events, in milliseconds.

This value is also used as a timeout length to send the onclick event to application from previously detected valid click events.

If application relies on multi consecutive clicks, this is the max time to allow user to trigger potential new click, or structure will get reset (before sent to user if any clicks have been detected so far)

LWBTN_CFG_TIME_CLICK_MULTI_MAX_DYNAMIC 0

Enables 1 or disables 0 dynamic settable max time for multi click.

When enabled, additional field is added to button structure, allowing application to manually set max time for multi click for each button instance. Default value is set to LWBTN_CFG_TIME_CLICK_MULTI_MAX

LWBTN_CFG_CLICK_MAX_CONSECUTIVE 3

Maximum number of allowed consecutive click events, before structure gets reset to default value.

Note

When consecutive value is reached, application will get notification of clicks. This can be executed immediately after last click has been detected, or after standard timeout (unless next on-press has already been detected, then it is send to application just before valid next press event). Configuration can be changed with LWBTN_CFG_CLICK_MAX_CONSECUTIVE_SEND_IMMEDIATELY macro

LWBTN_CFG_CLICK_MAX_CONSECUTIVE_DYNAMIC 0

Enables 1 or disables 0 dynamic settable max consecutive clicks.

When enabled, additional field is added to button structure, allowing application to manually set max consecutive clicks for each button instance. Default value is set to LWBTN_CFG_CLICK_MAX_CONSECUTIVE

LWBTN_CFG_TIME_KEEPALIVE_PERIOD 100

Keep-alive event period, in milliseconds.

When input is active, keep alive events will be sent through this period of time. First keep alive will be sent LWBTN_CFG_TIME_KEEPALIVE_PERIOD ms after input being considered active.

LWBTN_CFG_TIME_KEEPALIVE_PERIOD_DYNAMIC 0

Enables 1 or disables 0 dynamic settable keep alive period.

When enabled, additional field is added to button structure, allowing application to manually set keep alive period for each button instance. Default value is set to LWBTN_CFG_TIME_KEEPALIVE_PERIOD

LWBTN_CFG_CLICK_MAX_CONSECUTIVE_SEND_IMMEDIATELY 1

Enables 1 or disables 0 immediate onclick event after on-release event, if number of consecutive clicks reaches max value.

When this mode is disabled, onclick is sent in one of 2 cases:

  • An on-click timeout occurred

  • Next on-press event occurred before timeout expired

LWBTN_CFG_GET_STATE_MODE LWBTN_GET_STATE_MODE_CALLBACK

Sets the mode how new button state is acquired.

Different modes are availale, set with the level number:

  • LWBTN_GET_STATE_MODE_CALLBACK: State of the button is checked through get state callback function

  • LWBTN_GET_STATE_MODE_MANUAL: Only manual state set is enabled. Application must set the button state with API functions. Callback API is not used.

  • LWBTN_GET_STATE_MODE_CALLBACK_OR_MANUAL: State of the button is checked through get state callback function (by default). It enables API to manually set the state with approapriate function call. Button state is checked with the callback at least until manual state API function is called.

    This allows multiple build configurations for various button types

LWBTN_CFG_CLICK_CONSECUTIVE_KEEP_AFTER_SHORT_PRESS 0

Enables 1 or disables 0 keeping the consecutive click event group if last sequence of onpress and onrelease was too short.