Hi Sam @SLin.1 ,
you could try to exploit a combination of the Activity/inactivity function and the Stationary/motion-detection function described in the datasheet p.17 and in the application note p.34.
You can first configure the stationary/motion function:
The Android stationary/motion detection function only recognizes the device’s sleep state [it doesn't change the device configuration after the condition detection]. When the Android stationary/motion-detection function is activated by setting the STATIONARY bit in WAKE_UP_DUR (35h), the LIS2DW12 detects acceleration below a fixed threshold but does not change either ODR or operating mode (High-Performance mode or Low-Power mode) after sleep state detection. The Activity/Inactivity recognition function can use the high-pass filter or the offset outputs, this choice can be made through the USR_OFF_ON_OUT bit in CTRL7 (3Fh).
Once you get the stationary/motion interrupt, you can set the activity/inactivity function to enter the low power mode (that you can configure) and to enable the device for a potential future wake-up:
When the activity/inactivity function is activated by setting the INTERRUPTS_ENABLE bit in CTRL7 (3Fh) and the SLEEP_ON bit in WAKE_UP_THS (34h), the LIS2DW12 automatically goes to 12.5 Hz ODR in the low-power mode previously selected by the LP_MODE[1:0] bits in CTRL1 (20h) if the sleep state condition is detected and wakes up as soon as the interrupt event has been detected, increasing the output data rate and bandwidth. With this feature the system may be efficiently switched from low-power mode to full performance depending on user-selectable positioning and acceleration events, thus ensuring power saving and flexibility.
You can find two C sample codes on Github for setting these configurations, and you could build a custom code combining the two:
If this answer helped you, please select this as best.
-Eleon