This sets the vibration sensor sensitivity (please see the RTCU technical manual for support of the vibration sensor). With this function, the sensitivity of the vibration sensor can be set. The RTCU does not remember the value over a reset or PowerDown, and it must at least be set during program initialization.
Input:
sen : SINT (0..100) (default: 50)
The level of sensitivity. 100 is most sensitive. 0 (zero) disables vibration detection.
Returns: INT
0
|
- Success.
|
1
|
- Invalid value.
|
Declaration:
FUNCTION pmSetVibrationSensivity : INT;
VAR_INPUT
sen : SINT := 50;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR_INPUT
sw : BOOL;
END_VAR;
PROGRAM test;
VAR
sms : gsmIncomingSMS;
writer : logWrite;
tmp : INT;
sen : INT := 50;
END_VAR;
pmSetVibrationSensivity(sen:=100);
gsmPower(power:=ON);
gprsOpen();
IF NOT logIsInitialized(key:=4711) THEN
logInitialize(key:=4711, numlogvalues:=2, numlogrecords:=3000);
END_IF;
DebugMsg(message:="Running...");
BEGIN
IF sw THEN
sms();
IF sms.status > 0 THEN
tmp := strToInt(str:=sms.message);
IF tmp > 0 AND tmp < 101 THEN
IF pmSetVibrationSensivity(sen:=SINT(tmp)) = 0 THEN
sen := tmp;
DebugFmt(message:="Vibration sensivity: \1",v1:=sen);
END_IF;
END_IF;
END_IF;
ELSE
tmp := pmWaitEvent(Vibration:=TRUE,time:=10);
IF tmp <> 8 THEN
writer(tag:=1, value[1]:=sen, value[2]:=tmp);
END_IF;
END_IF;
END;
END_PROGRAM;
|