Press and Hold

Description

This object is being used to discover whether the input was held over a given time or just pressed.

The objects will now stop running once input parameters are changed.


App Builder Object


Source Code

 

function execute() { switch (trigger) { case TRIGGERS.SYSTEM_ASYNC: context.state = false; return [null, new Date()]; case 0: if (inPorts[0].value === true) { context.state = true; const holdTime = inPorts[1].value; cancelSleep(); sleep(holdTime, false); } if (inPorts[0].value === false && context.state) { cancelSleep(); context.state = false; return [new Date(), null]; } break; default: break; } return []; }

Examples

Example

Time

Button pressed for

Trigger

Example

Time

Button pressed for

Trigger

1

5 s

3 s

Press

2

5 s

5 s

Hold

3

3 s

1 s

Press


In Ports

Position

Name

Message Type

Description

Position

Name

Message Type

Description

1

In

Digital

This port is being used to set the digital state of the 'Press & Hold' on the Dashboard.

2

Time

Number

This is being used to get a time for the 'Press & Hold' object.


Out Ports

Position

Name

Message Type

Description

Position

Name

Message Type

Description

1

Press

Trigger

This port is triggered if the digital input is not pressed for as long as the input time.

2

Hold

Trigger

This port is triggered if the digital input is pressed for as long as the input time.


Properties

Name

Description

Name

Description

Object Name

The name on the object on the canvas.

Show Code View

The switch to turn on code view for the Code Object

Duplicate Code into custom Code Object