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 #ifndef LIGHT_AGENT_TYPE_H 17 #define LIGHT_AGENT_TYPE_H 18 19 #include <stdint.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /** Maximum length of the light name */ 26 #ifndef NAME_MAX_LEN 27 #define NAME_MAX_LEN 32 28 #endif /* NAME_MAX_LEN */ 29 /** 30 * @brief Enumerates the light types. 31 * 32 * @since 10 33 */ 34 enum LightType { 35 LIGHT_TYPE_SINGLE_COLOR = 1, 36 LIGHT_TYPE_RGB_COLOR = 2, 37 LIGHT_TYPE_WRGB_COLOR = 3, 38 }; 39 40 /** 41 * @brief Defines the basic light information. 42 * 43 * @since 10 44 */ 45 typedef struct { 46 char lightName[NAME_MAX_LEN]; /**< light name */ 47 int32_t lightId; /**< Light id */ 48 int32_t lightNumber; /**< Number of physical lights in the logic controller */ 49 int32_t lightType; /** Light type. For details, see {@link LightType}. */ 50 } LightInfo; 51 52 /** 53 * @brief Enumerates the lighting modes. 54 * 55 * @since 10 56 */ 57 typedef enum { 58 LIGHT_MODE_DEFAULT = 0, /**< No flicker mode. */ 59 LIGHT_MODE_BLINK = 1, /**< Timed flashing mode. */ 60 LIGHT_MODE_GRADIENT = 2, /**< Gradient mode. */ 61 LIGHT_MODE_BUTT = 3, /**< Invalid mode. */ 62 } FlashMode; 63 64 /** 65 * @brief Defines the blinking parameters. 66 * 67 * @since 10 68 */ 69 struct LightAnimation { 70 int32_t mode = LIGHT_MODE_DEFAULT; /**< Blinking mode. For details, see {@link FlashMode}. */ 71 int32_t onTime; /**< Duration (in ms) for which the light is on in a blinking period. */ 72 int32_t offTime; /**< Duration (in ms) for which the light is off in a blinking period. */ 73 }; 74 75 /** 76 * @brief Defines the color and custom extended information of the light. 77 * 78 * The parameters include the These parameters include red, green, blue values and custom extended information. 79 * 80 * @since 10 81 */ 82 struct RGBColor { 83 uint8_t r; /** Red value range 0-255. */ 84 uint8_t g; /** Green value range 0-255. */ 85 uint8_t b; /** Blue value range 0-255. */ 86 uint8_t reserved; /** Custom extended information */ 87 }; 88 89 /** 90 * @brief Defines the color of the light. 91 * 92 * The parameters include the These parameters include red, green, blue and white values. 93 ght idNumber of physical lights in the logic controllerint reservedCustom extended information. 94 * @since 10 95 */ 96 struct WRGBColor { 97 uint8_t w; /** White value range 0-255. */ 98 uint8_t r; /** Red value range 0-255. */ 99 uint8_t g; /** Green value range 0-255. */ 100 uint8_t b; /** Blue value range 0-255. */ 101 }; 102 103 /** 104 * @brief Defines the color of the light。 105 * 106 * @since 10 107 */ 108 union LightColor { 109 int32_t singleColor; /** Single color mode. */ 110 RGBColor rgbColor; /** RGB mode, see {@link RGBColor}. */ 111 WRGBColor wrgbColor; /** WRGB mode, see {@link WRGBColor}. */ 112 }; 113 114 /** @} */ 115 #ifdef __cplusplus 116 }; 117 #endif 118 #endif // endif LIGHT_AGENT_TYPE_H 119