P5tCube

p5.toioGlobalsP5tCube

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

+ new P5tCube(cube: CubeBase): P5tCube

Inherited from Cube.constructor

Defined in cube/cube.ts:39

Parameters:

NameType
cubeCubeBase

Returns: P5tCube

Properties

angle

angle: number | undefined = undefined

Inherited from Cube.angle

Defined in cube/cube.ts:32


batteryLevel

batteryLevel: number | undefined = undefined

Inherited from Cube.batteryLevel

Defined in cube/cube.ts:37


buttonPressed

buttonPressed: boolean | undefined = undefined

Inherited from Cube.buttonPressed

Defined in cube/cube.ts:36


Protected cube

cube: CubeBase | undefined = undefined

Inherited from Cube.cube

Defined in cube/cube.ts:39


flat

flat: boolean | undefined = undefined

Inherited from Cube.flat

Defined in cube/cube.ts:34


posture

posture: string | undefined = undefined

Inherited from Cube.posture

Defined in cube/cube.ts:35


sensorX

sensorX: number | undefined = undefined

Inherited from Cube.sensorX

Defined in cube/cube.ts:30


sensorY

sensorY: number | undefined = undefined

Inherited from Cube.sensorY

Defined in cube/cube.ts:31


standardId

standardId: string | undefined = undefined

Inherited from Cube.standardId

Defined in cube/cube.ts:33


x

x: number | undefined = undefined

Inherited from Cube.x

Defined in cube/cube.ts:28


y

y: number | undefined = undefined

Inherited from Cube.y

Defined in cube/cube.ts:29


Static angleTypeId

angleTypeId: object = CubeMotorChar.angleTypeId

Inherited from Cube.angleTypeId

Defined in cube/cube.ts:20

Type declaration:

  • absEfficient: 0 = 0

  • absNegativeDir: 2 = 2

  • absPositiveDir: 1 = 1

  • noRotate: 5 = 5

  • relNegativeDir: 4 = 4

  • relPositiveDir: 3 = 3

  • sameAsCurrent: 6 = 6


Static easeTypeId

easeTypeId: object = CubeMotorChar.easeTypeId

Inherited from Cube.easeTypeId

Defined in cube/cube.ts:19

Type declaration:

  • accel: 1 = 1

  • accelDecel: 3 = 3

  • constant: 0 = 0

  • decel: 2 = 2


Static moveTypeId

moveTypeId: object = CubeMotorChar.moveTypeId

Inherited from Cube.moveTypeId

Defined in cube/cube.ts:18

Type declaration:

  • efficient: 0 = 0

  • rotate1st: 2 = 2

  • withoutBack: 1 = 1


Static postureId

postureId: object = CubeSensorChar.postureId

Inherited from Cube.postureId

Defined in cube/cube.ts:17

Type declaration:

  • back: "back" = "back"

  • bottom: "bottom" = "bottom"

  • front: "front" = "front"

  • left: "left" = "left"

  • right: "right" = "right"

  • top: "top" = "top"


Static Readonly rotateTypeId

rotateTypeId: object = { efficient: 'efficient', clockwise: 'clockwise', counterClockwise: 'counterClockwise', } as const

Inherited from Cube.rotateTypeId

Defined in cube/cube.ts:22

Type declaration:

  • clockwise: "clockwise" = "clockwise"

  • counterClockwise: "counterClockwise" = "counterClockwise"

  • efficient: "efficient" = "efficient"


Static seId

seId: object = CubeSoundChar.seId

Inherited from Cube.seId

Defined in cube/cube.ts:16

Type declaration:

  • cancel: 2 = 2

  • cursor: 3 = 3

  • effect1: 9 = 9

  • effect2: 10 = 10

  • enter: 0 = 0

  • get1: 6 = 6

  • get2: 7 = 7

  • get3: 8 = 8

  • matIn: 4 = 4

  • matOut: 5 = 5

  • selected: 1 = 1

Methods

addEventListener

addEventListener(type: string, listener: CubeListner): void

Inherited from Cube.addEventListener

Defined in cube/cube.ts:94

Register callback from upper layer.

Parameters:

