Initialize Tizen 2.3
[framework/system/deviced.git] / src / deviced / dd-led.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19
20 #ifndef __DD_LED_H__
21 #define __DD_LED_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include <stdbool.h>
28
29 /**
30  * @file        dd-led.h
31  * @defgroup    CAPI_SYSTEM_DEVICED_LED_MODULE Led
32  * @ingroup     CAPI_SYSTEM_DEVICED
33  * @brief       This file provides the API for control of led
34  * @section CAPI_SYSTEM_DEVICED_LED_MODULE_HEADER Required Header
35  *   \#include <dd-led.h>
36  */
37
38 /**
39  * @addtogroup CAPI_SYSTEM_DEVICED_LED_MODULE
40  * @{
41  */
42
43 /**
44  * @par Description
45  * LED mode
46  */
47 enum LED_MODE {
48         LED_OFF = 0,
49         LED_LOW_BATTERY,
50         LED_CHARGING,
51         LED_FULLY_CHARGED,
52         LED_CHARGING_ERROR,
53         LED_MISSED_NOTI,
54         LED_VOICE_RECORDING,
55         LED_POWER_OFF,
56         LED_CUSTOM,
57         LED_MODE_MAX,
58 };
59
60 #define led_set_brightness(val) \
61                 led_set_brightness_with_noti(val, false)
62
63 #define led_set_mode(mode, on)  \
64                 led_set_mode_with_color(mode, on, 0)
65
66 /**
67  * @par Description:
68  *  This API is used to get the current brightness of the led.\n
69  *  It gets the current brightness of the led by calling device_get_property() function.\n
70  *  It returns integer value which is the current brightness on success.\n
71  *  Or a negative value(-1) is returned on failure.
72  * @return current brightness value on success, -1 if failed
73  * @see led_set_brightness_with_noti()
74  * @par Example
75  * @code
76  *  ...
77  *  int cur_brt;
78  *  cur_brt = led_get_brightness();
79  *  if( cur_brt < 0 )
80  *      printf("Fail to get the current brightness of the led.\n");
81  *  else
82  *      printf("Current brightness of the led is %d\n", cur_brt);
83  *  ...
84  * @endcode
85  */
86 int led_get_brightness(void);
87
88 /**
89  * @par Description:
90  *  This API is used to get the max brightness of the led.\n
91  *  It gets the max brightness of the led by calling device_get_property() function.\n
92  *  It returns integer value which is the max brightness on success.\n
93  *  Or a negative value(-1) is returned on failure
94  * @return max brightness value on success, -1 if failed
95  * @par Example
96  * @code
97  *  ...
98  *  int max_brt;
99  *  max_brt = led_get_max_brightness();
100  *  if( max_brt < 0 )
101  *      printf("Fail to get the max brightness of the led.\n");
102  *  ...
103  * @endcode
104  */
105 int led_get_max_brightness(void);
106
107 /**
108  * @par Description:
109  *  This API is used to set the current brightness of the led.\n
110  *      It sets the current brightness of the led by calling device_set_property() function.\n
111  * @param[in] val brightness value that you want to set
112  * @param[in] enable noti
113  * @return 0 on success, -1 if failed
114  * @see led_get_brightness()
115  * @par Example
116  * @code
117  *  ...
118  *  if( led_set_brightness_with_noti(1, 1) < 0 )
119  *     printf("Fail to set the brightness of the led\n");
120  *  ...
121  * @endcode
122  */
123 int led_set_brightness_with_noti(int val, bool enable);
124
125 /**
126  * @par Description:
127  *  This API is used to set command of the irled.\n
128  *  It sets the command to control irled by calling device_set_property() function.\n
129  * @param[in] value string that you want to set
130  * @return 0 on success, -1 if failed
131  * @see led_set_brightness_with_noti()
132  * @par Example
133  * @code
134  *  ...
135  *  if( led_set_ir_command(("38000,173,171,24,...,1880") < 0 )
136  *     printf("Fail to set the command of the irled\n");
137  *  ...
138  * @endcode
139  */
140 int led_set_ir_command(char *value);
141
142 /**
143  * @par Description:
144  *  This API is used to set LED mode with color.\n
145  *  It sets the command to set LED mode by calling device_set_property() function.\n
146  * @param[in] mode LED mode
147  * @param[in] on enable/disable LED
148  * @param[in] color LED color
149  * @return 0 on success, -1 if failed
150  * @see LED_MODE
151  * @par Example
152  * @code
153  *  ...
154  *  if( led_set_mode_with_color(LED_LOW_BATTERY, 1, 0) < 0 )
155  *      printf("Fail to set LED mode with color\n");
156  *  ...
157  * @endcode
158  * @todo describe color
159  */
160 int led_set_mode_with_color(int mode, bool on, unsigned int color);
161
162 /**
163  * @par Description:
164  *  This API is used to set LED mode with all option such as on/off duty and color.\n
165  *  It sets the command to set LED mode by calling device_set_property() function.\n
166  * @param[in] mode LED mode
167  * @param[in] val enable/disable LED
168  * @param[in] on  duty value (millisecond)
169  * @param[in] off duty value (millisecond)
170  * @param[in] color LED color
171  * @return 0 on success, -1 if failed
172  * @see LED_MODE
173  * @par Example
174  * @code
175  *  ...
176  *  if( led_set_mode_with_property(LED_LOW_BATTERY, true, 500, 5000, 0xFFFF0000) < 0 )
177  *      printf("Fail to set LED mode with color\n");
178  *  ...
179  * @endcode
180  * @todo describe color
181  */
182 int led_set_mode_with_property(int mode, bool val, int on, int off, unsigned int color);
183
184 /**
185  * @} // end of CAPI_SYSTEM_DEVICED_LED_MODULE
186  */
187
188 #ifdef __cplusplus
189 }
190 #endif
191 #endif