harmony 鸿蒙@ohos.brightness (Screen Brightness)

  • 2022-08-09
  • 浏览 (790)

@ohos.brightness (Screen Brightness)

The brightness module provides an API for setting the screen brightness.

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 APIs provided by this module are system APIs.

Modules to Import

import brightness from '@ohos.brightness';

brightness.setValue

setValue(value: number): void

Sets the screen brightness.

System API: This is a system API.

System capability: SystemCapability.PowerManager.DisplayPowerManager

Parameters

Name Type Mandatory Description
value number Yes Brightness value. The value ranges from 0 to 255.

Error codes

For details about the error codes, see Screen Brightness Error Codes.

ID Error Message
4700101 If connecting to the service failed.

Example

try {
    brightness.setValue(128);
} catch(err) {
    console.error('set brightness failed, err: ' + err);
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙APIs

harmony 鸿蒙System Common Events (To Be Deprecated Soon)

harmony 鸿蒙System Common Events

harmony 鸿蒙API Reference Document Description

harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)

harmony 鸿蒙BundleStatusCallback

harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)

harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)

harmony 鸿蒙@ohos.bundle (Bundle)

harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)

0  赞