提交 30eea4e0 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 f4ffb34e
# Display # Display
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -56,26 +57,27 @@ getDefaultDisplay(callback: AsyncCallback&lt;Display&gt;): void ...@@ -56,26 +57,27 @@ getDefaultDisplay(callback: AsyncCallback&lt;Display&gt;): void
Obtains the default display object. Obtains the default display object.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
- Parameters | Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- | | callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.|
| callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.|
- Example **Example**
```js ```js
var displayClass = null; var displayClass = null;
display.getDefaultDisplay((err, data) => { display.getDefaultDisplay((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err)); console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data)); console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
displayClass = data; displayClass = data;
}); });
``` ```
## display.getDefaultDisplay ## display.getDefaultDisplay
...@@ -83,24 +85,24 @@ getDefaultDisplay(): Promise&lt;Display&gt; ...@@ -83,24 +85,24 @@ getDefaultDisplay(): Promise&lt;Display&gt;
Obtains the default display object. Obtains the default display object.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
- Return value **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ---------------------------------------------- | | ---------------------------------- | ---------------------------------------------- |
| Promise&lt;[Display](#display)&gt; | Promise used to return the default display object.| | Promise&lt;[Display](#display)&gt; | Promise used to return the default display object.|
- Example **Example**
```js ```js
let promise = display.getDefaultDisplay(); let promise = display.getDefaultDisplay();
promise.then(() => { promise.then(() => {
console.log('getDefaultDisplay success'); console.log('getDefaultDisplay success');
}).catch((err) => { }).catch((err) => {
console.log('getDefaultDisplay fail: ' + JSON.stringify(err)); console.log('getDefaultDisplay fail: ' + JSON.stringify(err));
}); });
``` ```
## display.getAllDisplay ## display.getAllDisplay
...@@ -108,25 +110,25 @@ getAllDisplay(callback: AsyncCallback&lt;Array&lt;Display&gt;&gt;): void ...@@ -108,25 +110,25 @@ getAllDisplay(callback: AsyncCallback&lt;Array&lt;Display&gt;&gt;): void
Obtains all the display objects. Obtains all the display objects.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ------------------------------- | | -------- | ---------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes | Callback used to return all the display objects.| | callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes | Callback used to return all the display objects.|
- Example **Example**
```js ```js
display.getAllDisplay((err, data) => { display.getAllDisplay((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err)); console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data)) console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data))
}); });
``` ```
## display.getAllDisplay ## display.getAllDisplay
...@@ -134,24 +136,24 @@ getAllDisplay(): Promise&lt;Array&lt;Display&gt;&gt; ...@@ -134,24 +136,24 @@ getAllDisplay(): Promise&lt;Array&lt;Display&gt;&gt;
Obtains all the display objects. Obtains all the display objects.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
- Return value **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------------- | ------------------------------------------------------- | | ----------------------------------------------- | ------------------------------------------------------- |
| Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return an array containing all the display objects.| | Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return an array containing all the display objects.|
- Example **Example**
```js ```js
let promise = display.getAllDisplay(); let promise = display.getAllDisplay();
promise.then(() => { promise.then(() => {
console.log('getAllDisplay success'); console.log('getAllDisplay success');
}).catch((err) => { }).catch((err) => {
console.log('getAllDisplay fail: ' + JSON.stringify(err)); console.log('getAllDisplay fail: ' + JSON.stringify(err));
}); });
``` ```
## display.on('add'|'remove'|'change') ## display.on('add'|'remove'|'change')
...@@ -159,23 +161,24 @@ on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void ...@@ -159,23 +161,24 @@ on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void
Enables listening. Enables listening.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
- Parameters | Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- | | type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed|
| type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed| | callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
- Example **Example**
```js ```js
var type = "add"; var type = "add";
var callback = (data) => { var callback = (data) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data)) console.info('Listening enabled. Data: ' + JSON.stringify(data))
} }
display.on(type, callback); display.on(type, callback);
``` ```
## display.off('add'|'remove'|'change') ## display.off('add'|'remove'|'change')
...@@ -184,17 +187,18 @@ off(type: 'add'|'remove'|'change', callback?: Callback&lt;number&gt;): void ...@@ -184,17 +187,18 @@ off(type: 'add'|'remove'|'change', callback?: Callback&lt;number&gt;): void
Disables listening. Disables listening.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
- Parameters | Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- | | type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed|
| type | string | Yes| Listening type. The available values are as follows:<br>-&nbsp;**add**: listening for whether a display is added<br>-&nbsp;**remove**: listening for whether a display is removed<br>-&nbsp;**change**: listening for whether a display is changed| | callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
| callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
- Example **Example**
```js ```js
var type = "remove"; var type = "remove";
display.off(type); display.off(type);
``` ```
\ No newline at end of file
# Screenshot # Screenshot
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -54,21 +55,21 @@ save(options?: ScreenshotOptions, callback: AsyncCallback&lt;image.PixelMap&gt;) ...@@ -54,21 +55,21 @@ save(options?: ScreenshotOptions, callback: AsyncCallback&lt;image.PixelMap&gt;)
Takes a screenshot and saves it as a **PixelMap** object. This method uses a callback to return the result. Takes a screenshot and saves it as a **PixelMap** object. This method uses a callback to return the result.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Required permissions**: ohos.permission.CAPTURE_SCREEN **Required permissions**: ohos.permission.CAPTURE_SCREEN
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.|
| callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return a **PixelMap** object. | | callback | AsyncCallback&lt;image.PixelMap&gt; | Yes | Callback used to return a **PixelMap** object. |
- Example **Example**
```js ```js
var ScreenshotOptions = { var ScreenshotOptions = {
"screenRect": { "screenRect": {
"left": 200, "left": 200,
"top": 100, "top": 100,
...@@ -78,15 +79,15 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal ...@@ -78,15 +79,15 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal
"width": 300, "width": 300,
"height": 300}, "height": 300},
"rotation": 0 "rotation": 0
}; };
screenshot.save(ScreenshotOptions, (err, data) => { screenshot.save(ScreenshotOptions, (err, data) => {
if (err) { if (err) {
console.error('Failed to save the screenshot. Error: ' + JSON.stringify(err)); console.error('Failed to save the screenshot. Error: ' + JSON.stringify(err));
return; return;
} }
console.info('Screenshot saved. Data: ' + JSON.stringify(data)); console.info('Screenshot saved. Data: ' + JSON.stringify(data));
}); });
``` ```
## screenshot.save ## screenshot.save
...@@ -94,26 +95,26 @@ save(options?: ScreenshotOptions): Promise&lt;image.PixelMap&gt; ...@@ -94,26 +95,26 @@ save(options?: ScreenshotOptions): Promise&lt;image.PixelMap&gt;
Takes a screenshot and saves it as a **PixelMap** object. This method uses a promise to return the result. Takes a screenshot and saves it as a **PixelMap** object. This method uses a promise to return the result.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core **System capability**: SystemCapability.WindowManager.WindowManager.Core
**Required permissions**: ohos.permission.CAPTURE_SCREEN **Required permissions**: ohos.permission.CAPTURE_SCREEN
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| | options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.|
- Return value **Return value**
| Type | Description | | Type | Description |
| ----------------------------- | ----------------------------------------------- | | ----------------------------- | ----------------------------------------------- |
| Promise&lt;image.PixelMap&gt; | Promise used to return an **image.PixelMap** object.| | Promise&lt;image.PixelMap&gt; | Promise used to return an **image.PixelMap** object.|
- Example **Example**
```js ```js
var ScreenshotOptions = { var ScreenshotOptions = {
"screenRect": { "screenRect": {
"left": 200, "left": 200,
"top": 100, "top": 100,
...@@ -123,11 +124,11 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro ...@@ -123,11 +124,11 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro
"width": 300, "width": 300,
"height": 300}, "height": 300},
"rotation": 0 "rotation": 0
}; };
let promise = screenshot.save(ScreenshotOptions); let promise = screenshot.save(ScreenshotOptions);
promise.then(() => { promise.then(() => {
console.log('screenshot save success'); console.log('screenshot save success');
}).catch((err) => { }).catch((err) => {
console.log('screenshot save fail: ' + JSON.stringify(err)); console.log('screenshot save fail: ' + JSON.stringify(err));
}); });
``` ```
\ No newline at end of file
# USB # USB
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -17,18 +18,20 @@ Obtains the USB device list. ...@@ -17,18 +18,20 @@ Obtains the USB device list.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Return value **Return value**
| Type| Description|
| -------- | -------- | | Type| Description|
| Array&lt;Readonly&lt;[USBDevice](#usbdevice)&gt;&gt; | Device information list.| | -------- | -------- |
| Array&lt;Readonly&lt;[USBDevice](#usbdevice)&gt;&gt; | Device information list.|
- Example
``` **Example**
let devicesList = usb.getDevices();
console.log(`devicesList = ${JSON.stringify(devicesList)}`); ```
// devicesList is a list of USB devices. let devicesList = usb.getDevices();
// A simple example of devicesList is provided as follows: console.log(`devicesList = ${JSON.stringify(devicesList)}`);
[ // devicesList is a list of USB devices.
// A simple example of devicesList is provided as follows:
[
{ {
name: "1-1", name: "1-1",
serial: "", serial: "",
...@@ -75,8 +78,8 @@ Obtains the USB device list. ...@@ -75,8 +78,8 @@ Obtains the USB device list.
}, },
], ],
}, },
] ]
``` ```
## usb.connectDevice ## usb.connectDevice
...@@ -89,21 +92,24 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -89,21 +92,24 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| device | [USBDevice](#usbdevice) | Yes| USB device information.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | device | [USBDevice](#usbdevice) | Yes| USB device information.|
| Readonly&lt;[USBDevicePipe](#usbdevicepipe)&gt; | USB device pipe for data transfer.|
- Example **Return value**
```
let devicepipe= usb.connectDevice(device); | Type| Description|
console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); | -------- | -------- |
``` | Readonly&lt;[USBDevicePipe](#usbdevicepipe)&gt; | USB device pipe for data transfer.|
**Example**
```
let devicepipe= usb.connectDevice(device);
console.log(`devicepipe = ${JSON.stringify(devicepipe)}`);
```
## usb.hasRight ## usb.hasRight
...@@ -114,22 +120,25 @@ Checks whether the application has the permission to access the device. ...@@ -114,22 +120,25 @@ Checks whether the application has the permission to access the device.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| deviceName | string | Yes| Device name.| | -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.|
**Return value**
- Return value | Type| Description|
| Type| Description| | -------- | -------- |
| -------- | -------- | | boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.|
| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.|
- Example **Example**
```
let divicesName="1-1"; ```
let bool = usb.hasRight(divicesName); let divicesName="1-1";
console.log(bool); let bool = usb.hasRight(divicesName);
``` console.log(bool);
```
## usb.requestRight ## usb.requestRight
...@@ -140,23 +149,26 @@ Requests the temporary permission for the application to access the USB device. ...@@ -140,23 +149,26 @@ Requests the temporary permission for the application to access the USB device.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| deviceName | string | Yes| Device name.| | -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise.|
- Return value **Example**
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise.|
- Example ```
``` let divicesName="1-1";
let divicesName="1-1"; usb.requestRight(divicesName).then((ret) => {
usb.requestRight(divicesName).then((ret) => {
console.log(`requestRight = ${JSON.stringify(ret)}`); console.log(`requestRight = ${JSON.stringify(ret)}`);
}); });
``` ```
## usb.claimInterface ## usb.claimInterface
...@@ -169,23 +181,26 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -169,23 +181,26 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | -------- | -------- | -------- | -------- |
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.| | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to claim.|
| force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.|
- Return value **Return value**
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.|
- Example | Type| Description|
``` | -------- | -------- |
let ret = usb.claimInterface(devicepipe, interfaces); | number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.|
console.log(`claimInterface = ${ret}`);
``` **Example**
```
let ret = usb.claimInterface(devicepipe, interfaces);
console.log(`claimInterface = ${ret}`);
```
## usb.releaseInterface ## usb.releaseInterface
...@@ -198,22 +213,25 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c ...@@ -198,22 +213,25 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | -------- | -------- | -------- | -------- |
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release.|
**Return value**
- Return value | Type| Description|
| Type| Description| | -------- | -------- |
| -------- | -------- | | number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.|
| number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.|
- Example **Example**
```
let ret = usb.releaseInterface(devicepipe, interfaces); ```
console.log(`releaseInterface = ${ret}`); let ret = usb.releaseInterface(devicepipe, interfaces);
``` console.log(`releaseInterface = ${ret}`);
```
## usb.setConfiguration ## usb.setConfiguration
...@@ -226,22 +244,25 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -226,22 +244,25 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| config | [USBConfig](#usbconfig) | Yes| USB configuration to set.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.| | config | [USBConfig](#usbconfig) | Yes| USB configuration to set.|
- Example **Return value**
```
let ret = usb.setConfiguration(devicepipe, config); | Type| Description|
console.log(`setConfiguration = ${ret}`); | -------- | -------- |
``` | number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.|
**Example**
```
let ret = usb.setConfiguration(devicepipe, config);
console.log(`setConfiguration = ${ret}`);
```
## usb.setInterface ## usb.setInterface
...@@ -254,22 +275,25 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -254,22 +275,25 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | -------- | -------- | -------- | -------- |
| iface | [USBInterface](#usbinterface) | Yes| USB interface to set.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| iface | [USBInterface](#usbinterface) | Yes| USB interface to set.|
- Return value **Return value**
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.|
- Example | Type| Description|
``` | -------- | -------- |
let ret = usb.setInterface(devicepipe, interfaces); | number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.|
console.log(`setInterface = ${ret}`);
``` **Example**
```
let ret = usb.setInterface(devicepipe, interfaces);
console.log(`setInterface = ${ret}`);
```
## usb.getRawDescriptor ## usb.getRawDescriptor
...@@ -282,20 +306,23 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -282,20 +306,23 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.| | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
- Return value **Return value**
| Type| Description|
| -------- | -------- |
| Uint8Array | Raw descriptor data.|
- Example | Type| Description|
``` | -------- | -------- |
let ret = usb.getRawDescriptor(devicepipe); | Uint8Array | Raw descriptor data.|
```
**Example**
```
let ret = usb.getRawDescriptor(devicepipe);
```
## usb.getFileDescriptor ## usb.getFileDescriptor
...@@ -308,20 +335,23 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -308,20 +335,23 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
| number | File descriptor of the USB device.|
- Example **Return value**
```
let ret = usb.getFileDescriptor(devicepipe); | Type| Description|
``` | -------- | -------- |
| number | File descriptor of the USB device.|
**Example**
```
let ret = usb.getFileDescriptor(devicepipe);
```
## usb.controlTransfer ## usb.controlTransfer
...@@ -334,24 +364,27 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -334,24 +364,27 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| | -------- | -------- | -------- | -------- |
| contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.| | contrlparam | [USBControlParams](#usbcontrolparams) | Yes| Control transfer parameters.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.|
- Return value
| Type| Description| **Return value**
| -------- | -------- |
| Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.| | Type| Description|
| -------- | -------- |
- Example | Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.|
```
usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { **Example**
```
usb.controlTransfer(devicepipe, USBControlParams).then((ret) => {
console.log(`controlTransfer = ${JSON.stringify(ret)}`); console.log(`controlTransfer = ${JSON.stringify(ret)}`);
}) })
``` ```
## usb.bulkTransfer ## usb.bulkTransfer
...@@ -364,28 +397,31 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -364,28 +397,31 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.| | -------- | -------- | -------- | -------- |
| endpoint | [USBEndpoint](#usbendpoint) | Yes| USB endpoint, which is used to determine the USB port for data transfer.| | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device.|
| buffer | Uint8Array | Yes| Buffer for writing or reading data.| | endpoint | [USBEndpoint](#usbendpoint) | Yes| USB endpoint, which is used to determine the USB port for data transfer.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.| | buffer | Uint8Array | Yes| Buffer for writing or reading data.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.|
- Return value
| Type| Description| **Return value**
| -------- | -------- |
| Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.| | Type| Description|
| -------- | -------- |
- Example | Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs.|
```
// Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission. **Example**
// Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device.
// Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer. ```
usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => { // Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission.
// Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device.
// Call usb.claimInterface to claim the USB interface. After that, call usb.bulkTransfer to start bulk transfer.
usb.bulkTransfer(devicepipe, endpoint, buffer).then((ret) => {
console.log(`bulkTransfer = ${JSON.stringify(ret)}`); console.log(`bulkTransfer = ${JSON.stringify(ret)}`);
}); });
``` ```
## usb.closePipe ## usb.closePipe
...@@ -398,21 +434,24 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -398,21 +434,24 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.| | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.|
- Return value
| Type| Description| **Return value**
| -------- | -------- |
| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.| | Type| Description|
| -------- | -------- |
- Example | number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.|
```
let ret = usb.closePipe(devicepipe); **Example**
console.log(`closePipe = ${ret}`);
``` ```
let ret = usb.closePipe(devicepipe);
console.log(`closePipe = ${ret}`);
```
## USBEndpoint ## USBEndpoint
......
# webgl # webgl
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -22,7 +23,7 @@ Create a **<canvas\>** component in the HML file. The following is an example: ...@@ -22,7 +23,7 @@ Create a **<canvas\>** component in the HML file. The following is an example:
Obtain the **<canvas\>** component instance in the JS file. The following is an example: Obtain the **<canvas\>** component instance in the JS file. The following is an example:
``` ```js
// Obtain the <canvas> component instance. // Obtain the <canvas> component instance.
const el = this.$refs.canvas1; const el = this.$refs.canvas1;
// Obtain the WebGL context from the <canvas> component instance. // Obtain the WebGL context from the <canvas> component instance.
...@@ -87,7 +88,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0); ...@@ -87,7 +88,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0);
WebGLContextAttributes WebGLContextAttributes
| Name| Type| Mandatory| | Name| Type| Mandatory|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| alpha | boolean | No| | alpha | boolean | No|
| depth | boolean | No| | depth | boolean | No|
...@@ -104,7 +105,7 @@ WebGLContextAttributes ...@@ -104,7 +105,7 @@ WebGLContextAttributes
WebGLActiveInfo WebGLActiveInfo
| Name| Type| Mandatory| | Name| Type| Mandatory|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| size | GLint | Yes| | size | GLint | Yes|
| type | GLenum | Yes| | type | GLenum | Yes|
...@@ -115,7 +116,7 @@ WebGLActiveInfo ...@@ -115,7 +116,7 @@ WebGLActiveInfo
WebGLShaderPrecisionFormat WebGLShaderPrecisionFormat
| Name| Type| Mandatory| | Name| Type| Mandatory|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| rangeMin | GLint | Yes| | rangeMin | GLint | Yes|
| rangeMax | GLint | Yes| | rangeMax | GLint | Yes|
...@@ -129,7 +130,7 @@ WebGLRenderingContextBase ...@@ -129,7 +130,7 @@ WebGLRenderingContextBase
### Attributes ### Attributes
| Name| Type| Mandatory| | Name| Type| Mandatory|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| DEPTH_BUFFER_BIT | GLenum | Yes| | DEPTH_BUFFER_BIT | GLenum | Yes|
| STENCIL_BUFFER_BIT | GLenum | Yes| | STENCIL_BUFFER_BIT | GLenum | Yes|
...@@ -432,7 +433,7 @@ WebGLRenderingContextBase ...@@ -432,7 +433,7 @@ WebGLRenderingContextBase
### Methods ### Methods
| Method| Return Value Type| | Method| Return Value Type|
| -------- | -------- | | -------- | -------- |
| getContextAttributes() | WebGLContextAttributes&nbsp;\|&nbsp;null | | getContextAttributes() | WebGLContextAttributes&nbsp;\|&nbsp;null |
| isContextLost() | boolean | | isContextLost() | boolean |
...@@ -558,7 +559,7 @@ WebGLRenderingContextBase ...@@ -558,7 +559,7 @@ WebGLRenderingContextBase
WebGLRenderingContextOverloads WebGLRenderingContextOverloads
| Method| Return Value Type| | Method| Return Value Type|
| -------- | -------- | | -------- | -------- |
| bufferData(target:&nbsp;GLenum,&nbsp;size:&nbsp;GLsizeiptr,&nbsp;usage:&nbsp;GLenum) | void | | bufferData(target:&nbsp;GLenum,&nbsp;size:&nbsp;GLsizeiptr,&nbsp;usage:&nbsp;GLenum) | void |
| bufferData(target:&nbsp;GLenum,&nbsp;data:&nbsp;BufferSource&nbsp;\|&nbsp;null,&nbsp;usage:&nbsp;GLenum) | void | | bufferData(target:&nbsp;GLenum,&nbsp;data:&nbsp;BufferSource&nbsp;\|&nbsp;null,&nbsp;usage:&nbsp;GLenum) | void |
......
# webgl2 # webgl2
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
>
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -22,7 +23,7 @@ Create a **<canvas\>** component in the HML file. The following is an example: ...@@ -22,7 +23,7 @@ Create a **<canvas\>** component in the HML file. The following is an example:
Obtain the **<canvas\>** component instance in the JS file. The following is an example: Obtain the **<canvas\>** component instance in the JS file. The following is an example:
``` ```js
// Obtain the <canvas> component instance. // Obtain the <canvas> component instance.
const el = this.$refs.canvas1; const el = this.$refs.canvas1;
// Obtain the WebGL context from the <canvas> component instance. // Obtain the WebGL context from the <canvas> component instance.
...@@ -70,7 +71,7 @@ WebGL2RenderingContextBase ...@@ -70,7 +71,7 @@ WebGL2RenderingContextBase
### Attributes ### Attributes
| Name| Type| Mandatory| | Name| Type| Mandatory|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| READ_BUFFER | GLenum | Yes| | READ_BUFFER | GLenum | Yes|
| UNPACK_ROW_LENGTH | GLenum | Yes| | UNPACK_ROW_LENGTH | GLenum | Yes|
...@@ -338,7 +339,7 @@ WebGL2RenderingContextBase ...@@ -338,7 +339,7 @@ WebGL2RenderingContextBase
### Methods ### Methods
| Method| Return Value Type| | Method| Return Value Type|
| -------- | -------- | | -------- | -------- |
| copyBufferSubData(readTarget:&nbsp;GLenum,&nbsp;writeTarget:&nbsp;GLenum,&nbsp;readOffset:&nbsp;GLintptr,&nbsp;writeOffset:&nbsp;GLintptr,&nbsp;size:&nbsp;GLsizeiptr) | void | | copyBufferSubData(readTarget:&nbsp;GLenum,&nbsp;writeTarget:&nbsp;GLenum,&nbsp;readOffset:&nbsp;GLintptr,&nbsp;writeOffset:&nbsp;GLintptr,&nbsp;size:&nbsp;GLsizeiptr) | void |
| getBufferSubData(target:&nbsp;GLenum,&nbsp;srcByteOffset:&nbsp;GLintptr,&nbsp;dstBuffer:&nbsp;ArrayBufferView,&nbsp;dstOffset?:&nbsp;GLuint,&nbsp;length?:&nbsp;GLuint) | void | | getBufferSubData(target:&nbsp;GLenum,&nbsp;srcByteOffset:&nbsp;GLintptr,&nbsp;dstBuffer:&nbsp;ArrayBufferView,&nbsp;dstOffset?:&nbsp;GLuint,&nbsp;length?:&nbsp;GLuint) | void |
...@@ -441,7 +442,7 @@ WebGL2RenderingContextBase ...@@ -441,7 +442,7 @@ WebGL2RenderingContextBase
WebGL2RenderingContextOverloads WebGL2RenderingContextOverloads
| Method| Return Value Type| | Method| Return Value Type|
| -------- | -------- | | -------- | -------- |
| bufferData(target:&nbsp;GLenum,&nbsp;size:&nbsp;GLsizeiptr,&nbsp;usage:&nbsp;GLenum) | void | | bufferData(target:&nbsp;GLenum,&nbsp;size:&nbsp;GLsizeiptr,&nbsp;usage:&nbsp;GLenum) | void |
| bufferData(target:&nbsp;GLenum,&nbsp;srcData:&nbsp;BufferSource&nbsp;\|&nbsp;null,&nbsp;usage:&nbsp;GLenum) | void | | bufferData(target:&nbsp;GLenum,&nbsp;srcData:&nbsp;BufferSource&nbsp;\|&nbsp;null,&nbsp;usage:&nbsp;GLenum) | void |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册