node-poweredup 10.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/browser/poweredup.js +6193 -0
- package/dist/browser/poweredup.js.map +7 -0
- package/dist/consts.d.ts +40 -0
- package/dist/consts.d.ts.map +1 -1
- package/dist/consts.js +42 -0
- package/dist/consts.js.map +1 -1
- package/dist/devices/absolutemotor.d.ts +8 -6
- package/dist/devices/absolutemotor.d.ts.map +1 -1
- package/dist/devices/absolutemotor.js +24 -31
- package/dist/devices/absolutemotor.js.map +1 -1
- package/dist/devices/basicmotor.d.ts +11 -10
- package/dist/devices/basicmotor.d.ts.map +1 -1
- package/dist/devices/basicmotor.js +16 -22
- package/dist/devices/basicmotor.js.map +1 -1
- package/dist/devices/colordistancesensor.d.ts +13 -12
- package/dist/devices/colordistancesensor.d.ts.map +1 -1
- package/dist/devices/colordistancesensor.js +25 -31
- package/dist/devices/colordistancesensor.js.map +1 -1
- package/dist/devices/device.d.ts +15 -6
- package/dist/devices/device.d.ts.map +1 -1
- package/dist/devices/device.js +209 -21
- package/dist/devices/device.js.map +1 -1
- package/dist/devices/duplotrainbasespeaker.d.ts +4 -4
- package/dist/devices/duplotrainbasespeaker.d.ts.map +1 -1
- package/dist/devices/duplotrainbasespeaker.js +5 -8
- package/dist/devices/duplotrainbasespeaker.js.map +1 -1
- package/dist/devices/hubled.d.ts +5 -4
- package/dist/devices/hubled.d.ts.map +1 -1
- package/dist/devices/hubled.js +24 -24
- package/dist/devices/hubled.js.map +1 -1
- package/dist/devices/light.d.ts +7 -4
- package/dist/devices/light.d.ts.map +1 -1
- package/dist/devices/light.js +11 -17
- package/dist/devices/light.js.map +1 -1
- package/dist/devices/piezobuzzer.d.ts +3 -2
- package/dist/devices/piezobuzzer.d.ts.map +1 -1
- package/dist/devices/piezobuzzer.js +2 -2
- package/dist/devices/piezobuzzer.js.map +1 -1
- package/dist/devices/tachomotor.d.ts +14 -8
- package/dist/devices/tachomotor.d.ts.map +1 -1
- package/dist/devices/tachomotor.js +50 -56
- package/dist/devices/tachomotor.js.map +1 -1
- package/dist/devices/technic3x3colorlightmatrix.d.ts +3 -2
- package/dist/devices/technic3x3colorlightmatrix.d.ts.map +1 -1
- package/dist/devices/technic3x3colorlightmatrix.js +20 -23
- package/dist/devices/technic3x3colorlightmatrix.js.map +1 -1
- package/dist/devices/techniccolorsensor.d.ts +9 -4
- package/dist/devices/techniccolorsensor.d.ts.map +1 -1
- package/dist/devices/techniccolorsensor.js +99 -8
- package/dist/devices/techniccolorsensor.js.map +1 -1
- package/dist/devices/technicdistancesensor.d.ts +1 -1
- package/dist/devices/technicdistancesensor.js +1 -1
- package/dist/devices/technicmediumhubtiltsensor.d.ts +7 -6
- package/dist/devices/technicmediumhubtiltsensor.d.ts.map +1 -1
- package/dist/devices/technicmediumhubtiltsensor.js +9 -18
- package/dist/devices/technicmediumhubtiltsensor.js.map +1 -1
- package/dist/devices/tiltsensor.d.ts +4 -1
- package/dist/devices/tiltsensor.d.ts.map +1 -1
- package/dist/devices/tiltsensor.js +84 -3
- package/dist/devices/tiltsensor.js.map +1 -1
- package/dist/hubs/basehub.d.ts +1 -0
- package/dist/hubs/basehub.d.ts.map +1 -1
- package/dist/hubs/basehub.js +17 -0
- package/dist/hubs/basehub.js.map +1 -1
- package/dist/hubs/lpf2hub.d.ts +1 -0
- package/dist/hubs/lpf2hub.d.ts.map +1 -1
- package/dist/hubs/lpf2hub.js +11 -0
- package/dist/hubs/lpf2hub.js.map +1 -1
- package/dist/portoutputcommand.d.ts +13 -0
- package/dist/portoutputcommand.d.ts.map +1 -0
- package/dist/portoutputcommand.js +30 -0
- package/dist/portoutputcommand.js.map +1 -0
- package/dist/portoutputsleep.d.ts +6 -0
- package/dist/portoutputsleep.d.ts.map +1 -0
- package/dist/portoutputsleep.js +10 -0
- package/dist/portoutputsleep.js.map +1 -0
- package/dist/utils.d.ts +1 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +13 -19
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/consts.ts +44 -0
- package/src/devices/absolutemotor.ts +24 -31
- package/src/devices/basicmotor.ts +16 -22
- package/src/devices/colordistancesensor.ts +23 -29
- package/src/devices/device.ts +198 -20
- package/src/devices/duplotrainbasespeaker.ts +5 -8
- package/src/devices/hubled.ts +22 -22
- package/src/devices/light.ts +11 -18
- package/src/devices/piezobuzzer.ts +3 -3
- package/src/devices/tachomotor.ts +47 -53
- package/src/devices/technic3x3colorlightmatrix.ts +20 -23
- package/src/devices/techniccolorsensor.ts +102 -10
- package/src/devices/technicdistancesensor.ts +1 -1
- package/src/devices/technicmediumhubtiltsensor.ts +9 -18
- package/src/devices/tiltsensor.ts +85 -5
- package/src/hubs/basehub.ts +18 -0
- package/src/hubs/lpf2hub.ts +12 -5
- package/src/portoutputcommand.ts +37 -0
- package/src/portoutputsleep.ts +11 -0
- package/src/utils.ts +14 -19
- package/tsconfig.tsbuildinfo +1 -1
- package/webpack.config.cjs +35 -0
- package/dist/node/color.d.ts +0 -6
- package/dist/node/color.js +0 -15
- package/dist/node/color.js.map +0 -1
- package/dist/node/commands.d.ts +0 -299
- package/dist/node/commands.js +0 -672
- package/dist/node/commands.js.map +0 -1
- package/dist/node/connection.d.ts +0 -187
- package/dist/node/connection.js +0 -478
- package/dist/node/connection.js.map +0 -1
- package/dist/node/consts.d.ts +0 -644
- package/dist/node/consts.js +0 -675
- package/dist/node/consts.js.map +0 -1
- package/dist/node/devices/absolutemotor.d.ts +0 -43
- package/dist/node/devices/absolutemotor.js +0 -118
- package/dist/node/devices/absolutemotor.js.map +0 -1
- package/dist/node/devices/basicmotor.d.ts +0 -40
- package/dist/node/devices/basicmotor.js +0 -61
- package/dist/node/devices/basicmotor.js.map +0 -1
- package/dist/node/devices/colordistancesensor.d.ts +0 -79
- package/dist/node/devices/colordistancesensor.js +0 -284
- package/dist/node/devices/colordistancesensor.js.map +0 -1
- package/dist/node/devices/currentsensor.d.ts +0 -16
- package/dist/node/devices/currentsensor.js +0 -55
- package/dist/node/devices/currentsensor.js.map +0 -1
- package/dist/node/devices/device.d.ts +0 -71
- package/dist/node/devices/device.js +0 -162
- package/dist/node/devices/device.js.map +0 -1
- package/dist/node/devices/duplotrainbasecolorsensor.d.ts +0 -19
- package/dist/node/devices/duplotrainbasecolorsensor.js +0 -77
- package/dist/node/devices/duplotrainbasecolorsensor.js.map +0 -1
- package/dist/node/devices/duplotrainbasemotor.d.ts +0 -9
- package/dist/node/devices/duplotrainbasemotor.js +0 -12
- package/dist/node/devices/duplotrainbasemotor.js.map +0 -1
- package/dist/node/devices/duplotrainbasespeaker.d.ts +0 -28
- package/dist/node/devices/duplotrainbasespeaker.js +0 -40
- package/dist/node/devices/duplotrainbasespeaker.js.map +0 -1
- package/dist/node/devices/duplotrainbasespeedometer.d.ts +0 -16
- package/dist/node/devices/duplotrainbasespeedometer.js +0 -34
- package/dist/node/devices/duplotrainbasespeedometer.js.map +0 -1
- package/dist/node/devices/hubled.d.ts +0 -29
- package/dist/node/devices/hubled.js +0 -60
- package/dist/node/devices/hubled.js.map +0 -1
- package/dist/node/devices/index.d.ts +0 -14
- package/dist/node/devices/index.js +0 -154
- package/dist/node/devices/index.js.map +0 -1
- package/dist/node/devices/led.d.ts +0 -140
- package/dist/node/devices/led.js +0 -295
- package/dist/node/devices/led.js.map +0 -1
- package/dist/node/devices/light.d.ts +0 -25
- package/dist/node/devices/light.js +0 -46
- package/dist/node/devices/light.js.map +0 -1
- package/dist/node/devices/marioaccelerometer.d.ts +0 -17
- package/dist/node/devices/marioaccelerometer.js +0 -50
- package/dist/node/devices/marioaccelerometer.js.map +0 -1
- package/dist/node/devices/mariobarcodesensor.d.ts +0 -17
- package/dist/node/devices/mariobarcodesensor.js +0 -58
- package/dist/node/devices/mariobarcodesensor.js.map +0 -1
- package/dist/node/devices/mariopantssensor.d.ts +0 -16
- package/dist/node/devices/mariopantssensor.js +0 -34
- package/dist/node/devices/mariopantssensor.js.map +0 -1
- package/dist/node/devices/mediumlinearmotor.d.ts +0 -9
- package/dist/node/devices/mediumlinearmotor.js +0 -12
- package/dist/node/devices/mediumlinearmotor.js.map +0 -1
- package/dist/node/devices/motionsensor.d.ts +0 -16
- package/dist/node/devices/motionsensor.js +0 -38
- package/dist/node/devices/motionsensor.js.map +0 -1
- package/dist/node/devices/motor.d.ts +0 -182
- package/dist/node/devices/motor.js +0 -367
- package/dist/node/devices/motor.js.map +0 -1
- package/dist/node/devices/movehubmediumlinearmotor.d.ts +0 -9
- package/dist/node/devices/movehubmediumlinearmotor.js +0 -12
- package/dist/node/devices/movehubmediumlinearmotor.js.map +0 -1
- package/dist/node/devices/movehubtiltsensor.d.ts +0 -16
- package/dist/node/devices/movehubtiltsensor.js +0 -36
- package/dist/node/devices/movehubtiltsensor.js.map +0 -1
- package/dist/node/devices/piezobuzzer.d.ts +0 -17
- package/dist/node/devices/piezobuzzer.js +0 -28
- package/dist/node/devices/piezobuzzer.js.map +0 -1
- package/dist/node/devices/remotecontrolbutton.d.ts +0 -19
- package/dist/node/devices/remotecontrolbutton.js +0 -40
- package/dist/node/devices/remotecontrolbutton.js.map +0 -1
- package/dist/node/devices/sensor.d.ts +0 -305
- package/dist/node/devices/sensor.js +0 -662
- package/dist/node/devices/sensor.js.map +0 -1
- package/dist/node/devices/simplemediumlinearmotor.d.ts +0 -9
- package/dist/node/devices/simplemediumlinearmotor.js +0 -12
- package/dist/node/devices/simplemediumlinearmotor.js.map +0 -1
- package/dist/node/devices/tachomotor.d.ts +0 -70
- package/dist/node/devices/tachomotor.js +0 -167
- package/dist/node/devices/tachomotor.js.map +0 -1
- package/dist/node/devices/technic3x3colorlightmatrix.d.ts +0 -22
- package/dist/node/devices/technic3x3colorlightmatrix.js +0 -54
- package/dist/node/devices/technic3x3colorlightmatrix.js.map +0 -1
- package/dist/node/devices/techniccolorsensor.d.ts +0 -27
- package/dist/node/devices/techniccolorsensor.js +0 -72
- package/dist/node/devices/techniccolorsensor.js.map +0 -1
- package/dist/node/devices/technicdistancesensor.d.ts +0 -27
- package/dist/node/devices/technicdistancesensor.js +0 -58
- package/dist/node/devices/technicdistancesensor.js.map +0 -1
- package/dist/node/devices/technicforcesensor.d.ts +0 -18
- package/dist/node/devices/technicforcesensor.js +0 -58
- package/dist/node/devices/technicforcesensor.js.map +0 -1
- package/dist/node/devices/techniclargeangularmotor.d.ts +0 -12
- package/dist/node/devices/techniclargeangularmotor.js +0 -12
- package/dist/node/devices/techniclargeangularmotor.js.map +0 -1
- package/dist/node/devices/techniclargelinearmotor.d.ts +0 -9
- package/dist/node/devices/techniclargelinearmotor.js +0 -12
- package/dist/node/devices/techniclargelinearmotor.js.map +0 -1
- package/dist/node/devices/technicmediumangularmotor.d.ts +0 -12
- package/dist/node/devices/technicmediumangularmotor.js +0 -12
- package/dist/node/devices/technicmediumangularmotor.js.map +0 -1
- package/dist/node/devices/technicmediumhubaccelerometersensor.d.ts +0 -16
- package/dist/node/devices/technicmediumhubaccelerometersensor.js +0 -38
- package/dist/node/devices/technicmediumhubaccelerometersensor.js.map +0 -1
- package/dist/node/devices/technicmediumhubgyrosensor.d.ts +0 -16
- package/dist/node/devices/technicmediumhubgyrosensor.js +0 -38
- package/dist/node/devices/technicmediumhubgyrosensor.js.map +0 -1
- package/dist/node/devices/technicmediumhubtiltsensor.d.ts +0 -40
- package/dist/node/devices/technicmediumhubtiltsensor.js +0 -106
- package/dist/node/devices/technicmediumhubtiltsensor.js.map +0 -1
- package/dist/node/devices/technicsmallangularmotor.d.ts +0 -12
- package/dist/node/devices/technicsmallangularmotor.js +0 -12
- package/dist/node/devices/technicsmallangularmotor.js.map +0 -1
- package/dist/node/devices/technicxlargelinearmotor.d.ts +0 -9
- package/dist/node/devices/technicxlargelinearmotor.js +0 -12
- package/dist/node/devices/technicxlargelinearmotor.js.map +0 -1
- package/dist/node/devices/tiltsensor.d.ts +0 -16
- package/dist/node/devices/tiltsensor.js +0 -36
- package/dist/node/devices/tiltsensor.js.map +0 -1
- package/dist/node/devices/trainmotor.d.ts +0 -9
- package/dist/node/devices/trainmotor.js +0 -12
- package/dist/node/devices/trainmotor.js.map +0 -1
- package/dist/node/devices/voltagesensor.d.ts +0 -16
- package/dist/node/devices/voltagesensor.js +0 -59
- package/dist/node/devices/voltagesensor.js.map +0 -1
- package/dist/node/hub.d.ts +0 -291
- package/dist/node/hub.js +0 -778
- package/dist/node/hub.js.map +0 -1
- package/dist/node/hubs/basehub.d.ts +0 -162
- package/dist/node/hubs/basehub.js +0 -392
- package/dist/node/hubs/basehub.js.map +0 -1
- package/dist/node/hubs/duplotrainbase.d.ts +0 -17
- package/dist/node/hubs/duplotrainbase.js +0 -35
- package/dist/node/hubs/duplotrainbase.js.map +0 -1
- package/dist/node/hubs/hub.d.ts +0 -19
- package/dist/node/hubs/hub.js +0 -44
- package/dist/node/hubs/hub.js.map +0 -1
- package/dist/node/hubs/lpf2hub.d.ts +0 -48
- package/dist/node/hubs/lpf2hub.js +0 -314
- package/dist/node/hubs/lpf2hub.js.map +0 -1
- package/dist/node/hubs/mario.d.ts +0 -17
- package/dist/node/hubs/mario.js +0 -31
- package/dist/node/hubs/mario.js.map +0 -1
- package/dist/node/hubs/movehub.d.ts +0 -18
- package/dist/node/hubs/movehub.js +0 -46
- package/dist/node/hubs/movehub.js.map +0 -1
- package/dist/node/hubs/remotecontrol.d.ts +0 -17
- package/dist/node/hubs/remotecontrol.js +0 -37
- package/dist/node/hubs/remotecontrol.js.map +0 -1
- package/dist/node/hubs/technicmediumhub.d.ts +0 -17
- package/dist/node/hubs/technicmediumhub.js +0 -42
- package/dist/node/hubs/technicmediumhub.js.map +0 -1
- package/dist/node/hubs/technicsmallhub.d.ts +0 -18
- package/dist/node/hubs/technicsmallhub.js +0 -41
- package/dist/node/hubs/technicsmallhub.js.map +0 -1
- package/dist/node/hubs/wedo2smarthub.d.ts +0 -40
- package/dist/node/hubs/wedo2smarthub.js +0 -188
- package/dist/node/hubs/wedo2smarthub.js.map +0 -1
- package/dist/node/index-browser.d.ts +0 -1
- package/dist/node/index-browser.js +0 -96
- package/dist/node/index-browser.js.map +0 -1
- package/dist/node/index-node.d.ts +0 -49
- package/dist/node/index-node.js +0 -50
- package/dist/node/index-node.js.map +0 -1
- package/dist/node/index.d.ts +0 -31
- package/dist/node/index.js +0 -93
- package/dist/node/index.js.map +0 -1
- package/dist/node/index.mjs +0 -0
- package/dist/node/interfaces.d.ts +0 -23
- package/dist/node/interfaces.js +0 -2
- package/dist/node/interfaces.js.map +0 -1
- package/dist/node/nobleabstraction.d.ts +0 -26
- package/dist/node/nobleabstraction.js +0 -123
- package/dist/node/nobleabstraction.js.map +0 -1
- package/dist/node/poweredup-browser.d.ts +0 -50
- package/dist/node/poweredup-browser.js +0 -216
- package/dist/node/poweredup-browser.js.map +0 -1
- package/dist/node/poweredup-node.d.ts +0 -54
- package/dist/node/poweredup-node.js +0 -173
- package/dist/node/poweredup-node.js.map +0 -1
- package/dist/node/poweredup.d.ts +0 -83
- package/dist/node/poweredup.js +0 -542
- package/dist/node/poweredup.js.map +0 -1
- package/dist/node/protocol-wedo.d.ts +0 -158
- package/dist/node/protocol-wedo.js +0 -342
- package/dist/node/protocol-wedo.js.map +0 -1
- package/dist/node/protocol.d.ts +0 -340
- package/dist/node/protocol.js +0 -730
- package/dist/node/protocol.js.map +0 -1
- package/dist/node/types.d.ts +0 -408
- package/dist/node/types.js +0 -291
- package/dist/node/types.js.map +0 -1
- package/dist/node/utils.d.ts +0 -12
- package/dist/node/utils.js +0 -90
- package/dist/node/utils.js.map +0 -1
- package/dist/node/webbleabstraction.d.ts +0 -26
- package/dist/node/webbleabstraction.js +0 -104
- package/dist/node/webbleabstraction.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BasicMotor } from "./basicmotor";
|
|
2
|
-
import * as Consts from "../consts";
|
|
3
|
-
/**
|
|
4
|
-
* @class SimpleMediumLinearMotor
|
|
5
|
-
* @extends Device
|
|
6
|
-
*/
|
|
7
|
-
export class SimpleMediumLinearMotor extends BasicMotor {
|
|
8
|
-
constructor(hub, portId) {
|
|
9
|
-
super(hub, portId, {}, Consts.DeviceType.SIMPLE_MEDIUM_LINEAR_MOTOR);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=simplemediumlinearmotor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simplemediumlinearmotor.js","sourceRoot":"","sources":["../../../src/devices/simplemediumlinearmotor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,UAAU;IAEnD,YAAa,GAAqB,EAAE,MAAc;QAC9C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,UAAU,CAAC,0BAA0B,CAAC,CAAC;IACzE,CAAC;CAEJ"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { BasicMotor } from "./basicmotor";
|
|
2
|
-
import { IDeviceInterface } from "../interfaces";
|
|
3
|
-
import * as Consts from "../consts";
|
|
4
|
-
/**
|
|
5
|
-
* @class TachoMotor
|
|
6
|
-
* @extends BasicMotor
|
|
7
|
-
*/
|
|
8
|
-
export declare class TachoMotor extends BasicMotor {
|
|
9
|
-
protected _brakeStyle: Consts.BrakingStyle;
|
|
10
|
-
protected _maxPower: number;
|
|
11
|
-
useAccelerationProfile: boolean;
|
|
12
|
-
useDecelerationProfile: boolean;
|
|
13
|
-
constructor(hub: IDeviceInterface, portId: number, modeMap?: {
|
|
14
|
-
[event: string]: number;
|
|
15
|
-
}, type?: Consts.DeviceType);
|
|
16
|
-
receive(message: Buffer): void;
|
|
17
|
-
/**
|
|
18
|
-
* Set the braking style of the motor.
|
|
19
|
-
*
|
|
20
|
-
* Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.
|
|
21
|
-
* @method TachoMotor#setBrakingStyle
|
|
22
|
-
* @param {number} style Either BRAKE or HOLD
|
|
23
|
-
*/
|
|
24
|
-
setBrakingStyle(style: Consts.BrakingStyle): void;
|
|
25
|
-
/**
|
|
26
|
-
* Set the max power of the motor.
|
|
27
|
-
*
|
|
28
|
-
* Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.
|
|
29
|
-
* @method TachoMotor#setMaxPower
|
|
30
|
-
* @param {number} style Either BRAKE or HOLD
|
|
31
|
-
*/
|
|
32
|
-
setMaxPower(maxPower: number): void;
|
|
33
|
-
/**
|
|
34
|
-
* Set the global acceleration time
|
|
35
|
-
* @method TachoMotor#setAccelerationTime
|
|
36
|
-
* @param {number} time How long acceleration should last (in milliseconds).
|
|
37
|
-
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
|
|
38
|
-
*/
|
|
39
|
-
setAccelerationTime(time: number, profile?: number): void;
|
|
40
|
-
/**
|
|
41
|
-
* Set the global deceleration time
|
|
42
|
-
* @method TachoMotor#setDecelerationTime
|
|
43
|
-
* @param {number} time How long deceleration should last (in milliseconds).
|
|
44
|
-
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
|
|
45
|
-
*/
|
|
46
|
-
setDecelerationTime(time: number, profile?: number): void;
|
|
47
|
-
/**
|
|
48
|
-
* Set the motor speed.
|
|
49
|
-
* @method TachoMotor#setSpeed
|
|
50
|
-
* @param {number} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
|
|
51
|
-
* @param {number} time How long the motor should run for (in milliseconds).
|
|
52
|
-
* @returns {Promise} Resolved upon successful issuance of the command.
|
|
53
|
-
*/
|
|
54
|
-
setSpeed(speed: [number, number] | number, time: number | undefined): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Rotate a motor by a given amount of degrees.
|
|
57
|
-
* @method TachoMotor#rotateByDegrees
|
|
58
|
-
* @param {number} degrees How much the motor should be rotated (in degrees).
|
|
59
|
-
* @param {number} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.
|
|
60
|
-
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
|
|
61
|
-
*/
|
|
62
|
-
rotateByDegrees(degrees: number, speed: [number, number] | number): Promise<void>;
|
|
63
|
-
protected useProfile(): number;
|
|
64
|
-
}
|
|
65
|
-
export declare enum Mode {
|
|
66
|
-
ROTATION = 2
|
|
67
|
-
}
|
|
68
|
-
export declare const ModeMap: {
|
|
69
|
-
[event: string]: number;
|
|
70
|
-
};
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { BasicMotor } from "./basicmotor";
|
|
2
|
-
import * as Consts from "../consts";
|
|
3
|
-
import { mapSpeed } from "../utils";
|
|
4
|
-
/**
|
|
5
|
-
* @class TachoMotor
|
|
6
|
-
* @extends BasicMotor
|
|
7
|
-
*/
|
|
8
|
-
export class TachoMotor extends BasicMotor {
|
|
9
|
-
constructor(hub, portId, modeMap = {}, type = Consts.DeviceType.UNKNOWN) {
|
|
10
|
-
super(hub, portId, Object.assign({}, modeMap, ModeMap), type);
|
|
11
|
-
this._brakeStyle = Consts.BrakingStyle.BRAKE;
|
|
12
|
-
this._maxPower = 100;
|
|
13
|
-
this.useAccelerationProfile = true;
|
|
14
|
-
this.useDecelerationProfile = true;
|
|
15
|
-
}
|
|
16
|
-
receive(message) {
|
|
17
|
-
const mode = this._mode;
|
|
18
|
-
switch (mode) {
|
|
19
|
-
case Mode.ROTATION:
|
|
20
|
-
const degrees = message.readInt32LE(this.isWeDo2SmartHub ? 2 : 4);
|
|
21
|
-
/**
|
|
22
|
-
* Emits when a rotation sensor is activated.
|
|
23
|
-
* @event TachoMotor#rotate
|
|
24
|
-
* @type {object}
|
|
25
|
-
* @param {number} rotation
|
|
26
|
-
*/
|
|
27
|
-
this.notify("rotate", { degrees });
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Set the braking style of the motor.
|
|
33
|
-
*
|
|
34
|
-
* Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.
|
|
35
|
-
* @method TachoMotor#setBrakingStyle
|
|
36
|
-
* @param {number} style Either BRAKE or HOLD
|
|
37
|
-
*/
|
|
38
|
-
setBrakingStyle(style) {
|
|
39
|
-
this._brakeStyle = style;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Set the max power of the motor.
|
|
43
|
-
*
|
|
44
|
-
* Note: This applies to setSpeed, rotateByDegrees, and gotoAngle.
|
|
45
|
-
* @method TachoMotor#setMaxPower
|
|
46
|
-
* @param {number} style Either BRAKE or HOLD
|
|
47
|
-
*/
|
|
48
|
-
setMaxPower(maxPower) {
|
|
49
|
-
this._maxPower = maxPower;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Set the global acceleration time
|
|
53
|
-
* @method TachoMotor#setAccelerationTime
|
|
54
|
-
* @param {number} time How long acceleration should last (in milliseconds).
|
|
55
|
-
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
|
|
56
|
-
*/
|
|
57
|
-
setAccelerationTime(time, profile = 0x00) {
|
|
58
|
-
const message = Buffer.from([0x81, this.portId, 0x11, 0x05, 0x00, 0x00, profile]);
|
|
59
|
-
message.writeUInt16LE(time, 4);
|
|
60
|
-
this.send(message);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Set the global deceleration time
|
|
64
|
-
* @method TachoMotor#setDecelerationTime
|
|
65
|
-
* @param {number} time How long deceleration should last (in milliseconds).
|
|
66
|
-
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
|
|
67
|
-
*/
|
|
68
|
-
setDecelerationTime(time, profile = 0x00) {
|
|
69
|
-
const message = Buffer.from([0x81, this.portId, 0x11, 0x06, 0x00, 0x00, profile]);
|
|
70
|
-
message.writeUInt16LE(time, 4);
|
|
71
|
-
this.send(message);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Set the motor speed.
|
|
75
|
-
* @method TachoMotor#setSpeed
|
|
76
|
-
* @param {number} speed For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100. Stop is 0.
|
|
77
|
-
* @param {number} time How long the motor should run for (in milliseconds).
|
|
78
|
-
* @returns {Promise} Resolved upon successful issuance of the command.
|
|
79
|
-
*/
|
|
80
|
-
setSpeed(speed, time) {
|
|
81
|
-
if (!this.isVirtualPort && speed instanceof Array) {
|
|
82
|
-
throw new Error("Only virtual ports can accept multiple speeds");
|
|
83
|
-
}
|
|
84
|
-
if (this.isWeDo2SmartHub) {
|
|
85
|
-
throw new Error("Motor speed is not available on the WeDo 2.0 Smart Hub");
|
|
86
|
-
}
|
|
87
|
-
this.cancelEventTimer();
|
|
88
|
-
return new Promise((resolve) => {
|
|
89
|
-
if (speed === undefined || speed === null) {
|
|
90
|
-
speed = 100;
|
|
91
|
-
}
|
|
92
|
-
let message;
|
|
93
|
-
if (time !== undefined) {
|
|
94
|
-
if (speed instanceof Array) {
|
|
95
|
-
message = Buffer.from([0x81, this.portId, 0x11, 0x0a, 0x00, 0x00, mapSpeed(speed[0]), mapSpeed(speed[1]), this._maxPower, this._brakeStyle, this.useProfile()]);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
message = Buffer.from([0x81, this.portId, 0x11, 0x09, 0x00, 0x00, mapSpeed(speed), this._maxPower, this._brakeStyle, this.useProfile()]);
|
|
99
|
-
}
|
|
100
|
-
message.writeUInt16LE(time, 4);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
if (speed instanceof Array) {
|
|
104
|
-
message = Buffer.from([0x81, this.portId, 0x11, 0x08, mapSpeed(speed[0]), mapSpeed(speed[1]), this._maxPower, this.useProfile()]);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
message = Buffer.from([0x81, this.portId, 0x11, 0x07, mapSpeed(speed), this._maxPower, this.useProfile()]);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
this.send(message);
|
|
111
|
-
this._finishedCallbacks.push(() => {
|
|
112
|
-
return resolve();
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Rotate a motor by a given amount of degrees.
|
|
118
|
-
* @method TachoMotor#rotateByDegrees
|
|
119
|
-
* @param {number} degrees How much the motor should be rotated (in degrees).
|
|
120
|
-
* @param {number} [speed=100] For forward, a value between 1 - 100 should be set. For reverse, a value between -1 to -100.
|
|
121
|
-
* @returns {Promise} Resolved upon successful completion of command (ie. once the motor is finished).
|
|
122
|
-
*/
|
|
123
|
-
rotateByDegrees(degrees, speed) {
|
|
124
|
-
if (!this.isVirtualPort && speed instanceof Array) {
|
|
125
|
-
throw new Error("Only virtual ports can accept multiple speeds");
|
|
126
|
-
}
|
|
127
|
-
if (this.isWeDo2SmartHub) {
|
|
128
|
-
throw new Error("Rotation is not available on the WeDo 2.0 Smart Hub");
|
|
129
|
-
}
|
|
130
|
-
this.cancelEventTimer();
|
|
131
|
-
return new Promise((resolve) => {
|
|
132
|
-
if (speed === undefined || speed === null) {
|
|
133
|
-
speed = 100;
|
|
134
|
-
}
|
|
135
|
-
let message;
|
|
136
|
-
if (speed instanceof Array) {
|
|
137
|
-
message = Buffer.from([0x81, this.portId, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed[0]), mapSpeed(speed[1]), this._maxPower, this._brakeStyle, this.useProfile()]);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
message = Buffer.from([0x81, this.portId, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, mapSpeed(speed), this._maxPower, this._brakeStyle, this.useProfile()]);
|
|
141
|
-
}
|
|
142
|
-
message.writeUInt32LE(degrees, 4);
|
|
143
|
-
this.send(message);
|
|
144
|
-
this._finishedCallbacks.push(() => {
|
|
145
|
-
return resolve();
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
useProfile() {
|
|
150
|
-
let value = 0x00;
|
|
151
|
-
if (this.useAccelerationProfile) {
|
|
152
|
-
value += 0x01;
|
|
153
|
-
}
|
|
154
|
-
if (this.useDecelerationProfile) {
|
|
155
|
-
value += 0x02;
|
|
156
|
-
}
|
|
157
|
-
return value;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
export var Mode;
|
|
161
|
-
(function (Mode) {
|
|
162
|
-
Mode[Mode["ROTATION"] = 2] = "ROTATION";
|
|
163
|
-
})(Mode || (Mode = {}));
|
|
164
|
-
export const ModeMap = {
|
|
165
|
-
"rotate": Mode.ROTATION
|
|
166
|
-
};
|
|
167
|
-
//# sourceMappingURL=tachomotor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tachomotor.js","sourceRoot":"","sources":["../../../src/devices/tachomotor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IAOtC,YAAa,GAAqB,EAAE,MAAc,EAAE,UAAqC,EAAE,EAAE,OAA0B,MAAM,CAAC,UAAU,CAAC,OAAO;QAC5I,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;QANxD,gBAAW,GAAwB,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC;QAC7D,cAAS,GAAW,GAAG,CAAC;QAC3B,2BAAsB,GAAY,IAAI,CAAC;QACvC,2BAAsB,GAAY,IAAI,CAAC;IAI9C,CAAC;IAEM,OAAO,CAAE,OAAe;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QAEx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E,CAAC;YAC9B,KAAK,IAAI,IAAI,CAAC;QAClB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CAGJ;AAED,MAAM,CAAN,IAAY,IAEX;AAFD,WAAY,IAAI;IACZ,uCAAe,CAAA;AACnB,CAAC,EAFW,IAAI,KAAJ,IAAI,QAEf;AAED,MAAM,CAAC,MAAM,OAAO,GAA8B;IAC9C,QAAQ,EAAE,IAAI,CAAC,QAAQ;CAC1B,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Device } from "./device";
|
|
2
|
-
import { IDeviceInterface } from "../interfaces";
|
|
3
|
-
/**
|
|
4
|
-
* @class Technic3x3ColorLightMatrix
|
|
5
|
-
* @extends Device
|
|
6
|
-
*/
|
|
7
|
-
export declare class Technic3x3ColorLightMatrix extends Device {
|
|
8
|
-
constructor(hub: IDeviceInterface, portId: number);
|
|
9
|
-
/**
|
|
10
|
-
* Set the LED matrix, one color per LED
|
|
11
|
-
* @method Technic3x3ColorLightMatrix#setMatrix
|
|
12
|
-
* @param {Color[] | Color} colors Array of 9 colors, 9 Color objects, or a single color
|
|
13
|
-
* @returns {Promise} Resolved upon successful issuance of the command.
|
|
14
|
-
*/
|
|
15
|
-
setMatrix(colors: number[] | number): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export declare enum Mode {
|
|
18
|
-
LEV_0 = 0,
|
|
19
|
-
COL_0 = 1,
|
|
20
|
-
PIX_0 = 2,
|
|
21
|
-
TRANS = 3
|
|
22
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Color } from "../color";
|
|
2
|
-
import { Device } from "./device";
|
|
3
|
-
import * as Consts from "../consts";
|
|
4
|
-
/**
|
|
5
|
-
* @class Technic3x3ColorLightMatrix
|
|
6
|
-
* @extends Device
|
|
7
|
-
*/
|
|
8
|
-
export class Technic3x3ColorLightMatrix extends Device {
|
|
9
|
-
constructor(hub, portId) {
|
|
10
|
-
super(hub, portId, {}, Consts.DeviceType.TECHNIC_3X3_COLOR_LIGHT_MATRIX);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Set the LED matrix, one color per LED
|
|
14
|
-
* @method Technic3x3ColorLightMatrix#setMatrix
|
|
15
|
-
* @param {Color[] | Color} colors Array of 9 colors, 9 Color objects, or a single color
|
|
16
|
-
* @returns {Promise} Resolved upon successful issuance of the command.
|
|
17
|
-
*/
|
|
18
|
-
setMatrix(colors) {
|
|
19
|
-
return new Promise((resolve) => {
|
|
20
|
-
this.subscribe(Mode.PIX_0);
|
|
21
|
-
const colorArray = new Array(9);
|
|
22
|
-
for (let i = 0; i < colorArray.length; i++) {
|
|
23
|
-
if (typeof colors === 'number') {
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
colorArray[i] = colors + (10 << 4);
|
|
26
|
-
}
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
if (colors[i] instanceof Color) {
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
colorArray[i] = colors[i].toValue();
|
|
31
|
-
}
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
if (colors[i] === Consts.Color.NONE) {
|
|
34
|
-
colorArray[i] = Consts.Color.NONE;
|
|
35
|
-
}
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
if (colors[i] <= 10) {
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
colorArray[i] = colors[i] + (10 << 4); // If a raw color value, set it to max brightness (10)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
this.writeDirect(Mode.PIX_0, Buffer.from(colorArray));
|
|
43
|
-
return resolve();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export var Mode;
|
|
48
|
-
(function (Mode) {
|
|
49
|
-
Mode[Mode["LEV_0"] = 0] = "LEV_0";
|
|
50
|
-
Mode[Mode["COL_0"] = 1] = "COL_0";
|
|
51
|
-
Mode[Mode["PIX_0"] = 2] = "PIX_0";
|
|
52
|
-
Mode[Mode["TRANS"] = 3] = "TRANS";
|
|
53
|
-
})(Mode || (Mode = {}));
|
|
54
|
-
//# sourceMappingURL=technic3x3colorlightmatrix.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"technic3x3colorlightmatrix.js","sourceRoot":"","sources":["../../../src/devices/technic3x3colorlightmatrix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,OAAO,0BAA2B,SAAQ,MAAM;IAGlD,YAAa,GAAqB,EAAE,MAAc;QAC9C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC;IAC7E,CAAC;IAGD;;;;;OAKG;IACI,SAAS,CAAE,MAAyB;QACvC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3B,MAAM,UAAU,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;YAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACzC,IAAI,OAAO,MAAM,KAAM,QAAQ,EAAE,CAAC;oBAC9B,aAAa;oBACb,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;gBACvC,CAAC;gBACD,aAAa;gBACb,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,KAAK,EAAE,CAAC;oBAC7B,aAAa;oBACb,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;gBACxC,CAAC;gBACD,aAAa;gBACb,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;oBAClC,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;gBACtC,CAAC;gBACD,aAAa;gBACb,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;oBAClB,aAAa;oBACb,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,sDAAsD;gBACjG,CAAC;YACL,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YACtD,OAAO,OAAO,EAAE,CAAC;QACrB,CAAC,CAAC,CAAC;IACP,CAAC;CAGJ;AAED,MAAM,CAAN,IAAY,IAKX;AALD,WAAY,IAAI;IACZ,iCAAY,CAAA;IACZ,iCAAY,CAAA;IACZ,iCAAY,CAAA;IACZ,iCAAY,CAAA;AAChB,CAAC,EALW,IAAI,KAAJ,IAAI,QAKf"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Device } from "./device";
|
|
2
|
-
import { IDeviceInterface } from "../interfaces";
|
|
3
|
-
/**
|
|
4
|
-
* @class TechnicColorSensor
|
|
5
|
-
* @extends Device
|
|
6
|
-
*/
|
|
7
|
-
export declare class TechnicColorSensor extends Device {
|
|
8
|
-
constructor(hub: IDeviceInterface, portId: number);
|
|
9
|
-
receive(message: Buffer): void;
|
|
10
|
-
/**
|
|
11
|
-
* Set the brightness (or turn on/off) of the lights around the sensor.
|
|
12
|
-
* @method TechnicColorSensor#setBrightness
|
|
13
|
-
* @param {number} firstSegment First light segment. 0-100 brightness.
|
|
14
|
-
* @param {number} secondSegment Second light segment. 0-100 brightness.
|
|
15
|
-
* @param {number} thirdSegment Third light segment. 0-100 brightness.
|
|
16
|
-
* @returns {Promise} Resolved upon successful issuance of the command.
|
|
17
|
-
*/
|
|
18
|
-
setBrightness(firstSegment: number, secondSegment: number, thirdSegment: number): void;
|
|
19
|
-
}
|
|
20
|
-
export declare enum Mode {
|
|
21
|
-
COLOR = 0,
|
|
22
|
-
REFLECTIVITY = 1,
|
|
23
|
-
AMBIENT_LIGHT = 2
|
|
24
|
-
}
|
|
25
|
-
export declare const ModeMap: {
|
|
26
|
-
[event: string]: number;
|
|
27
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Device } from "./device";
|
|
2
|
-
import * as Consts from "../consts";
|
|
3
|
-
import { parseColor } from "../utils";
|
|
4
|
-
/**
|
|
5
|
-
* @class TechnicColorSensor
|
|
6
|
-
* @extends Device
|
|
7
|
-
*/
|
|
8
|
-
export class TechnicColorSensor extends Device {
|
|
9
|
-
constructor(hub, portId) {
|
|
10
|
-
super(hub, portId, ModeMap, Consts.DeviceType.TECHNIC_COLOR_SENSOR);
|
|
11
|
-
}
|
|
12
|
-
receive(message) {
|
|
13
|
-
const mode = this._mode;
|
|
14
|
-
switch (mode) {
|
|
15
|
-
case Mode.COLOR:
|
|
16
|
-
if (message[4] <= 10) {
|
|
17
|
-
const color = parseColor(message[4]);
|
|
18
|
-
/**
|
|
19
|
-
* Emits when a color sensor is activated.
|
|
20
|
-
* @event TechnicColorSensor#color
|
|
21
|
-
* @type {object}
|
|
22
|
-
* @param {Color} color
|
|
23
|
-
*/
|
|
24
|
-
this.notify("color", { color });
|
|
25
|
-
}
|
|
26
|
-
break;
|
|
27
|
-
case Mode.REFLECTIVITY:
|
|
28
|
-
const reflect = message[4];
|
|
29
|
-
/**
|
|
30
|
-
* Emits when the light reflectivity changes.
|
|
31
|
-
* @event TechnicColorSensor#reflect
|
|
32
|
-
* @type {object}
|
|
33
|
-
* @param {number} reflect Percentage, from 0 to 100.
|
|
34
|
-
*/
|
|
35
|
-
this.notify("reflect", { reflect });
|
|
36
|
-
break;
|
|
37
|
-
case Mode.AMBIENT_LIGHT:
|
|
38
|
-
const ambient = message[4];
|
|
39
|
-
/**
|
|
40
|
-
* Emits when the ambient light changes.
|
|
41
|
-
* @event TechnicColorSensor#ambient
|
|
42
|
-
* @type {object}
|
|
43
|
-
* @param {number} ambient Percentage, from 0 to 100.
|
|
44
|
-
*/
|
|
45
|
-
this.notify("ambient", { ambient });
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Set the brightness (or turn on/off) of the lights around the sensor.
|
|
51
|
-
* @method TechnicColorSensor#setBrightness
|
|
52
|
-
* @param {number} firstSegment First light segment. 0-100 brightness.
|
|
53
|
-
* @param {number} secondSegment Second light segment. 0-100 brightness.
|
|
54
|
-
* @param {number} thirdSegment Third light segment. 0-100 brightness.
|
|
55
|
-
* @returns {Promise} Resolved upon successful issuance of the command.
|
|
56
|
-
*/
|
|
57
|
-
setBrightness(firstSegment, secondSegment, thirdSegment) {
|
|
58
|
-
this.writeDirect(0x03, Buffer.from([firstSegment, secondSegment, thirdSegment]));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export var Mode;
|
|
62
|
-
(function (Mode) {
|
|
63
|
-
Mode[Mode["COLOR"] = 0] = "COLOR";
|
|
64
|
-
Mode[Mode["REFLECTIVITY"] = 1] = "REFLECTIVITY";
|
|
65
|
-
Mode[Mode["AMBIENT_LIGHT"] = 2] = "AMBIENT_LIGHT";
|
|
66
|
-
})(Mode || (Mode = {}));
|
|
67
|
-
export const ModeMap = {
|
|
68
|
-
"color": Mode.COLOR,
|
|
69
|
-
"reflect": Mode.REFLECTIVITY,
|
|
70
|
-
"ambient": Mode.AMBIENT_LIGHT
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=techniccolorsensor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"techniccolorsensor.js","sourceRoot":"","sources":["../../../src/devices/techniccolorsensor.ts"],"names":[],"mapp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I,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACrF,CAAC;CAEJ;AAED,MAAM,CAAN,IAAY,IAIX;AAJD,WAAY,IAAI;IACZ,iCAAY,CAAA;IACZ,+CAAmB,CAAA;IACnB,iDAAoB,CAAA;AACxB,CAAC,EAJW,IAAI,KAAJ,IAAI,QAIf;AAED,MAAM,CAAC,MAAM,OAAO,GAA8B;IAC9C,OAAO,EAAE,IAAI,CAAC,KAAK;IACnB,SAAS,EAAE,IAAI,CAAC,YAAY;IAC5B,SAAS,EAAE,IAAI,CAAC,aAAa;CAChC,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Device } from "./device";
|
|
2
|
-
import { IDeviceInterface } from "../interfaces";
|
|
3
|
-
/**
|
|
4
|
-
* @class TechnicDistanceSensor
|
|
5
|
-
* @extends Device
|
|
6
|
-
*/
|
|
7
|
-
export declare class TechnicDistanceSensor extends Device {
|
|
8
|
-
constructor(hub: IDeviceInterface, portId: number);
|
|
9
|
-
receive(message: Buffer): void;
|
|
10
|
-
/**
|
|
11
|
-
* Set the brightness (or turn on/off) of the lights around the eyes.
|
|
12
|
-
* @method TechnicDistanceSensor#setBrightness
|
|
13
|
-
* @param {number} topLeft Top left quadrant (above left eye). 0-100 brightness.
|
|
14
|
-
* @param {number} bottomLeft Bottom left quadrant (below left eye). 0-100 brightness.
|
|
15
|
-
* @param {number} topRight Top right quadrant (above right eye). 0-100 brightness.
|
|
16
|
-
* @param {number} bottomRight Bottom right quadrant (below right eye). 0-100 brightness.
|
|
17
|
-
* @returns {Promise} Resolved upon successful issuance of the command.
|
|
18
|
-
*/
|
|
19
|
-
setBrightness(topLeft: number, bottomLeft: number, topRight: number, bottomRight: number): void;
|
|
20
|
-
}
|
|
21
|
-
export declare enum Mode {
|
|
22
|
-
DISTANCE = 0,
|
|
23
|
-
FAST_DISTANCE = 1
|
|
24
|
-
}
|
|
25
|
-
export declare const ModeMap: {
|
|
26
|
-
[event: string]: number;
|
|
27
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Device } from "./device";
|
|
2
|
-
import * as Consts from "../consts";
|
|
3
|
-
/**
|
|
4
|
-
* @class TechnicDistanceSensor
|
|
5
|
-
* @extends Device
|
|
6
|
-
*/
|
|
7
|
-
export class TechnicDistanceSensor extends Device {
|
|
8
|
-
constructor(hub, portId) {
|
|
9
|
-
super(hub, portId, ModeMap, Consts.DeviceType.TECHNIC_DISTANCE_SENSOR);
|
|
10
|
-
}
|
|
11
|
-
receive(message) {
|
|
12
|
-
const mode = this._mode;
|
|
13
|
-
switch (mode) {
|
|
14
|
-
case Mode.DISTANCE:
|
|
15
|
-
const distance = message.readUInt16LE(4);
|
|
16
|
-
/**
|
|
17
|
-
* Emits when the detected distance changes (Slow sampling covers 40mm to 2500mm).
|
|
18
|
-
* @event TechnicDistanceSensor#distance
|
|
19
|
-
* @type {object}
|
|
20
|
-
* @param {number} distance Distance, from 40 to 2500mm
|
|
21
|
-
*/
|
|
22
|
-
this.notify("distance", { distance });
|
|
23
|
-
break;
|
|
24
|
-
case Mode.FAST_DISTANCE:
|
|
25
|
-
const fastDistance = message.readUInt16LE(4);
|
|
26
|
-
/**
|
|
27
|
-
* Emits when the detected distance changes (Fast sampling covers 50mm to 320mm).
|
|
28
|
-
* @event TechnicDistanceSensor#fastDistance
|
|
29
|
-
* @type {object}
|
|
30
|
-
* @param {number} fastDistance Distance, from 50 to 320mm
|
|
31
|
-
*/
|
|
32
|
-
this.notify("fastDistance", { fastDistance });
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Set the brightness (or turn on/off) of the lights around the eyes.
|
|
38
|
-
* @method TechnicDistanceSensor#setBrightness
|
|
39
|
-
* @param {number} topLeft Top left quadrant (above left eye). 0-100 brightness.
|
|
40
|
-
* @param {number} bottomLeft Bottom left quadrant (below left eye). 0-100 brightness.
|
|
41
|
-
* @param {number} topRight Top right quadrant (above right eye). 0-100 brightness.
|
|
42
|
-
* @param {number} bottomRight Bottom right quadrant (below right eye). 0-100 brightness.
|
|
43
|
-
* @returns {Promise} Resolved upon successful issuance of the command.
|
|
44
|
-
*/
|
|
45
|
-
setBrightness(topLeft, bottomLeft, topRight, bottomRight) {
|
|
46
|
-
this.writeDirect(0x05, Buffer.from([topLeft, topRight, bottomLeft, bottomRight]));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export var Mode;
|
|
50
|
-
(function (Mode) {
|
|
51
|
-
Mode[Mode["DISTANCE"] = 0] = "DISTANCE";
|
|
52
|
-
Mode[Mode["FAST_DISTANCE"] = 1] = "FAST_DISTANCE";
|
|
53
|
-
})(Mode || (Mode = {}));
|
|
54
|
-
export const ModeMap = {
|
|
55
|
-
"distance": Mode.DISTANCE,
|
|
56
|
-
"fastDistance": Mode.FAST_DISTANCE
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=technicdistancesensor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"technicdistancesensor.js","sourceRoot":"","sources":["../../../src/devices/technicdistancesensor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,MAAM;IAE7C,YAAa,GAAqB,EAAE,MAAc;QAC9C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;IAC3E,CAAC;IAEM,OAAO,CAAE,OAAe;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QAExB,QAAQ,IAAI,EAAE,CAAC;YACX,KAAK,IAAI,CAAC,QAAQ;gBACd,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBAEzC;;;;;mBAKG;gBACH,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;gBACtC,MAAM;YAEV,KAAK,IAAI,CAAC,aAAa;gBACnB,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBAE7C;;;;;mBAKG;gBACH,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC;gBAC9C,MAAM;QACd,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACI,aAAa,CAAE,OAAe,EAAE,UAAkB,EAAE,QAAgB,EAAE,WAAmB;QAC5F,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;CAEJ;AAED,MAAM,CAAN,IAAY,IAGX;AAHD,WAAY,IAAI;IACZ,uCAAe,CAAA;IACf,iDAAoB,CAAA;AACxB,CAAC,EAHW,IAAI,KAAJ,IAAI,QAGf;AAED,MAAM,CAAC,MAAM,OAAO,GAA8B;IAC9C,UAAU,EAAE,IAAI,CAAC,QAAQ;IACzB,cAAc,EAAE,IAAI,CAAC,aAAa;CACrC,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Device } from "./device";
|
|
2
|
-
import { IDeviceInterface } from "../interfaces";
|
|
3
|
-
/**
|
|
4
|
-
* @class TechnicForceSensor
|
|
5
|
-
* @extends Device
|
|
6
|
-
*/
|
|
7
|
-
export declare class TechnicForceSensor extends Device {
|
|
8
|
-
constructor(hub: IDeviceInterface, portId: number);
|
|
9
|
-
receive(message: Buffer): void;
|
|
10
|
-
}
|
|
11
|
-
export declare enum Mode {
|
|
12
|
-
FORCE = 0,
|
|
13
|
-
TOUCHED = 1,
|
|
14
|
-
TAPPED = 2
|
|
15
|
-
}
|
|
16
|
-
export declare const ModeMap: {
|
|
17
|
-
[event: string]: number;
|
|
18
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Device } from "./device";
|
|
2
|
-
import * as Consts from "../consts";
|
|
3
|
-
/**
|
|
4
|
-
* @class TechnicForceSensor
|
|
5
|
-
* @extends Device
|
|
6
|
-
*/
|
|
7
|
-
export class TechnicForceSensor extends Device {
|
|
8
|
-
constructor(hub, portId) {
|
|
9
|
-
super(hub, portId, ModeMap, Consts.DeviceType.TECHNIC_FORCE_SENSOR);
|
|
10
|
-
}
|
|
11
|
-
receive(message) {
|
|
12
|
-
const mode = this._mode;
|
|
13
|
-
switch (mode) {
|
|
14
|
-
case Mode.FORCE:
|
|
15
|
-
const force = message[this.isWeDo2SmartHub ? 2 : 4] / 10;
|
|
16
|
-
/**
|
|
17
|
-
* Emits when force is applied.
|
|
18
|
-
* @event TechnicForceSensor#force
|
|
19
|
-
* @type {object}
|
|
20
|
-
* @param {number} force Force, in newtons (0-10).
|
|
21
|
-
*/
|
|
22
|
-
this.notify("force", { force });
|
|
23
|
-
break;
|
|
24
|
-
case Mode.TOUCHED:
|
|
25
|
-
const touched = message[4] ? true : false;
|
|
26
|
-
/**
|
|
27
|
-
* Emits when the sensor is touched.
|
|
28
|
-
* @event TechnicForceSensor#touch
|
|
29
|
-
* @type {object}
|
|
30
|
-
* @param {boolean} touch Touched on/off (boolean).
|
|
31
|
-
*/
|
|
32
|
-
this.notify("touched", { touched });
|
|
33
|
-
break;
|
|
34
|
-
case Mode.TAPPED:
|
|
35
|
-
const tapped = message[4];
|
|
36
|
-
/**
|
|
37
|
-
* Emits when the sensor is tapped.
|
|
38
|
-
* @event TechnicForceSensor#tapped
|
|
39
|
-
* @type {object}
|
|
40
|
-
* @param {number} tapped How hard the sensor was tapped, from 0-3.
|
|
41
|
-
*/
|
|
42
|
-
this.notify("tapped", { tapped });
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export var Mode;
|
|
48
|
-
(function (Mode) {
|
|
49
|
-
Mode[Mode["FORCE"] = 0] = "FORCE";
|
|
50
|
-
Mode[Mode["TOUCHED"] = 1] = "TOUCHED";
|
|
51
|
-
Mode[Mode["TAPPED"] = 2] = "TAPPED";
|
|
52
|
-
})(Mode || (Mode = {}));
|
|
53
|
-
export const ModeMap = {
|
|
54
|
-
"force": Mode.FORCE,
|
|
55
|
-
"touched": Mode.TOUCHED,
|
|
56
|
-
"tapped": Mode.TAPPED
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=technicforcesensor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"technicforcesensor.js","sourceRoot":"","sources":["../../../src/devices/technicforcesensor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,MAAM;IAE1C,YAAa,GAAqB,EAAE,MAAc;QAC9C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxE,CAAC;IAEM,OAAO,CAAE,OAAe;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QAExB,QAAQ,IAAI,EAAE,CAAC;YACX,KAAK,IAAI,CAAC,KAAK;gBACX,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;gBAEzD;;;;;mBAKG;gBACH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;gBAChC,MAAM;YAEV,KAAK,IAAI,CAAC,OAAO;gBACb,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;gBAE1C;;;;;mBAKG;gBACH,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;gBACpC,MAAM;YAEV,KAAK,IAAI,CAAC,MAAM;gBACZ,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;gBAE1B;;;;;mBAKG;gBACH,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;gBAClC,MAAM;QACd,CAAC;IACL,CAAC;CAEJ;AAED,MAAM,CAAN,IAAY,IAIX;AAJD,WAAY,IAAI;IACZ,iCAAY,CAAA;IACZ,qCAAc,CAAA;IACd,mCAAa,CAAA;AACjB,CAAC,EAJW,IAAI,KAAJ,IAAI,QAIf;AAED,MAAM,CAAC,MAAM,OAAO,GAA8B;IAC9C,OAAO,EAAE,IAAI,CAAC,KAAK;IACnB,SAAS,EAAE,IAAI,CAAC,OAAO;IACvB,QAAQ,EAAE,IAAI,CAAC,MAAM;CACxB,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AbsoluteMotor } from "./absolutemotor";
|
|
2
|
-
import { IDeviceInterface } from "../interfaces";
|
|
3
|
-
import * as Consts from "../consts";
|
|
4
|
-
/**
|
|
5
|
-
* @class TechnicLargeAngularMotor
|
|
6
|
-
* @extends AbsoluteMotor
|
|
7
|
-
*/
|
|
8
|
-
export declare class TechnicLargeAngularMotor extends AbsoluteMotor {
|
|
9
|
-
constructor(hub: IDeviceInterface, portId: number, modeMap?: {
|
|
10
|
-
[event: string]: number;
|
|
11
|
-
}, type?: Consts.DeviceType);
|
|
12
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AbsoluteMotor } from "./absolutemotor";
|
|
2
|
-
import * as Consts from "../consts";
|
|
3
|
-
/**
|
|
4
|
-
* @class TechnicLargeAngularMotor
|
|
5
|
-
* @extends AbsoluteMotor
|
|
6
|
-
*/
|
|
7
|
-
export class TechnicLargeAngularMotor extends AbsoluteMotor {
|
|
8
|
-
constructor(hub, portId, modeMap = {}, type = Consts.DeviceType.TECHNIC_LARGE_ANGULAR_MOTOR) {
|
|
9
|
-
super(hub, portId, {}, type);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=techniclargeangularmotor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"techniclargeangularmotor.js","sourceRoot":"","sources":["../../../src/devices/techniclargeangularmotor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,aAAa;IAEvD,YAAa,GAAqB,EAAE,MAAc,EAAE,UAAqC,EAAE,EAAE,OAA0B,MAAM,CAAC,UAAU,CAAC,2BAA2B;QAChK,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;CAEJ"}
|