FSM#12: How to… test your FSM: GLANCE detection (both axl and gyro), further algorithm examples
This example describes how to set up a finite state machine to enable the built-in detection of a GLANCE action along x-axis. The picture here below shows the steps of the dedicated FSM. This code shows you also how to use the gyro data for a complete and more accurate pattern recognition. GLANCE FSM allows you to check when a glance event occurs. The code is quite longer than the previous examples because the glance gesture is more complex than e.g. a simple motion or a free fall action. In attachment you can find the state machine code to upload on your Unico tool.
Input data are both the axl and the gyro output streams (select ODR >= 26Hz)
Masks selects as interesting orientation the x axis value on positive direction (MASK_A=0x80), the y axis value on positive direction (MASK_B=0x20), and the z axis value on positive direction (MASK_C=0x08),
Thresholds are set to 0.5g (TH1) and 0.1g (TH2)
Timeout have been selected and tuned as 400ms and 120ms (T3 and T4)
Output is an interrupt when a glance gesture is detected.

Enjoy!
