This function block returns the ID of a pressed configurable button on an NMP.
Note that the ID is only valid after an "NMP Button Pressed" event is raised; the event will be removed when this function block is called.
Input:
None.
Output:
id : INT
The ID of the pressed button.
ready : BOOL
TRUE:
|
If data is ready.
|
FALSE:
|
If data is not ready.
|
Declaration:
FUNCTION_BLOCK nmpButtonPressedReceive;
VAR_OUTPUT
id : INT;
ready : BOOL;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR
buttonPress : nmpButtonPressedReceive;
END_VAR;
FUNCTION ButtonPressed;
buttonPress();
IF buttonPress.ready THEN
DebugMsg(message := "*** Button Pressed ***");
DebugFmt(message := "-button=\1", v1 := buttonPress.id);
END_IF;
END_FUNCTION;
THREAD_BLOCK navMonitor;
VAR
event : INT := 0;
END_VAR;
WHILE event <> -1 DO
event := navWaitEvent(timeout := -1);
CASE event OF
...
11: ButtonPressed();
...
END_CASE;
END_WHILE;
END_THREAD_BLOCK;
|