NameTypeDescription
typestringSupport following types. - 'buttonpress' - 'buttonrelease' - 'batterylevelchange' - 'sensorflat' - 'sensorcollision' - 'sensordoubletap' - 'sensorposturechange' - 'positionid' - 'standardid'
listenerCubeListner-

Returns: void


connect

connect(): Promise‹Cube

Inherited from Cube.connect

Defined in cube/cube.ts:51

Connect to the toio™Core Cube.

Returns: Promise‹Cube

Promise. resolve includes a Cube instance.


connectP5tCube

connectP5tCube(): Promise‹P5tCube

Defined in p5tCube.ts:12

Connect to the toio™Core Cube.

Returns: Promise‹P5tCube

Promise. resolve includes a P5tCube instance.


disconnect

disconnect(): void

Inherited from Cube.disconnect

Defined in cube/cube.ts:73

Disconnet from the toio™Core Cube.

Returns: void


distanceToCube

distanceToCube(cube: Cube): number

Inherited from Cube.distanceToCube

Defined in cube/cube.ts:625

Calculate distance from this Cube to the specified Cube.

Parameters:

NameTypeDescription
cubeCubeaim cube instance.

Returns: number

Distance from this Cube to the specified Cube.


distanceToXY

distanceToXY(x: number, y: number): number

Inherited from Cube.distanceToXY

Defined in cube/cube.ts:607

Calculate distance from this Cube to the specified coordinate.

Parameters:

NameTypeDescription
xnumberX value of the target coordinate.
ynumberY value of the target coordinate.

Returns: number

Distance from this Cube to the specified coordinate.


move

move(left: number, right: number, duration: number): void

Inherited from Cube.move

Defined in cube/cube.ts:392

Move with specified speed/time.

Parameters:

NameTypeDefaultDescription
leftnumber-Left motor speed. Negative value means back direction. -115 to -8, 8 to 115, and 0 integer value.
rightnumber-Right motor speed. Negative value means back direction. -115 to -8, 8 to 115, and 0 integer value.
durationnumber0Motor control duration in msec. 0-2550( 0: Eternally ).

Returns: void


moveTo

moveTo(aim: object, maxSpeed: number, moveType: 0, easeType: 0, timeout: number): void

Overrides Cube.moveTo

Defined in p5tCube.ts:74

Move to specified coordinate/angle.

Parameters:

aim: object

object including following properties. x, y: coordinate of aimed point. angle(Optional): Cube's angle at the goal point. angleType(Optional): angleTypeId value. See the spec

NameType
angle?undefined | number
angleType?undefined | number
xnumber
ynumber

maxSpeed: number

8 to 115, and 0 integer value.

Default value moveType: 0= CubeMotorChar.moveTypeId.efficient

(Optional)moveTypeId value. default is moveTypeId.efficient

Default value easeType: 0= CubeMotorChar.easeTypeId.constant

(Optional)easeTypeId value. default is easeTypeId.constant

Default value timeout: number= 5

(Optional)timeout in sec. default is 5 sec. 1-255 sec. 0 means exceptionally 10 sec.

Returns: void


moveToCube

moveToCube(cube: Cube, maxSpeed: number, moveType: 0, easeType: 0, timeout: number): void

Inherited from Cube.moveToCube

Defined in cube/cube.ts:470

Move to specified cube's position.

Parameters:

NameTypeDefaultDescription
cubeCube-aim cube instance.
maxSpeednumber-8 to 115, and 0 integer value.
moveType0CubeMotorChar.moveTypeId.efficient(Optional)moveTypeId value. default is moveTypeId.efficient
easeType0CubeMotorChar.easeTypeId.constant(Optional)easeTypeId value. default is easeTypeId.constant
timeoutnumber5(Optional)timeout in sec. default is 5 sec. 1-255 sec. 0 means exceptionally 10 sec.

Returns: void


moveToMulti

moveToMulti(aims: object[], maxSpeed: number, moveType: 0, easeType: 0, isAppend: boolean, timeout: number): void

Overrides Cube.moveToMulti

Defined in p5tCube.ts:99

Move to specified several coordinate/angle.

Parameters:

