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

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 f4ffb34e
# 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.
## Modules to Import
......@@ -56,26 +57,27 @@ getDefaultDisplay(callback: AsyncCallback&lt;Display&gt;): void
Obtains the default display object.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the default display object.|
- Example
**Example**
```js
var displayClass = null;
display.getDefaultDisplay((err, data) => {
```js
var displayClass = null;
display.getDefaultDisplay((err, data) => {
if (err.code) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in obtaining the default display object. Data:' + JSON.stringify(data));
displayClass = data;
});
```
});
```
## display.getDefaultDisplay
......@@ -83,24 +85,24 @@ getDefaultDisplay(): Promise&lt;Display&gt;
Obtains the default display object.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
**System capability**: SystemCapability.WindowManager.WindowManager.Core
- Return value
**Return value**
| Type | Description |
| ---------------------------------- | ---------------------------------------------- |
| Promise&lt;[Display](#display)&gt; | Promise used to return the default display object.|
| Type | Description |
| ---------------------------------- | ---------------------------------------------- |
| Promise&lt;[Display](#display)&gt; | Promise used to return the default display object.|
- Example
**Example**
```js
let promise = display.getDefaultDisplay();
promise.then(() => {
```js
let promise = display.getDefaultDisplay();
promise.then(() => {
console.log('getDefaultDisplay success');
}).catch((err) => {
}).catch((err) => {
console.log('getDefaultDisplay fail: ' + JSON.stringify(err));
});
```
});
```
## display.getAllDisplay
......@@ -108,25 +110,25 @@ getAllDisplay(callback: AsyncCallback&lt;Array&lt;Display&gt;&gt;): void
Obtains all the display objects.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
**System capability**: SystemCapability.WindowManager.WindowManager.Core
- Parameters
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes | Callback used to return all the display objects.|
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes | Callback used to return all the display objects.|
- Example
**Example**
```js
display.getAllDisplay((err, data) => {
```js
display.getAllDisplay((err, data) => {
if (err.code) {
console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
return;
}
console.info('Succeeded in obtaining all the display objects. Data: ' + JSON.stringify(data))
});
```
});
```
## display.getAllDisplay
......@@ -134,24 +136,24 @@ getAllDisplay(): Promise&lt;Array&lt;Display&gt;&gt;
Obtains all the display objects.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
**System capability**: SystemCapability.WindowManager.WindowManager.Core
- Return value
**Return value**
| Type | Description |
| ----------------------------------------------- | ------------------------------------------------------- |
| Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return an array containing all the display objects.|
| Type | Description |
| ----------------------------------------------- | ------------------------------------------------------- |
| Promise&lt;Array&lt;[Display](#display)&gt;&gt; | Promise used to return an array containing all the display objects.|
- Example
**Example**
```js
let promise = display.getAllDisplay();
promise.then(() => {
```js
let promise = display.getAllDisplay();
promise.then(() => {
console.log('getAllDisplay success');
}).catch((err) => {
}).catch((err) => {
console.log('getAllDisplay fail: ' + JSON.stringify(err));
});
```
});
```
## display.on('add'|'remove'|'change')
......@@ -159,23 +161,24 @@ on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void
Enables listening.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
- Parameters
| 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|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
| 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|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
- Example
**Example**
```js
var type = "add";
var callback = (data) => {
```js
var type = "add";
var callback = (data) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data))
}
display.on(type, callback);
```
}
display.on(type, callback);
```
## display.off('add'|'remove'|'change')
......@@ -184,17 +187,18 @@ off(type: 'add'|'remove'|'change', callback?: Callback&lt;number&gt;): void
Disables listening.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Parameters**
- Parameters
| 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|
| callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
| 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|
| callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
- Example
**Example**
```js
var type = "remove";
display.off(type);
```
```js
var type = "remove";
display.off(type);
```
\ No newline at end of file
# 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.
## Modules to Import
......@@ -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.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Required permissions**: ohos.permission.CAPTURE_SCREEN
- Parameters
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| 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. |
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| 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. |
- Example
**Example**
```js
var ScreenshotOptions = {
```js
var ScreenshotOptions = {
"screenRect": {
"left": 200,
"top": 100,
......@@ -78,15 +79,15 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal
"width": 300,
"height": 300},
"rotation": 0
};
screenshot.save(ScreenshotOptions, (err, data) => {
};
screenshot.save(ScreenshotOptions, (err, data) => {
if (err) {
console.error('Failed to save the screenshot. Error: ' + JSON.stringify(err));
return;
}
console.info('Screenshot saved. Data: ' + JSON.stringify(data));
});
```
});
```
## screenshot.save
......@@ -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.
**System capabilities**: SystemCapability.WindowManager.WindowManager.Core
**System capability**: SystemCapability.WindowManager.WindowManager.Core
**Required permissions**: ohos.permission.CAPTURE_SCREEN
- Parameters
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.|
| Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| 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 |
| ----------------------------- | ----------------------------------------------- |
| Promise&lt;image.PixelMap&gt; | Promise used to return an **image.PixelMap** object.|
| Type | Description |
| ----------------------------- | ----------------------------------------------- |
| Promise&lt;image.PixelMap&gt; | Promise used to return an **image.PixelMap** object.|
- Example
**Example**
```js
var ScreenshotOptions = {
```js
var ScreenshotOptions = {
"screenRect": {
"left": 200,
"top": 100,
......@@ -123,11 +124,11 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro
"width": 300,
"height": 300},
"rotation": 0
};
let promise = screenshot.save(ScreenshotOptions);
promise.then(() => {
};
let promise = screenshot.save(ScreenshotOptions);
promise.then(() => {
console.log('screenshot save success');
}).catch((err) => {
}).catch((err) => {
console.log('screenshot save fail: ' + JSON.stringify(err));
});
```
});
```
\ No newline at end of file
# 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.
## Modules to Import
......@@ -17,18 +18,20 @@ Obtains the USB device list.
**System capability**: SystemCapability.USB.USBManager
- Return value
| Type| Description|
| -------- | -------- |
| Array&lt;Readonly&lt;[USBDevice](#usbdevice)&gt;&gt; | Device information list.|
- Example
```
let devicesList = usb.getDevices();
console.log(`devicesList = ${JSON.stringify(devicesList)}`);
// devicesList is a list of USB devices.
// A simple example of devicesList is provided as follows:
[
**Return value**
| Type| Description|
| -------- | -------- |
| Array&lt;Readonly&lt;[USBDevice](#usbdevice)&gt;&gt; | Device information list.|
**Example**
```
let devicesList = usb.getDevices();
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",
serial: "",
......@@ -75,8 +78,8 @@ Obtains the USB device list.
},
],
},
]
```
]
```
## usb.connectDevice
......@@ -89,21 +92,24 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| device | [USBDevice](#usbdevice) | Yes| USB device information.|
**Parameters**
- Return value
| Type| Description|
| -------- | -------- |
| Readonly&lt;[USBDevicePipe](#usbdevicepipe)&gt; | USB device pipe for data transfer.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| device | [USBDevice](#usbdevice) | Yes| USB device information.|
- Example
```
let devicepipe= usb.connectDevice(device);
console.log(`devicepipe = ${JSON.stringify(devicepipe)}`);
```
**Return value**
| Type| Description|
| -------- | -------- |
| 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
......@@ -114,22 +120,25 @@ Checks whether the application has the permission to access the device.
**System capability**: SystemCapability.USB.USBManager
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.|
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.|
**Return value**
- Return value
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.|
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise.|
- Example
```
let divicesName="1-1";
let bool = usb.hasRight(divicesName);
console.log(bool);
```
**Example**
```
let divicesName="1-1";
let bool = usb.hasRight(divicesName);
console.log(bool);
```
## usb.requestRight
......@@ -140,23 +149,26 @@ Requests the temporary permission for the application to access the USB device.
**System capability**: SystemCapability.USB.USBManager
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name.|
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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
| Type| Description|
| -------- | -------- |
| Promise&lt;boolean&gt; | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise.|
**Example**
- Example
```
let divicesName="1-1";
usb.requestRight(divicesName).then((ret) => {
```
let divicesName="1-1";
usb.requestRight(divicesName).then((ret) => {
console.log(`requestRight = ${JSON.stringify(ret)}`);
});
```
});
```
## usb.claimInterface
......@@ -169,23 +181,26 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
| 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.|
| force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface.|
**Parameters**
| 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.|
| 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
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.|
**Return value**
- Example
```
let ret = usb.claimInterface(devicepipe, interfaces);
console.log(`claimInterface = ${ret}`);
```
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise.|
**Example**
```
let ret = usb.claimInterface(devicepipe, interfaces);
console.log(`claimInterface = ${ret}`);
```
## usb.releaseInterface
......@@ -198,22 +213,25 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c
**System capability**: SystemCapability.USB.USBManager
- Parameters
| 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.|
**Parameters**
| 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.|
**Return value**
- Return value
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.|
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully released; returns an error code otherwise.|
- Example
```
let ret = usb.releaseInterface(devicepipe, interfaces);
console.log(`releaseInterface = ${ret}`);
```
**Example**
```
let ret = usb.releaseInterface(devicepipe, interfaces);
console.log(`releaseInterface = ${ret}`);
```
## usb.setConfiguration
......@@ -226,22 +244,25 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- 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.|
**Parameters**
- Return value
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise.|
| 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.|
- Example
```
let ret = usb.setConfiguration(devicepipe, config);
console.log(`setConfiguration = ${ret}`);
```
**Return value**
| Type| Description|
| -------- | -------- |
| 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
......@@ -254,22 +275,25 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
| 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.|
**Parameters**
| 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.|
- Return value
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.|
**Return value**
- Example
```
let ret = usb.setInterface(devicepipe, interfaces);
console.log(`setInterface = ${ret}`);
```
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise.|
**Example**
```
let ret = usb.setInterface(devicepipe, interfaces);
console.log(`setInterface = ${ret}`);
```
## usb.getRawDescriptor
......@@ -282,20 +306,23 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
- Return value
| Type| Description|
| -------- | -------- |
| Uint8Array | Raw descriptor data.|
**Return value**
- Example
```
let ret = usb.getRawDescriptor(devicepipe);
```
| Type| Description|
| -------- | -------- |
| Uint8Array | Raw descriptor data.|
**Example**
```
let ret = usb.getRawDescriptor(devicepipe);
```
## usb.getFileDescriptor
......@@ -308,20 +335,23 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
**Parameters**
- Return value
| Type| Description|
| -------- | -------- |
| number | File descriptor of the USB device.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address.|
- Example
```
let ret = usb.getFileDescriptor(devicepipe);
```
**Return value**
| Type| Description|
| -------- | -------- |
| number | File descriptor of the USB device.|
**Example**
```
let ret = usb.getFileDescriptor(devicepipe);
```
## usb.controlTransfer
......@@ -334,24 +364,27 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
| 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.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.|
- Return value
| Type| Description|
| -------- | -------- |
| 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.|
- Example
```
usb.controlTransfer(devicepipe, USBControlParams).then((ret) => {
**Parameters**
| 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.|
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout.|
**Return value**
| Type| Description|
| -------- | -------- |
| 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.|
**Example**
```
usb.controlTransfer(devicepipe, USBControlParams).then((ret) => {
console.log(`controlTransfer = ${JSON.stringify(ret)}`);
})
```
})
```
## usb.bulkTransfer
......@@ -364,28 +397,31 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
| 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.|
| 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|
| -------- | -------- |
| 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.|
- Example
```
// 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) => {
**Parameters**
| 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.|
| 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|
| -------- | -------- |
| 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.|
**Example**
```
// 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)}`);
});
```
});
```
## usb.closePipe
......@@ -398,21 +434,24 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager
- Parameters
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.|
- Return value
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.|
- Example
```
let ret = usb.closePipe(devicepipe);
console.log(`closePipe = ${ret}`);
```
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe.|
**Return value**
| Type| Description|
| -------- | -------- |
| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise.|
**Example**
```
let ret = usb.closePipe(devicepipe);
console.log(`closePipe = ${ret}`);
```
## USBEndpoint
......
# 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.
......@@ -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:
```
```js
// Obtain the <canvas> component instance.
const el = this.$refs.canvas1;
// Obtain the WebGL context from the <canvas> component instance.
......@@ -87,7 +88,7 @@ gl.clearColor(0.0, 0.0, 0.0, 1.0);
WebGLContextAttributes
| Name| Type| Mandatory|
| Name| Type| Mandatory|
| -------- | -------- | -------- |
| alpha | boolean | No|
| depth | boolean | No|
......@@ -104,7 +105,7 @@ WebGLContextAttributes
WebGLActiveInfo
| Name| Type| Mandatory|
| Name| Type| Mandatory|
| -------- | -------- | -------- |
| size | GLint | Yes|
| type | GLenum | Yes|
......@@ -115,7 +116,7 @@ WebGLActiveInfo
WebGLShaderPrecisionFormat
| Name| Type| Mandatory|
| Name| Type| Mandatory|
| -------- | -------- | -------- |
| rangeMin | GLint | Yes|
| rangeMax | GLint | Yes|
......@@ -129,7 +130,7 @@ WebGLRenderingContextBase
### Attributes
| Name| Type| Mandatory|
| Name| Type| Mandatory|
| -------- | -------- | -------- |
| DEPTH_BUFFER_BIT | GLenum | Yes|
| STENCIL_BUFFER_BIT | GLenum | Yes|
......@@ -432,7 +433,7 @@ WebGLRenderingContextBase
### Methods
| Method| Return Value Type|
| Method| Return Value Type|
| -------- | -------- |
| getContextAttributes() | WebGLContextAttributes&nbsp;\|&nbsp;null |
| isContextLost() | boolean |
......@@ -558,7 +559,7 @@ WebGLRenderingContextBase
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;data:&nbsp;BufferSource&nbsp;\|&nbsp;null,&nbsp;usage:&nbsp;GLenum) | void |
......
# 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.
......@@ -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:
```
```js
// Obtain the <canvas> component instance.
const el = this.$refs.canvas1;
// Obtain the WebGL context from the <canvas> component instance.
......@@ -70,7 +71,7 @@ WebGL2RenderingContextBase
### Attributes
| Name| Type| Mandatory|
| Name| Type| Mandatory|
| -------- | -------- | -------- |
| READ_BUFFER | GLenum | Yes|
| UNPACK_ROW_LENGTH | GLenum | Yes|
......@@ -338,7 +339,7 @@ WebGL2RenderingContextBase
### 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 |
| 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
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;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.
先完成此消息的编辑!
想要评论请 注册