tizen 2.3 release
[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_REMOTE_CONTROLLER,
56         LED_AIR_WAKEUP,
57         LED_POWER_OFF,
58         LED_CUSTOM,
59         LED_MODE_MAX,
60 };
61
62 #define led_set_brightness(val) \
63                 led_set_brightness_with_noti(val, false)
64
65 #define led_set_mode(mode, on)  \
66                 led_set_mode_with_color(mode, on, 0)
67
68 /**
69  * @par Description:
70  *  This API is used to get the current brightness of the led.\n
71  *  It gets the current brightness of the led by calling device_get_property() function.\n
72  *  It returns integer value which is the current brightness on success.\n
73  *  Or a negative value(-1) is returned on failure.
74  * @return current brightness value on success, -1 if failed
75  * @see led_set_brightness_with_noti()
76  * @par Example
77  * @code
78  *  ...
79  *  int cur_brt;
80  *  cur_brt = led_get_brightness();
81  *  if( cur_brt < 0 )
82  *      printf("Fail to get the current brightness of the led.\n");
83  *  else
84  *      printf("Current brightness of the led is %d\n", cur_brt);
85  *  ...
86  * @endcode
87  */
88 int led_get_brightness(void);
89
90 /**
91  * @par Description:
92  *  This API is used to get the max brightness of the led.\n
93  *  It gets the max brightness of the led by calling device_get_property() function.\n
94  *  It returns integer value which is the max brightness on success.\n
95  *  Or a negative value(-1) is returned on failure
96  * @return max brightness value on success, -1 if failed
97  * @par Example
98  * @code
99  *  ...
100  *  int max_brt;
101  *  max_brt = led_get_max_brightness();
102  *  if( max_brt < 0 )
103  *      printf("Fail to get the max brightness of the led.\n");
104  *  ...
105  * @endcode
106  */
107 int led_get_max_brightness(void);
108
109 /**
110  * @par Description:
111  *  This API is used to set the current brightness of the led.\n
112  *      It sets the current brightness of the led by calling device_set_property() function.\n
113  * @param[in] val brightness value that you want to set
114  * @param[in] enable noti
115  * @return 0 on success, -1 if failed
116  * @see led_get_brightness()
117  * @par Example
118  * @code
119  *  ...
120  *  if( led_set_brightness_with_noti(1, 1) < 0 )
121  *     printf("Fail to set the brightness of the led\n");
122  *  ...
123  * @endcode
124  */
125 int led_set_brightness_with_noti(int val, bool enable);
126
127 /**
128  * @par Description:
129  *  This API is used to set command of the irled.\n
130  *  It sets the command to control irled by calling device_set_property() function.\n
131  * @param[in] value string that you want to set
132  * @return 0 on success, negative value if failed
133  * @see led_set_brightness_with_noti()
134  * @par Example
135  * @code
136  *  ...
137  *  if( led_set_ir_command(("38000,173,171,24,...,1880") < 0 )
138  *     printf("Fail to set the command of the irled\n");
139  *  ...
140  * @endcode
141  */
142 int led_set_ir_command(char *value);
143
144 /**
145  * @par Description:
146  *  This API is used to set LED mode with color.\n
147  *  It sets the command to set LED mode by calling device_set_property() function.\n
148  * @param[in] mode LED mode
149  * @param[in] on enable/disable LED
150  * @param[in] color LED color
151  * @return 0 on success, -1 if failed
152  * @see LED_MODE
153  * @par Example
154  * @code
155  *  ...
156  *  if( led_set_mode_with_color(LED_LOW_BATTERY, 1, 0) < 0 )
157  *      printf("Fail to set LED mode with color\n");
158  *  ...
159  * @endcode
160  * @todo describe color
161  */
162 int led_set_mode_with_color(int mode, bool on, unsigned int color);
163
164 /**
165  * @par Description:
166  *  This API is used to set LED mode with all option such as on/off duty and color.\n
167  *  It sets the command to set LED mode by calling device_set_property() function.\n
168  * @param[in] mode LED mode
169  * @param[in] val enable/disable LED
170  * @param[in] on  duty value (millisecond)
171  * @param[in] off duty value (millisecond)
172  * @param[in] color LED color
173  * @return 0 on success, -1 if failed
174  * @see LED_MODE
175  * @par Example
176  * @code
177  *  ...
178  *  if( led_set_mode_with_property(LED_LOW_BATTERY, true, 500, 5000, 0xFFFF0000) < 0 )
179  *      printf("Fail to set LED mode with color\n");
180  *  ...
181  * @endcode
182  * @todo describe color
183  */
184 int led_set_mode_with_property(int mode, bool val, int on, int off, unsigned int color);
185
186 /**
187  * @} // end of CAPI_SYSTEM_DEVICED_LED_MODULE
188  */
189
190 #ifdef __cplusplus
191 }
192 #endif
193 #endif