NameTypeDefaultDescription
aimsobject[]-object array each aim includes following properties. x, y: coordinate of aimed point. angle(Optional): Cube's angle at the goal point. angleType(Optional): angleTypeId value. See the spec
maxSpeednumber-8 to 115, and 0 integer value.
moveType0CubeMotorChar.moveTypeId.efficient(Optional)moveTypeId value. default is moveTypeId.efficient
easeType0CubeMotorChar.easeTypeId.constant(Optional)easeTypeId value. default is easeTypeId.constant
isAppendbooleanfalse(Optional)true: append to existing mutiple aim command. false: overwrite existing command.
timeoutnumber5(Optional)timeout in sec. default is 5 sec. 1-255 sec. 0 means exceptionally 10 sec.

Returns: void


Protected normalizeAngleDegrees

normalizeAngleDegrees(angle: number): number

Inherited from Cube.normalizeAngleDegrees

Defined in cube/cube.ts:683

Normalize the specified angle in Degrees within [0-360]

Parameters:

NameTypeDescription
anglenumberNormalization target angle.

Returns: number

Normalized angle in Degrees.


Protected normalizeAngleRadian

normalizeAngleRadian(angle: number): number

Inherited from Cube.normalizeAngleRadian

Defined in cube/cube.ts:701

Normalize the specified angle in Radian within [(-Math.PI)-Math.PI]

Parameters:

NameTypeDescription
anglenumberNormalization target angle.

Returns: number

Normalized angle in Radian.


Protected onPositionIdChanged

onPositionIdChanged(info: positionIdInfo): void

Overrides Cube.onPositionIdChanged

Defined in p5tCube.ts:29

For prepared callback function cubePositionIdChanged.

Parameters:

NameType
infopositionIdInfo

Returns: void


Protected onStandardIdChanged

onStandardIdChanged(info: standardIdInfo): void

Overrides Cube.onStandardIdChanged

Defined in p5tCube.ts:39

For prepared callback function cubeStandardIdChanged.

Parameters:

NameType
infostandardIdInfo

Returns: void


playMelody

playMelody(melody: object[]): void

Inherited from Cube.playMelody

Defined in cube/cube.ts:373

Play melody specified wiht MIDI note sequence.

Parameters:

NameTypeDescription
melodyobject[]An array composed of some combinations of note and duration values. Use like below. playMelody( [ { note: 0x50, duration: 0x1E }, { note: 0x52, duration: 0x1E }, { note: 0x54, duration: 0x1E } ] ); Refer to the instruction of playSingleNote() for note/duration.

Returns: void


playSE

playSE(idSE: number): void

Inherited from Cube.playSE

Defined in cube/cube.ts:345

Play pre-installed sound effect.

Parameters:

NameTypeDescription
idSEnumberSounde effect index value. Please make use of static seId.xxx properties in this class.

Returns: void


playSingleNote

playSingleNote(note: number, duration: number): void

Inherited from Cube.playSingleNote

Defined in cube/cube.ts:356

Play single MIDI note.

Parameters:

NameTypeDefaultDescription
notenumber-MIDI note number 0-128. 128 is a special value for no-sound. Refer toio™Core Cube Spec: Note number and note name.
durationnumber30Sound duration in msec. 0-2550( 0: Eternally ).

Returns: void


relativeAngleToXY

relativeAngleToXY(x: number, y: number): number

Inherited from Cube.relativeAngleToXY

Defined in cube/cube.ts:642

Calculate relative angle from this Cube to the specified coordinate.

Parameters:

NameTypeDescription
xnumberX value of the target coordinate.
ynumberY value of the target coordinate.

Returns: number

Relative angle from this Cube to the specified coordinate.


rotate

rotate(speed: number, duration: number): void

Inherited from Cube.rotate

Defined in cube/cube.ts:494

Rotate with specified speed/time.

Parameters:

NameTypeDefaultDescription
speednumber-Motor speed. Plus value means clockwise direction and the other is counter-clockwise. -115 to -8, 8 to 115, and 0 integer value.
durationnumber0Motor control duration in msec. 0-2550( 0: Eternally ).

Returns: void


setFrameRate

setFrameRate(fps: number): void

Inherited from Cube.setFrameRate

Defined in cube/cube.ts:304

Set framerate.

Parameters:

NameType
fpsnumber

