arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Object «gamepad»

circle-info

This article is automatically translated from Russian by Google Translator.

Serves to work with the programmable control panel "TRIK Gamepad".

Method

Description

hashtag
button

Sent when the user has pressed one of the five buttons at the bottom of the remote control.

hashtag
buttonWasPressed

Returns true if a button with the specified number was pressed on the remote control. Resets the memorized press for this button.

hashtag
Syntax

As a parameter, you must specify the number of the button - from 1 to 5.

hashtag
Example

hashtag
connected

Sent when the remote control is connected to the robot.

hashtag
disconnect

It is sent when the remote control is turned off.

hashtag
isPadPressed

Returns whether the control area on the remote control is currently pressed. The control areas are numbered 0 and 1.

hashtag
Syntax

As a parameter, you must specify the number of the control area - 0 or 1.

hashtag
Example

hashtag
pad

Sent when the user taps or moves their finger over the control area on the remote.

hashtag
padX

If the specified control area on the remote is pressed, returns the current x-coordinate of the press.

hashtag
Syntax

As a parameter, you must specify the number of the padId control area.

hashtag
padY

If the specified control area on the remote is pressed, returns the current y-coordinate of the press.

hashtag
Syntax

As a parameter, you must specify the number of the padId control area.

hashtag
padUp

Sent when the user moves his finger away from the control area with the specified number.

hashtag
Syntax

Parameters:

  • padId — control area number.

  • x, y — the coordinates of the last known click from -100 to 100. The coordinate (-100, -100) corresponds to the upper left corner of the control area.

hashtag
reset

Resets the memorized events from the remote control.

hashtag
Syntax

hashtag
wheel

If "steering" (events from the device's accelerometer) is enabled on the remote control, it returns the current remote control tilt.

Tilt is coded from -100 to 100, with -100 being the leftmost "rudder" position and 100 being the rightmost position.

hashtag
Syntax

hashtag
wheelEvent

Sent when the remote control has the "steering wheel" (events from the device's accelerometer) on and the user has turned the device.

hashtag
Syntax

As a parameter it is necessary to specify a number from -100 to 100, -100 corresponds to the leftmost position of the "rudder", 100 - to the rightmost position.

Returns true if a button with the specified number was pressed on the remote control.

isPadPressed

Returns whether the control area on the remote control is currently pressed.

padX

If the specified control area on the remote is pressed, returns the current x-coordinate of the press.

padY

If the specified control area on the remote is pressed, returns the current y-coordinate of the press.

padUp

Sent when the user moves his finger away from the control area with the specified number.

reset

Resets the memorized events from the remote control.

wheel

If "steering" (events from the device's accelerometer) is enabled on the remote control, it returns the current remote control tilt.

wheelEvent

Sent when the remote control has the "steering wheel" (events from the device's accelerometer) on and the user has turned the device.

Signal

Description

button

Sent when the user has pressed one of the five buttons at the bottom of the remote control.

connected

Sent when the remote control is connected to the robot.

disconnect

It is sent when the remote control is turned off.

pad

Sent when the user taps or moves their finger over the control area on the remote.

buttonWasPressed
gamepad.buttonWasPressed(buttonNumber);
gamepad.buttonWasPressed(buttonNumber);
gamepad.buttonWasPressed(5);
gamepad.buttonWasPressed(5);
gamepad.isPadPressed(padId);
gamepad.isPadPressed(padId);
gamepad.isPadPressed(1);
gamepad.isPadPressed(1);
gamepad.padX(padId);
gamepad.padX(padId);
gamepad.padY(padId);
gamepad.padY(padId);
gamepad.padUp.connect( function(padId, x, y) { brick.stop(); });
gamepad.padUp.connect(lambda padId, x, y: brick.stop());
gamepad.reset();
gamepad.reset();
gamepad.wheel();
gamepad.wheel();
gamepad.wheelEvent.connect( function(percent) { brick.motor("E1").setPower(percent); });
gamepad.wheelEvent.connect(lambda percent: brick.motor("E1").setPower(percent));