1# @ohos.brightness (Screen Brightness) (System API) 2 3<!--Kit: Basic Services Kit--> 4<!--Subsystem: PowerManager--> 5<!--Owner: @zhang-yinglie; @volcano_wang--> 6<!--Designer: @wangyantian0--> 7<!--Tester: @alien0208--> 8<!--Adviser: @w_Machine_cc--> 9 10The **brightness** module provides an API for setting the screen brightness. 11 12> **NOTE** 13> 14> - 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. 15> 16> - The APIs provided by this module are system APIs. 17 18## Modules to Import 19 20```js 21import brightness from '@ohos.brightness'; 22``` 23 24## brightness.setValue 25 26setValue(value: number): void 27 28Sets the screen brightness. 29 30**System API**: This is a system API. 31 32**System capability**: SystemCapability.PowerManager.DisplayPowerManager 33 34**Parameters** 35 36| Name| Type | Mandatory| Description | 37| ------ | ------ | ---- | ----------------------- | 38| value | number | Yes | Brightness value. Value range: 0 to 255. The value of this parameter must be a number.| 39 40**Error codes** 41 42For details about the error codes, see [Brightness Error Codes](errorcode-brightness.md) and [Universal Error Codes](../errorcode-universal.md). 43 44| ID | Error Message | 45|---------|---------| 46| 4700101 | Failed to connect to the service. | 47| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 48| 202 | Permission verification failed. A non-system application calls a system API. | 49 50**Example:** 51 52```js 53try { 54 brightness.setValue(128); 55} catch(err) { 56 console.error('set brightness failed, err: ' + err); 57} 58``` 59 60## brightness.setValue<sup>11+</sup> 61 62setValue(value: number, continuous: boolean): void 63 64Sets the screen brightness. This API is used for continuous brightness adjustment. To achieve a better performance, set **continuous** to **true** when you start, and set it to **false** after you finish. 65 66**System API**: This is a system API. 67 68**System capability**: SystemCapability.PowerManager.DisplayPowerManager 69 70**Parameters** 71 72| Name| Type | Mandatory| Description | 73| ------ | ------ | ---- | ----------------------- | 74| value | number | Yes | Brightness value. Value range: [0, 255]| 75| continuous | boolean | Yes | Whether the brightness adjustment is continuous. The value **true** indicates that the brightness adjustment is continuous; **false** indicates the opposite. Default value: **false**| 76 77**Error codes** 78 79For details about the error codes, see [Brightness Error Codes](errorcode-brightness.md) and [Universal Error Codes](../errorcode-universal.md). 80 81| ID | Error Message | 82|---------|---------| 83| 4700101 | Failed to connect to the service. | 84| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. | 85| 202 | Permission verification failed. A non-system application calls a system API. | 86 87**Example:** 88 89```js 90try { 91 brightness.setValue(128, true); 92} catch(err) { 93 console.error('set brightness failed, err: ' + err); 94} 95``` 96