Returns: void


stop

stop(): void

Inherited from Cube.stop

Defined in cube/cube.ts:381

Stop moving.

Returns: void


turnLightOff

turnLightOff(): void

Inherited from Cube.turnLightOff

Defined in cube/cube.ts:311

Turn the light off.

Returns: void


turnLightOn

turnLightOn(color: p5.Color, duration: number): void

Defined in p5tCube.ts:52

Turn the light on with specified p5.Color and duration(optional) values.

Parameters:

NameTypeDefaultDescription
colorp5.Color-p5.Color value. RGBA values are reflected.
durationnumber0Light up duration in msec. 0-2550 ( 0: Eternally ).

Returns: void


turnLightOnRGB

turnLightOnRGB(r: number, g: number, b: number, duration: number): void

Inherited from Cube.turnLightOnRGB

Defined in cube/cube.ts:323

Turn the light on with specified RGB and duration(optional) values.

Parameters:

NameTypeDefaultDescription
rnumber-Red value. 0-255.
gnumber-Green value. 0-255.
bnumber-Blue value. 0-255.
durationnumber0Light up duration in msec. 0-2550 ( 0: Eternally ).

Returns: void


turnLightOnRGBA

turnLightOnRGBA(r: number, g: number, b: number, a: number, duration: number): void

Inherited from Cube.turnLightOnRGBA

Defined in cube/cube.ts:336

Turn the light on with specified RGB, Alpha and duration(optional) values.

Parameters:

NameTypeDefaultDescription
rnumber-Red value. 0-255.
gnumber-Green value. 0-255.
bnumber-Blue value. 0-255.
anumber-Alpha( = Brightness ) value. 0-255.
durationnumber0Light up duration in msec. 0-2550( 0: Eternally ).

Returns: void


turnTo

turnTo(angle: number, speed: number, rotateType: string, timeout: number): void

Overrides Cube.turnTo

Defined in p5tCube.ts:123

Turn to specified angle.

Parameters:

NameTypeDefaultDescription
anglenumber-Aim angle. Unit depends on the setting angleMode(Default: RADIANS)
speednumber-8 to 115, and 0 integer value.
rotateTypestringP5tCube.rotateTypeId.efficient(Optional)rotation direction value. default is rotateType.efficient
timeoutnumber5(Optional)timeout in sec. default is 5 sec. 1-255 sec. 0 means exceptionally 10 sec.

Returns: void


turnToCube

turnToCube(cube: Cube, speed: number, rotateType: string, timeout: number): void

Inherited from Cube.turnToCube

Defined in cube/cube.ts:588

Turn to specified cube's position.

Parameters:

NameTypeDefaultDescription
cubeCube-aim cube instance.
speednumber-8 to 115, and 0 integer value.
rotateTypestringCube.rotateTypeId.efficient(Optional)rotation direction value. default is rotateType.efficient
timeoutnumber5(Optional)timeout in sec. default is 5 sec. 1-255 sec. 0 means exceptionally 10 sec.

Returns: void


turnToXY

turnToXY(x: number, y: number, speed: number, rotateType: string, timeout: number): void

Overrides Cube.turnToXY

Defined in p5tCube.ts:142

Turn to the specified coordinate.

Parameters:

NameTypeDefaultDescription
xnumber-X value of the target coordinate.
ynumber-Y value of the target coordinate.
speednumber-8 to 115, and 0 integer value.
rotateTypestringP5tCube.rotateTypeId.efficient(Optional)rotation direction value. default is rotateType.efficient
timeoutnumber5(Optional)timeout in sec. default is 5 sec. 1-255 sec. 0 means exceptionally 10 sec.

Returns: void


Static connectNewCube

connectNewCube(): Promise‹Cube

Inherited from Cube.connectNewCube

Defined in cube/cube.ts:720

Connect to new toio™Core Cube.

Returns: Promise‹Cube

Promise. resolve handler includes a instance of connected Cube.


Static connectNewP5tCube

connectNewP5tCube(): Promise‹P5tCube

Defined in p5tCube.ts:218

Connect to new toio™Core Cube.

Returns: Promise‹P5tCube

Promise. resolve handler includes a instance of connected P5tCube.