nmpHardwareButtonPressedReceive (Functionblock)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

MX2i pro, CX1 pro/flex/warp, SX1, MX2 turbo, NX-200, NX-400, NX-900, LX2

Firmware version:

2.84 / 1.00.00

Nav. API level:

2


This function block returns the ID of a pressed hardware button on an NMP.

To enable this event, call nmpHardwareButtonsEnable.

Note that the ID is only valid after a "Hardware Button Pressed" event is raised; the event will be removed when this function block is called.

 

 

If hardware buttons are enabled, and the lcd backlight is set to level 0, any press on the touchscreen will be sent as button id 100, useful to e.g. wake the device from a screen saver mode.

 

Input:

None.

 

 

Output:

id : INT

The ID of the pressed button. Possible values:

1

- "1" button.

2

- "2" button.

3

- "3" button.

4

- "4" button.

10

- "SET" button.

11

- "Power" button.

100

- Touchscreen press (nmpLcdBrightness level 0)

 

ready : BOOL

TRUE:

If data is ready.

FALSE:

If data is not ready.

 

Declaration:

FUNCTION_BLOCK nmpHardwareButtonPressedReceive;
VAR_OUTPUT
  id   : INT;
  ready : BOOL;
END_VAR;

 

Example:

INCLUDE rtcu.inc
VAR
  hwButtonPress : nmpHardwareButtonPressedReceive;
END_VAR;
 
FUNCTION HwButtonPressed;
  hwButtonPress();
  IF hwButtonPress.ready THEN
    DebugMsg(message := "*** Hardware Button Pressed ***");
    DebugFmt(message := "-button=\1", v1 := hwButtonPress.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
     ...
    13: HwButtonPressed();
     ...
  END_CASE;
END_WHILE;
END_THREAD_BLOCK;