Simple sequence detection library for Arduino
This library allows you to create and detect a sequence (pattern) of event series following by different intervals.
For example, this could be used for a door lock which can be opended by knocking it with a certain sequence.
In this case, each 'knock' called 'trigger'.
The speed of the sequence is not significant, only order does. This means the intervals between triggers can be as short as 10 msec (default interval resoltion) and as long until timeout (2 seconds by default).
Example
You create a following pattern with error tolerance of 10 % (in milliseconds):[ 500 ±50, 250 ±25, 100 ±10, 250 ±25) ]
and this will also match the following one: [ 250 ±25, 125 ±12, 50 ±5, 125 ±12 ]
(for 2x speed), as well as: [ 1000 ±10, 500 ±50, 200 ±20, 500 ±50 ]
(for 0.5x speed) - A callback function can be assigned for each event (match, error, end of recording etc.)
- Detection based on relative difference between intervals, not absolute value
- Configurable timeout and % of allowed timing error (tolerance)
- Pattern can be recorded, stored and loaded from EEPROM
By default, the maximum pattern size is 32, but it can be changed inside PatternSwitch.h