Tizen Native API
9.0
|
The Led API provides functions to control the attached led device.
Required Header
#include <device/led.h>
Overview
The Led API provides the way to control the attached LED device such as the camera flash and service LED. It supports to turn on the camera flash and set the pattern to the service LED which is located to the front of a device.
Related Features
This API is related with the following features:
- http://tizen.org/feature/led
- http://tizen.org/feature/camera.back.flash
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from feature element description.
Functions | |
int | device_flash_get_max_brightness (int *max_brightness) |
Gets the max brightness value of a LED that is located next to the camera. | |
int | device_flash_get_brightness (int *brightness) |
Gets the brightness value of a LED that is located next to the camera. | |
int | device_flash_set_brightness (int brightness) |
Sets the brightness value of a LED that is located next to the camera. | |
int | device_led_play_custom (int on, int off, unsigned int color, unsigned int flags) |
Plays the custom effect of the service LED that is located to the front of a device. | |
int | device_led_stop_custom (void) |
Stops the custom effect of the service LED that is located to the front of a device. |
Enumeration Type Documentation
enum led_custom_flags |
Function Documentation
int device_flash_get_brightness | ( | int * | brightness | ) |
Gets the brightness value of a LED that is located next to the camera.
Retrieves the current brightness level of the back camera flash.
The brightness level is filled in the brightness parameter.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/led
- Remarks:
- This API is related to the following feature: http://tizen.org/feature/camera.back.flash
- Parameters:
-
[out] brightness The brightness value of LED ( 0
~ MAX)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DEVICE_ERROR_NONE Successful DEVICE_ERROR_INVALID_PARAMETER Invalid parameter DEVICE_ERROR_PERMISSION_DENIED Permission denied DEVICE_ERROR_OPERATION_FAILED Operation failed DEVICE_ERROR_NOT_SUPPORTED Not supported device #include <device/led.h> ... int brightness = 0; int ret = 0; ... ret = device_flash_get_brightness(&brightness); ...
- See also:
- device_flash_set_brightness()
int device_flash_get_max_brightness | ( | int * | max_brightness | ) |
Gets the max brightness value of a LED that is located next to the camera.
Retrieves the maximum brightness level of the back camera flash.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/led
- Remarks:
- This API is related to the following feature: http://tizen.org/feature/camera.back.flash
- Parameters:
-
[out] max_brightness The max brightness value of the LED
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DEVICE_ERROR_NONE Successful DEVICE_ERROR_INVALID_PARAMETER Invalid parameter DEVICE_ERROR_PERMISSION_DENIED Permission denied DEVICE_ERROR_OPERATION_FAILED Operation failed DEVICE_ERROR_NOT_SUPPORTED Not supported device #include <device/led.h> ... int max_brightness = 0; int ret = 0; ... ret = device_flash_get_max_brightness(&max_brightness); ...
int device_flash_set_brightness | ( | int | brightness | ) |
Sets the brightness value of a LED that is located next to the camera.
Sets the brightness level of the back camera flash.
The desired brightness level is specified in the brightness parameter.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/led
- Remarks:
- Since 2.4, this API check camera flash status whether camera API preempted flash or not, so it could be failed if flash was preempted by camera API. In this case, API will return DEVICE_ERROR_RESOURCE_BUSY error. This API is related to the following feature: http://tizen.org/feature/camera.back.flash
- Parameters:
-
[in] brightness The brightness value of LED ( 0
~ MAX)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DEVICE_ERROR_NONE Successful DEVICE_ERROR_INVALID_PARAMETER Invalid parameter DEVICE_ERROR_PERMISSION_DENIED Permission denied DEVICE_ERROR_OPERATION_FAILED Operation failed DEVICE_ERROR_NOT_SUPPORTED Not supported device DEVICE_ERROR_RESOURCE_BUSY Device or resource busy #include <device/led.h> ... int brightness = 0; int ret = 0; ... ret = device_flash_set_brightness(brightness); ...
int device_led_play_custom | ( | int | on, |
int | off, | ||
unsigned int | color, | ||
unsigned int | flags | ||
) |
Plays the custom effect of the service LED that is located to the front of a device.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/led
- Remarks:
- This API is related to the following feature: http://tizen.org/feature/led
- Parameters:
-
[in] on Turn on time in milliseconds [in] off Turn off time in milliseconds [in] color The Color value
The first byte means opaque and the other 3 bytes are RGB values[in] flags The combination of enum led_custom_flags
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DEVICE_ERROR_NONE Successful DEVICE_ERROR_INVALID_PARAMETER Invalid parameter DEVICE_ERROR_PERMISSION_DENIED Permission denied DEVICE_ERROR_OPERATION_FAILED Operation failed DEVICE_ERROR_NOT_SUPPORTED Not supported device #include <stdio.h> #include <device/led.h> ... int on_time = 100; // On time in milliseconds int off_time = 200; // Off time in milliseconds unsigned int color = 0xFF0000; // Red color with full opacity unsigned int flags = LED_CUSTOM_DEFAULT; // Default flag int ret = device_led_play_custom(on_time, off_time, color, flags); if (ret != DEVICE_ERROR_NONE) { ... return -1; } printf("Custom effect played successfully.\n"); ...
- See also:
- device_led_stop_custom()
int device_led_stop_custom | ( | void | ) |
Stops the custom effect of the service LED that is located to the front of a device.
Stops the custom effect of the service LED located at the front of the device. The custom effect was started by calling device_led_play_custom().
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/led
- Remarks:
- This API is related to the following feature: http://tizen.org/feature/led
Requested custom effects by device_led_play_custom() are removed.
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
DEVICE_ERROR_NONE Successful DEVICE_ERROR_INVALID_PARAMETER Invalid parameter DEVICE_ERROR_PERMISSION_DENIED Permission denied DEVICE_ERROR_OPERATION_FAILED Operation failed DEVICE_ERROR_NOT_SUPPORTED Not supported device #include <device/led.h> ... int ret = device_led_play_custom(100, 200, 0xFF0000, LED_CUSTOM_DEFAULT); if (ret != DEVICE_ERROR_NONE) { return -1; } sleep(5); // Wait for 5 seconds ret = device_led_stop_custom(); ...
- See also:
- device_led_play_custom()