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 Light 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 light_type.h 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 36 #ifndef LIGHT_TYPE_H 37 #define LIGHT_TYPE_H 38 39 #include <stdint.h> 40 41 #ifdef __cplusplus 42 #if __cplusplus 43 extern "C" { 44 #endif 45 #endif /* __cplusplus */ 46 47 #define NAME_MAX_LEN 16 48 49 /** 50 * @brief Enumerates the return values of the light module. 51 * 52 * @since 3.1 53 */ 54 enum LightStatus { 55 /** The operation is successful. */ 56 LIGHT_SUCCESS = 0, 57 /** The light id is not supported. */ 58 LIGHT_NOT_SUPPORT = -1, 59 /** Blinking setting is not supported. */ 60 LIGHT_NOT_FLASH = -2, 61 /** Brightness setting is not supported. */ 62 LIGHT_NOT_BRIGHTNESS = -3, 63 }; 64 65 /** 66 * @brief Enumerates the light ids. 67 * 68 * @since 3.1 69 */ 70 enum LightId { 71 /** Unknown id */ 72 LIGHT_ID_NONE = 0, 73 /** Power light */ 74 LIGHT_ID_BATTERY = 1, 75 /** Notification light */ 76 LIGHT_ID_NOTIFICATIONS = 2, 77 /** Alarm light */ 78 LIGHT_ID_ATTENTION = 3, 79 /** Invalid id */ 80 LIGHT_ID_BUTT = 4, 81 }; 82 83 /** 84 * @brief Enumerates the light types. 85 * 86 * @since 3.2 87 */ 88 enum HdfLightType { 89 HDF_LIGHT_TYPE_SINGLE_COLOR = 1, 90 HDF_LIGHT_TYPE_RGB_COLOR = 2, 91 HDF_LIGHT_TYPE_WRGB_COLOR = 3, 92 }; 93 94 /** 95 * @brief Enumerates the lighting modes. 96 * 97 * @since 3.1 98 */ 99 enum LightFlashMode { 100 /** Steady on */ 101 LIGHT_FLASH_NONE = 0, 102 /** Blinking */ 103 LIGHT_FLASH_BLINK = 1, 104 /** Gradient */ 105 LIGHT_FLASH_GRADIENT = 2, 106 /** Invalid mode */ 107 LIGHT_FLASH_BUTT = 3, 108 }; 109 110 /** 111 * @brief Defines the blinking parameters. 112 * 113 * The parameters include the blinking mode and the on and off time for the light in a blinking period. 114 * 115 * @since 3.1 116 */ 117 struct LightFlashEffect { 118 int32_t flashMode; /** Blinking mode. For details, see {@link LightFlashMode}. */ 119 int32_t onTime; /** Duration (in ms) for which the light is on in a blinking period. */ 120 int32_t offTime; /** Duration (in ms) for which the light is off in a blinking period. */ 121 }; 122 123 /** 124 * @brief Defines the color and extended information of the light. 125 * 126 * The parameters include four parameters include red, green, blue values and extended information. 127 * 128 * @since 3.2 129 */ 130 struct RGBColor { 131 uint8_t r; /** Red value range 0-255. */ 132 uint8_t g; /** Green value range 0-255. */ 133 uint8_t b; /** Blue value range 0-255. */ 134 uint8_t reserved; /** Custom extended information. */ 135 }; 136 137 /** 138 * @brief Defines the color of the light. 139 * 140 * The parameters include the These parameters include red, green, blue and white values. 141 * 142 * @since 3.2 143 */ 144 struct WRGBColor { 145 uint8_t w; /** White value range 0-255. */ 146 uint8_t r; /** Red value range 0-255. */ 147 uint8_t g; /** Green value range 0-255. */ 148 uint8_t b; /** Blue value range 0-255. */ 149 }; 150 151 /** 152 * @brief Defines three modes for setting the light. 153 * 154 * The parameters include single color mode, RGB mode and WRGB mode. 155 * 156 * @since 3.2 157 */ 158 union ColorValue { 159 int32_t singleColor; /** Single color mode. */ 160 struct WRGBColor wrgbColor; /** WRGB mode, see {@link WRGBColor}. */ 161 struct RGBColor rgbColor; /** RGB mode, see {@link RGBColor}. */ 162 }; 163 164 /** 165 * @brief Defines two modes for setting the light. 166 * 167 * The parameters include RGB mode and WRGB mode. 168 * 169 * @since 3.2 170 */ 171 172 struct LightColor { 173 union ColorValue colorValue; 174 }; 175 176 /** 177 * @brief Defines the lighting effect parameters. 178 * 179 * The parameters include the brightness and blinking mode. 180 * 181 * @since 3.1 182 */ 183 struct LightEffect { 184 struct LightColor lightColor; /** Color and brightness corresponding to light, see {@link HdfLightColor}. */ 185 struct LightFlashEffect flashEffect; /** Blinking mode. For details, see {@link LightFlashEffect}. */ 186 }; 187 188 /** 189 * @brief Defines the basic light information. 190 * 191 * Basic light information includes the light id, light name, light number and light type. 192 * 193 * @since 3.1 194 */ 195 struct LightInfo { 196 uint32_t lightId; /** Light id. For details, see {@link LightId}. */ 197 uint32_t lightNumber; /** Number of physical lights in the logic controller. */ 198 char lightName[NAME_MAX_LEN]; /** Logic light name. */ 199 int32_t lightType; /** Light type. For details, see {@link HdfLightType}. */ 200 }; 201 202 #ifdef __cplusplus 203 #if __cplusplus 204 } 205 #endif 206 #endif /* __cplusplus */ 207 208 #endif /* LIGHT_TYPE_H */ 209 /** @} */ 210