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 /** 48 * @brief Enumerates the return values of the light module. 49 * 50 * @since 3.1 51 */ 52 enum LightStatus { 53 /** The operation is successful. */ 54 LIGHT_SUCCESS = 0, 55 /** The light id is not supported. */ 56 LIGHT_NOT_SUPPORT = -1, 57 /** Blinking setting is not supported. */ 58 LIGHT_NOT_FLASH = -2, 59 /** Brightness setting is not supported. */ 60 LIGHT_NOT_BRIGHTNESS = -3, 61 }; 62 63 /** 64 * @brief Enumerates the light ids. 65 * 66 * @since 3.1 67 */ 68 enum LightId { 69 /** Unknown id */ 70 LIGHT_ID_NONE = 0, 71 /** Power light */ 72 LIGHT_ID_BATTERY = 1, 73 /** Notification light */ 74 LIGHT_ID_NOTIFICATIONS = 2, 75 /** Alarm light */ 76 LIGHT_ID_ATTENTION = 3, 77 /** Invalid id */ 78 LIGHT_ID_BUTT = 4, 79 }; 80 81 /** 82 * @brief Enumerates the lighting modes. 83 * 84 * @since 3.1 85 */ 86 enum LightFlashMode { 87 /** Steady on */ 88 LIGHT_FLASH_NONE = 0, 89 /** Blinking */ 90 LIGHT_FLASH_TIMED = 1, 91 /** Invalid mode */ 92 LIGHT_FLASH_BUTT = 2, 93 }; 94 95 /** 96 * @brief Defines the blinking parameters. 97 * 98 * The parameters include the blinking mode and the on and off time for the light in a blinking period. 99 * 100 * @since 3.1 101 */ 102 struct LightFlashEffect { 103 int32_t flashMode; /** Blinking mode. For details, see {@link LightFlashMode}. */ 104 int32_t onTime; /** Duration (in ms) for which the light is on in a blinking period. */ 105 int32_t offTime; /** Duration (in ms) for which the light is off in a blinking period. */ 106 }; 107 108 /** 109 * @brief Defines the lighting effect parameters. 110 * 111 * The parameters include the brightness and blinking mode. 112 * 113 * @since 3.1 114 */ 115 struct LightEffect { 116 int32_t lightBrightness; /** Brightness value. The value 1 of the most significant bit indicates a color. 117 Bits 16–31 for red, bits 8–15 for green, and bits 0–7 for blue. */ 118 struct LightFlashEffect flashEffect; /** Blinking mode. For details, see {@link LightFlashEffect}. */ 119 }; 120 121 /** 122 * @brief Defines the basic light information. 123 * 124 * Basic light information includes the light id and custom extended information. 125 * 126 * @since 3.1 127 */ 128 struct LightInfo { 129 uint32_t lightId; /** Light id. For details, see {@link LightId}. */ 130 int32_t reserved; /** Custom extended information. */ 131 }; 132 133 #ifdef __cplusplus 134 #if __cplusplus 135 } 136 #endif 137 #endif /* __cplusplus */ 138 139 #endif /* LIGHT_TYPE_H */ 140 /** @} */ 141