LIS3DH. Click
(lis3dh v0.1.0)
Copy Markdown
Encoding and decoding for the LIS3DH's click / double-click / tap detection engine.
Six per-axis enable bits in CLICK_CFG select which axes and click types
(single vs double) are armed. Timing is configured by three registers:
TIME_LIMIT— maximum pulse width for a click (must rise above the threshold and fall back within this window).TIME_LATENCY— dead time after a click during which another pulse is ignored.TIME_WINDOW— the additional window after the latency in which a second click is allowed (for double-click detection).
All three timing values are in 1/ODR units.
References: LIS3DH Datasheet DocID17530 Rev 2 §8.29 – §8.34.
Summary
Functions
Decode a CLICK_CFG byte into a list of enabled click_event/0.
Decode a CLICK_SRC byte into a map of its fields.
Encode a CLICK_CFG byte from a list of click_event/0 to enable.
Encode a CLICK_THS byte from a threshold in milli-g (using the same LSB
table as the inertial interrupt thresholds) and a latch-request flag.
Types
@type click_event() ::
:single_click_x
| :double_click_x
| :single_click_y
| :double_click_y
| :single_click_z
| :double_click_z
Per-axis / click-type enables for CLICK_CFG.
@type source_flags() :: %{ active: boolean(), double_click: boolean(), single_click: boolean(), sign: :positive | :negative, x: boolean(), y: boolean(), z: boolean() }
Decoded CLICK_SRC flags.
Functions
@spec decode_click_cfg(<<_::8>>) :: [click_event()]
Decode a CLICK_CFG byte into a list of enabled click_event/0.
@spec decode_click_src(<<_::8>>) :: source_flags()
Decode a CLICK_SRC byte into a map of its fields.
@spec encode_click_cfg([click_event()]) :: <<_::8>>
Encode a CLICK_CFG byte from a list of click_event/0 to enable.
@spec encode_click_ths!(non_neg_integer(), LIS3DH.Config.range(), boolean()) :: <<_::8>>
Encode a CLICK_THS byte from a threshold in milli-g (using the same LSB
table as the inertial interrupt thresholds) and a latch-request flag.