Skip to main content

CubeMotorChar

Hierarchy

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

+ new CubeMotorChar(service: BluetoothRemoteGATTService): CubeMotorChar

Inherited from CubeChar.constructor

Defined in cube/char/char.ts:19

Parameters:

NameType
serviceBluetoothRemoteGATTService

Returns: CubeMotorChar

Properties

Protected characteristic

characteristic: BluetoothRemoteGATTCharacteristic

Inherited from CubeChar.characteristic

Defined in cube/char/char.ts:10


Protected errStrInProgress

errStrInProgress: string = "GATT operation already in progress."

Inherited from CubeChar.errStrInProgress

Defined in cube/char/char.ts:12


Readonly uuid

uuid: string = "10b20102-5b3b-4571-9508-cf3efcd7bbae"

Overrides CubeChar.uuid

Defined in cube/char/motorChar.ts:4


Static angleTypeId

angleTypeId: object = { absEfficient: 0, absPositiveDir: 1, absNegativeDir: 2, relPositiveDir: 3, relNegativeDir: 4, noRotate: 5, sameAsCurrent: 6, } as const

Defined in cube/char/motorChar.ts:55

Angle type IDs.

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 = { constant: 0, accel: 1, decel: 2, accelDecel: 3, } as const

Defined in cube/char/motorChar.ts:45

Ease type IDs.

Type declaration:

  • accel: 1 = 1

  • accelDecel: 3 = 3

  • constant: 0 = 0

  • decel: 2 = 2


Static moveTypeId

moveTypeId: object = { efficient: 0, withoutBack: 1, rotate1st: 2, } as const

Defined in cube/char/motorChar.ts:36

Movement type IDs.

Type declaration:

  • efficient: 0 = 0

  • rotate1st: 2 = 2

  • withoutBack: 1 = 1

Methods

motorControl

motorControl(left: number, right: number): void

Defined in cube/char/motorChar.ts:123

Primitive motor control.

Parameters:

NameTypeDescription
leftnumberLeft motor speed. Negative value means back direction. -115 to -8, 8 to 115, and 0 integer value.
rightnumberRight motor speed. Negative value means back direction. -115 to -8, 8 to 115, and 0 integer value.

Returns: void


motorControlAccelerationSpecified

motorControlAccelerationSpecified(): void

Defined in cube/char/motorChar.ts:284

Acceleration specified motor control. NOT IMPLEMENTED YET.

Returns: void


motorControlAimSpecified

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

Defined in cube/char/motorChar.ts:161

Aim specified motor control.

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


motorControlMultipleAimSpecified

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

Defined in cube/char/motorChar.ts:225

Multiple aim specified motor control.

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


motorControlTimeSpecified

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

Defined in cube/char/motorChar.ts:134

Time specified motor control.

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


prepare

prepare(): Promise‹string | Error›

Implementation of CubeCharIF

Overrides CubeChar.prepare

Defined in cube/char/motorChar.ts:70

Prepare for using motor characteristic function.

Returns: Promise‹string | Error›

Promise. resolve handler says that methods are available in this class.


readValue

readValue(): Promise‹DataView›

Implementation of CubeCharIF

Inherited from CubeChar.readValue

Defined in cube/char/char.ts:110

Read value from remote GATT Characteristics.

Returns: Promise‹DataView›

Promise. resolve handler include data.


setFrameRate

setFrameRate(fps: number): void

Implementation of CubeCharIF

Inherited from CubeChar.setFrameRate

Defined in cube/char/char.ts:134

Set framerate.

Parameters:

NameType
fpsnumber

Returns: void


writeValue

writeValue(buf: ArrayBuffer): Promise‹string | Error›

Implementation of CubeCharIF

Inherited from CubeChar.writeValue

Defined in cube/char/char.ts:55

Write value to remote GATT Characteristics.

Parameters:

NameTypeDescription
bufArrayBufferdata buffer including command for Cube.

Returns: Promise‹string | Error›

Promise. resolve handler says that write command executed correctly.


writeValueCore

writeValueCore(buf: ArrayBuffer, countRetry: number): Promise‹string | Error›

Inherited from CubeChar.writeValueCore

Defined in cube/char/char.ts:78

Write value to remote GATT Characteristics. Core function.

Parameters:

NameTypeDescription
bufArrayBufferdata buffer including command for Cube.
countRetrynumberCounter for retry.

Returns: Promise‹string | Error›

Promise. resolve handler says that write command executed correctly.