Configure the system to wake from suspend on detection of vibration. See pmSuspend.
pmSuspend return codes for this wake-up source (shared with msVibrationSetWakeup ):
Error
|
Type
|
Value
|
Description
|
False
|
4
|
1
|
Vibration has woken up the system.
|
True
|
4
|
-10
|
Sensitivity is 0.
|
True
|
4
|
-11
|
Accelerometer is open, preventing vibration from working.
Call accClose to close it.
|
True
|
4
|
-12
|
MS is open and accelerometer, gyroscope or magnetometer is active.
|
Input:
Enable : BOOL
Controls if enabling or disabling wake-up on vibration.
Sensitivity : SINT (-1..100, default -1)
The sensitivity level of the vibration detection.
|
0 is no vibration detection, 100 is most sensitive.
|
|
-1 will use the sensitivity used under normal operation. See pmSetVibrationSensivity
|
To use vibration as a wake-up source, the sensitivity must not be 0.
Returns: INT
0
|
- Success or this function is not supported.
|
-1
|
- Sensitivity is outside the valid range.
|
Declaration
FUNCTION accVibrationSetWakeup : INT;
VAR_INPUT
Enable : BOOL;
Sensitivity : SINT := -1;
END_VAR;
Example:
INCLUDE rtcu.inc
PROGRAM test;
VAR
wk : DINT;
END_VAR;
...
accVibrationSetWakeup(sensitivity := 80, enable := ON);
...
wk := pmSuspend(time:=600, mode := 0);
...
BEGIN
END;
END_PROGRAM;
|