• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @addtogroup HdfLight
18 * @{
19 *
20 * @brief Provides APIs for the light service.
21 *
22 * The light module provides a unified interface for the light service to access the light driver.
23 * After obtaining the light driver object or proxy, the service can call related APIs to obtain light information,
24 * turn on or off a light, and set the light blinking mode based on the light id.
25 * @since 3.1
26 */
27
28/**
29 * @file LightTypes.idl
30 *
31 * @brief Defines the light data structure, including the light id, lighting mode,
32 * blinking mode and duration, return values, and lighting effect.
33 * @since 3.1
34 */
35
36package ohos.hdi.light.v1_0;
37
38/**
39 * @brief Enumerates the light ids.
40 *
41 * @since 3.1
42 */
43enum HdfLightId {
44    HDF_LIGHT_ID_BATTERY = 1,
45    HDF_LIGHT_ID_NOTIFICATIONS = 2,
46    HDF_LIGHT_ID_ATTENTION = 3,
47    HDF_LIGHT_ID_BUTT = 4,
48};
49
50/**
51 * @brief Enumerates the light types.
52 *
53 * @since 3.2
54 */
55enum HdfLightType {
56    HDF_LIGHT_TYPE_SINGLE_COLOR = 1,
57    HDF_LIGHT_TYPE_RGB_COLOR = 2,
58    HDF_LIGHT_TYPE_WRGB_COLOR = 3,
59};
60
61/**
62 * @brief Defines the basic light information.
63 *
64 * Basic light information includes the light id, light name, light number and light type.
65 *
66 * @since 3.1
67 */
68struct HdfLightInfo {
69    String lightName;    /** Logic light name. */
70    int lightId;         /** Light id. For details, see {@link HdfLightId}. */
71    int lightNumber;     /** Number of physical lights in the logic controller. */
72    int lightType;       /** Light type. For details, see {@link HdfLightType}. */
73};
74
75/**
76 * @brief Enumerates the lighting modes.
77 *
78 * @since 3.1
79 */
80enum HdfLightFlashMode {
81    HDF_LIGHT_FLASH_NONE = 0,        /** No flicker mode. */
82    HDF_LIGHT_FLASH_BLINK = 1,       /** Timed flashing mode. */
83    HDF_LIGHT_FLASH_GRADIENT = 2,    /** Gradient mode. */
84    HDF_LIGHT_FLASH_BUTT = 3,        /** Invalid mode. */
85};
86
87/**
88 * @brief Defines the blinking parameters.
89 *
90 * The parameters include the blinking mode and the on and off time for the light in a blinking period.
91 *
92 * @since 3.1
93 */
94struct HdfLightFlashEffect {
95   int flashMode;     /** Blinking mode. For details, see {@link HdfLightFlashMode}. */
96   int onTime;        /** Duration (in ms) for which the light is on in a blinking period. */
97   int offTime;       /** Duration (in ms) for which the light is off in a blinking period. */
98};
99
100/**
101 * @brief Defines the color and extended information of the light.
102 *
103 * The parameters include four parameters include red, green, blue values and extended information.
104 *
105 * @since 3.2
106 */
107struct RGBColor {
108    unsigned char r;         /** Red value range 0-255. */
109    unsigned char g;         /** Green value range 0-255. */
110    unsigned char b;         /** Blue value range 0-255. */
111    unsigned char reserved;  /** Custom extended information. */
112};
113
114/**
115 * @brief Defines the color of the light.
116 *
117 * The parameters include the These parameters include red, green, blue and white values.
118 *
119 * @since 3.2
120 */
121struct WRGBColor {
122    unsigned char w;    /** White value range 0-255. */
123    unsigned char r;    /** Red value range 0-255. */
124    unsigned char g;    /** Green value range 0-255. */
125    unsigned char b;    /** Blue value range 0-255. */
126};
127
128/**
129 * @brief Defines three modes for setting the light.
130 *
131 * The parameters include single color mode, RGB mode and WRGB mode.
132 *
133 * @since 3.2
134 */
135union ColorValue
136{
137    int singleColor;             /** Single color mode. */
138    struct WRGBColor wrgbColor;  /** WRGB mode, see {@link WRGBColor}. */
139    struct RGBColor rgbColor;    /** RGB mode, see {@link RGBColor}. */
140};
141
142/**
143 * @brief Defines the color and brightness corresponding to light.
144 *
145 * The parameters include the brightness and WRGB color.
146 *
147 * @since 3.2
148 */
149struct HdfLightColor {
150    union ColorValue colorValue;    /** The modes for setting the light, see {@link union ColorValue}. */
151};
152
153/**
154 * @brief Defines the lighting effect parameters.
155 *
156 * The parameters include the brightness and blinking mode.
157 *
158 * @since 3.1
159 */
160struct HdfLightEffect {
161    struct HdfLightColor lightColor;    /** Color and brightness corresponding to light, see {@link HdfLightColor}. */
162    struct HdfLightFlashEffect flashEffect;    /** Blinking mode. For details, see {@link LightFlashEffect}. */
163};
164