Position

Description

This object is being used to determine the position of a joystick by considering the X-Axis and Y-Axis.

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


App Builder Object


Source Code

function execute() { const x = inPorts[0].value; const y = inPorts[1].value; switch (trigger) { case TRIGGERS.SYSTEM_SYNC: { context.blocked = false; break; } case 0: { if (!context.blocked) { context.blocked = true; syncSleep(1000); if (x === 0) { return [false, false, true, false, false]; } if (x === 4095) { return [false, false, false, true, false]; } if (y === 0) { return [true, false, false, false, false]; } if (y === 4095) { return [false, true, false, false, false]; } return [false, false, false, false, true]; } break; } case 1: { if (!context.blocked) { context.blocked = true; syncSleep(1000); if (x === 0) { return [false, false, true, false, false]; } if (x === 4095) { return [false, false, false, true, false]; } if (y === 0) { return [true, false, false, false, false]; } if (y === 4095) { return [false, true, false, false, false]; } return [false, false, false, false, true]; } break; } default: break; } return []; }

Examples

Example

X-Axis

Y-Axis

Up

Down

Left

Right

Stop

Example

X-Axis

Y-Axis

Up

Down

Left

Right

Stop

1

4095

2048

false

false

false

true

false

2

2048

4095

false

true

false

false

false

3

2048

2048

false

false

false

false

true


In Ports

Position

Name

Message Type

Description

Position

Name

Message Type

Description

1

X-Axis

Analog

This port is being used to set the X-Axis of the 'Position' object.

2

Y-Axis

Analog

This port is being used to set the Y-Axis of the 'Position' object.


Out Ports

Position

Name

Message Type

Description

Position

Name

Message Type

Description

1

Up

Digital

This port is being used to sent out if the position is up.

2

Down

Digital

This port is being used to sent out if the position is down.

3

Left

Digital

This port is being used to sent out if the position is left.

4

Right

Digital

This port is being used to sent out if the position is right.

5

Stop

Digital

This port is being used to sent out if there is no position.


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