Configure the system to wake from suspend on detection of vibration. See pmSuspend.
Note:
The Motion Sensor interface must be opened with msOpen before calling this function.
To wake on vibration without calling msOpen, see accVibrationSetWakeup.
All of the motion sensors must be disabled to be able to wake on vibration, see msAccEnable, msAccEnable and msMagEnable.
pmSuspend return codes for this wake-up source:
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 is to use the sensitivity used in normal operation. See pmSetVibrationSensivity
|
To use vibration as a wake-up source, the sensitivity must not be 0.
Returns: INT
1
|
- Success.
|
0
|
- This function is not supported.
|
-1
|
- Interface is not open. Call msOpen first.
|
-2
|
- Generic error.
|
-3
|
- Invalid input configuration.
|
-9
|
- Logger is active.
|
-14
|
- Accelerometer, gyroscope or magnetometer is active.
|
Declaration
FUNCTION msVibrationSetWakeup : INT;
VAR_INPUT
Enable : BOOL;
Sensitivity : SINT := -1;
END_VAR;
Example:
INCLUDE rtcu.inc
PROGRAM test;
VAR
wk : DINT;
END_VAR;
...
msOpen();
...
msVibrationSetWakeup(sensitivity := 80, enable := ON);
...
wk := pmSuspend(time:=600, mode := 0);
...
msClose();
...
BEGIN
END;
END_PROGRAM;
|