diff --git a/DOCS.md b/DOCS.md index 4637f11..f426340 100644 --- a/DOCS.md +++ b/DOCS.md @@ -15,6 +15,19 @@
+## Typedefs + +
+
Devices
+
+
Colors
+
+
ButtonStates
+
+
DuploTrainBaseSounds
+
+
+ ## PoweredUP ⇐ EventEmitter @@ -172,7 +185,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -322,7 +335,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -346,7 +359,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -383,7 +396,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -574,7 +587,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -673,7 +686,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -697,7 +710,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -709,7 +722,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -748,7 +761,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -924,7 +937,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1023,7 +1036,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -1047,7 +1060,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -1059,7 +1072,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1086,7 +1099,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -1200,7 +1213,7 @@ Set the color of the LED on the Remote via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1312,7 +1325,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -1324,7 +1337,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1431,7 +1444,7 @@ Set the color of the LED on the train via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1457,7 +1470,7 @@ Play a built-in train sound. | Param | Type | Description | | --- | --- | --- | -| sound | number | A number representing one of the Train Base sound consts. | +| sound | number | A number representing one of the DuploTrainBaseSounds. | @@ -1583,7 +1596,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -1595,7 +1608,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1610,3 +1623,77 @@ Emits on a speed change. | port | string | | speed | number | + + +## Devices +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| UNKNOWN | number | 0 | +| BASIC_MOTOR | number | 1 | +| TRAIN_MOTOR | number | 2 | +| LED_LIGHTS | number | 8 | +| BOOST_LED | number | 22 | +| WEDO2_TILT | number | 34 | +| WEDO2_DISTANCE | number | 35 | +| BOOST_DISTANCE | number | 37 | +| BOOST_TACHO_MOTOR | number | 38 | +| BOOST_MOVE_HUB_MOTOR | number | 39 | +| BOOST_TILT | number | 40 | +| DUPLO_TRAIN_BASE_MOTOR | number | 41 | +| DUPLO_TRAIN_BASE_SPEAKER | number | 42 | +| DUPLO_TRAIN_BASE_COLOR | number | 43 | +| DUPLO_TRAIN_BASE_SPEEDOMETER | number | 44 | +| POWERED_UP_REMOTE_BUTTON | number | 55 | + + + +## Colors +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| BLACK | number | 0 | +| PINK | number | 1 | +| PURPLE | number | 2 | +| BLUE | number | 3 | +| LIGHT_BLUE | number | 4 | +| CYAN | number | 5 | +| GREEN | number | 6 | +| YELLOW | number | 7 | +| ORANGE | number | 8 | +| RED | number | 9 | +| WHITE | number | 10 | +| NONE | number | 255 | + + + +## ButtonStates +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| PRESSED | number | 0 | +| RELEASED | number | 1 | +| UP | number | 2 | +| DOWN | number | 3 | +| STOP | number | 4 | + + + +## DuploTrainBaseSounds +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| BREAK | number | 3 | +| STATION_DEPARTURE | number | 5 | +| WATER_REFILL | number | 7 | +| HORN | number | 9 | +| STEAM | number | 10 | + diff --git a/README.md b/README.md index fc1b123..56edb3b 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,19 @@ Thanks go to Jorge Pereira ([@JorgePe](https://github.com/JorgePe)), Sebastian R
+## Typedefs + +
+
Devices
+
+
Colors
+
+
ButtonStates
+
+
DuploTrainBaseSounds
+
+
+ ## PoweredUP ⇐ EventEmitter @@ -255,7 +268,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -405,7 +418,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -429,7 +442,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -466,7 +479,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -657,7 +670,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -756,7 +769,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -780,7 +793,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -792,7 +805,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -831,7 +844,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -1007,7 +1020,7 @@ Set the color of the LED on the Hub via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1106,7 +1119,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -1130,7 +1143,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -1142,7 +1155,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1169,7 +1182,7 @@ Emits when a motor or sensor is attached to the Hub. | Param | Type | Description | | --- | --- | --- | | port | string | | -| type | number | A number representing one of the peripheral consts. | +| type | number | A number representing one of the Devices.. | @@ -1283,7 +1296,7 @@ Set the color of the LED on the Remote via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1395,7 +1408,7 @@ Emits when a button is pressed. | Param | Type | Description | | --- | --- | --- | | button | string | | -| state | number | A number representing one of the button state consts. | +| state | number | A number representing one of the ButtonStates. | @@ -1407,7 +1420,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1514,7 +1527,7 @@ Set the color of the LED on the train via a color value. | Param | Type | Description | | --- | --- | --- | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors. | @@ -1540,7 +1553,7 @@ Play a built-in train sound. | Param | Type | Description | | --- | --- | --- | -| sound | number | A number representing one of the Train Base sound consts. | +| sound | number | A number representing one of the DuploTrainBaseSounds. | @@ -1666,7 +1679,7 @@ Emits when a color sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | @@ -1678,7 +1691,7 @@ A combined color and distance event, emits when the sensor is activated. | Param | Type | Description | | --- | --- | --- | | port | string | | -| color | number | A number representing one of the LED color consts. | +| color | number | A number representing one of the LED Colors | | distance | number | Distance, in millimeters. | @@ -1693,3 +1706,77 @@ Emits on a speed change. | port | string | | speed | number | + + +## Devices +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| UNKNOWN | number | 0 | +| BASIC_MOTOR | number | 1 | +| TRAIN_MOTOR | number | 2 | +| LED_LIGHTS | number | 8 | +| BOOST_LED | number | 22 | +| WEDO2_TILT | number | 34 | +| WEDO2_DISTANCE | number | 35 | +| BOOST_DISTANCE | number | 37 | +| BOOST_TACHO_MOTOR | number | 38 | +| BOOST_MOVE_HUB_MOTOR | number | 39 | +| BOOST_TILT | number | 40 | +| DUPLO_TRAIN_BASE_MOTOR | number | 41 | +| DUPLO_TRAIN_BASE_SPEAKER | number | 42 | +| DUPLO_TRAIN_BASE_COLOR | number | 43 | +| DUPLO_TRAIN_BASE_SPEEDOMETER | number | 44 | +| POWERED_UP_REMOTE_BUTTON | number | 55 | + + + +## Colors +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| BLACK | number | 0 | +| PINK | number | 1 | +| PURPLE | number | 2 | +| BLUE | number | 3 | +| LIGHT_BLUE | number | 4 | +| CYAN | number | 5 | +| GREEN | number | 6 | +| YELLOW | number | 7 | +| ORANGE | number | 8 | +| RED | number | 9 | +| WHITE | number | 10 | +| NONE | number | 255 | + + + +## ButtonStates +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| PRESSED | number | 0 | +| RELEASED | number | 1 | +| UP | number | 2 | +| DOWN | number | 3 | +| STOP | number | 4 | + + + +## DuploTrainBaseSounds +**Kind**: global typedef +**Properties** + +| Name | Type | Description | +| --- | --- | --- | +| BREAK | number | 3 | +| STATION_DEPARTURE | number | 5 | +| WATER_REFILL | number | 7 | +| HORN | number | 9 | +| STEAM | number | 10 | + diff --git a/consts.ts b/consts.ts index 1c29f54..45391a6 100644 --- a/consts.ts +++ b/consts.ts @@ -8,6 +8,25 @@ export enum Hubs { } +/** + * @typedef Devices + * @property {number} UNKNOWN 0 + * @property {number} BASIC_MOTOR 1 + * @property {number} TRAIN_MOTOR 2 + * @property {number} LED_LIGHTS 8 + * @property {number} BOOST_LED 22 + * @property {number} WEDO2_TILT 34 + * @property {number} WEDO2_DISTANCE 35 + * @property {number} BOOST_DISTANCE 37 + * @property {number} BOOST_TACHO_MOTOR 38 + * @property {number} BOOST_MOVE_HUB_MOTOR 39 + * @property {number} BOOST_TILT 40 + * @property {number} DUPLO_TRAIN_BASE_MOTOR 41 + * @property {number} DUPLO_TRAIN_BASE_SPEAKER 42 + * @property {number} DUPLO_TRAIN_BASE_COLOR 43 + * @property {number} DUPLO_TRAIN_BASE_SPEEDOMETER 44 + * @property {number} POWERED_UP_REMOTE_BUTTON 55 + */ export enum Devices { UNKNOWN = 0, BASIC_MOTOR = 1, @@ -28,6 +47,21 @@ export enum Devices { } +/** + * @typedef Colors + * @property {number} BLACK 0 + * @property {number} PINK 1 + * @property {number} PURPLE 2 + * @property {number} BLUE 3 + * @property {number} LIGHT_BLUE 4 + * @property {number} CYAN 5 + * @property {number} GREEN 6 + * @property {number} YELLOW 7 + * @property {number} ORANGE 8 + * @property {number} RED 9 + * @property {number} WHITE 10 + * @property {number} NONE 255 + */ export enum Colors { BLACK = 0, PINK = 1, @@ -44,6 +78,14 @@ export enum Colors { } +/** + * @typedef ButtonStates + * @property {number} PRESSED 0 + * @property {number} RELEASED 1 + * @property {number} UP 2 + * @property {number} DOWN 3 + * @property {number} STOP 4 + */ export enum ButtonStates { PRESSED = 0, RELEASED = 1, @@ -53,6 +95,14 @@ export enum ButtonStates { } +/** + * @typedef DuploTrainBaseSounds + * @property {number} BREAK 3 + * @property {number} STATION_DEPARTURE 5 + * @property {number} WATER_REFILL 7 + * @property {number} HORN 9 + * @property {number} STEAM 10 + */ export enum DuploTrainBaseSounds { BREAK = 3, STATION_DEPARTURE = 5, diff --git a/duplotrainbase.ts b/duplotrainbase.ts index 79ede2b..21ae00f 100644 --- a/duplotrainbase.ts +++ b/duplotrainbase.ts @@ -81,7 +81,7 @@ export class DuploTrainBase extends LPF2Hub { /** * Set the color of the LED on the train via a color value. * @method DuploTrainBase#setLEDColor - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors. * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { @@ -138,7 +138,7 @@ export class DuploTrainBase extends LPF2Hub { /** * Play a built-in train sound. * @method DuploTrainBase#playSound - * @param {number} sound A number representing one of the Train Base sound consts. + * @param {number} sound A number representing one of the DuploTrainBaseSounds. * @returns {Promise} Resolved upon successful issuance of command. */ public playSound (sound: number) { diff --git a/hub.ts b/hub.ts index c257a4f..e462875 100644 --- a/hub.ts +++ b/hub.ts @@ -257,7 +257,7 @@ export class Hub extends EventEmitter { * Emits when a motor or sensor is attached to the Hub. * @event Hub#attach * @param {string} port - * @param {number} type A number representing one of the peripheral consts. + * @param {number} type A number representing one of the Devices.. */ this.emit("attach", port.id, type); } diff --git a/lpf2hub.ts b/lpf2hub.ts index 89ec217..08d74b8 100644 --- a/lpf2hub.ts +++ b/lpf2hub.ts @@ -75,7 +75,7 @@ export class LPF2Hub extends Hub { /** * Set the color of the LED on the Hub via a color value. * @method LPF2Hub#setLEDColor - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors. * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { @@ -186,7 +186,7 @@ export class LPF2Hub extends Hub { * Emits when a button is pressed. * @event LPF2Hub#button * @param {string} button - * @param {number} state A number representing one of the button state consts. + * @param {number} state A number representing one of the ButtonStates. */ this.emit("button", "GREEN", Consts.ButtonStates.PRESSED); return; @@ -289,7 +289,7 @@ export class LPF2Hub extends Hub { * Emits when a color sensor is activated. * @event LPF2Hub#color * @param {string} port - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors */ if (data[4] <= 10) { this.emit("color", port.id, data[4]); @@ -310,7 +310,7 @@ export class LPF2Hub extends Hub { * A combined color and distance event, emits when the sensor is activated. * @event LPF2Hub#colorAndDistance * @param {string} port - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors * @param {number} distance Distance, in millimeters. */ if (data[4] <= 10) { diff --git a/package.json b/package.json index 7f34a33..b59cf46 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "types": "dist/index.d.ts", "scripts": { "build": "tslint -c tslint.json \"*.ts\" && tsc", - "docs": "jsdoc2md dist/poweredup.js dist/lpf2hub.js dist/wedo2smarthub.js dist/boostmovehub.js dist/puphub.js dist/pupremote.js dist/duplotrainbase.js dist/hub.js dist/consts.js > DOCS.md", + "docs": "jsdoc2md dist/consts.js dist/poweredup.js dist/lpf2hub.js dist/wedo2smarthub.js dist/boostmovehub.js dist/puphub.js dist/pupremote.js dist/duplotrainbase.js dist/hub.js dist/consts.js > DOCS.md", "readme": "cat ABOUT.md DOCS.md > README.md", "all": "npm run build && npm run docs && npm run readme", "prepublishOnly": "npm run build" diff --git a/pupremote.ts b/pupremote.ts index a16b4b0..82e790f 100644 --- a/pupremote.ts +++ b/pupremote.ts @@ -85,7 +85,7 @@ export class PUPRemote extends LPF2Hub { /** * Set the color of the LED on the Remote via a color value. * @method PUPRemote#setLEDColor - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors. * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { diff --git a/wedo2smarthub.ts b/wedo2smarthub.ts index 99b7923..ec6193a 100644 --- a/wedo2smarthub.ts +++ b/wedo2smarthub.ts @@ -87,7 +87,7 @@ export class WeDo2SmartHub extends Hub { /** * Set the color of the LED on the Hub via a color value. * @method WeDo2SmartHub#setLEDColor - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors. * @returns {Promise} Resolved upon successful issuance of command. */ public setLEDColor (color: number | boolean) { @@ -276,7 +276,7 @@ export class WeDo2SmartHub extends Hub { * Emits when a button is pressed. * @event WeDo2SmartHub#button * @param {string} button - * @param {number} state A number representing one of the button state consts. + * @param {number} state A number representing one of the ButtonStates. */ this.emit("button", "GREEN", Consts.ButtonStates.PRESSED); return; @@ -315,7 +315,7 @@ export class WeDo2SmartHub extends Hub { * Emits when a color sensor is activated. * @event WeDo2SmartHub#color * @param {string} port - * @param {number} color A number representing one of the LED color consts. + * @param {number} color A number representing one of the LED Colors. */ this.emit("color", port.id, distance); break;