diff options
| author | AdrianDC <radian.dc@gmail.com> | 2015-08-23 01:16:17 +0200 |
|---|---|---|
| committer | LuK1337 <priv.luk@gmail.com> | 2016-01-27 16:48:47 +0100 |
| commit | c23ca7dd704d66663ec7e1b6a7ddd899313811fe (patch) | |
| tree | cbdcf1815000446ce244dc08d2892264a9d746f4 /liblight | |
| parent | 8c188686cdb5dd6aa715b25a7ac30b6168b5763e (diff) | |
msm8916-common: LED brightness LibLights control
- Add the brightness features to the LibLights.
Change-Id: Ib21879b2b61afffc194294adbeb3818b12406374
Signed-off-by: AdrianDC <radian.dc@gmail.com>
Diffstat (limited to 'liblight')
| -rw-r--r-- | liblight/lights.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/liblight/lights.c b/liblight/lights.c index cf24d50..33dcfb7 100644 --- a/liblight/lights.c +++ b/liblight/lights.c @@ -228,7 +228,35 @@ set_light_notifications(struct light_device_t* dev, struct light_state_t const* state) { pthread_mutex_lock(&g_lock); + + unsigned int brightness; + unsigned int color; + unsigned int rgb[3]; + g_notification = *state; + + // If a brightness has been applied by the user + brightness = (g_notification.color & 0xFF000000) >> 24; + if (brightness > 0 && brightness < 0xFF) { + + // Retrieve each of the RGB colors + color = g_notification.color & 0x00FFFFFF; + rgb[0] = (color >> 16) & 0xFF; + rgb[1] = (color >> 8) & 0xFF; + rgb[2] = color & 0xFF; + + // Apply the brightness level + if (rgb[0] > 0) + rgb[0] = (rgb[0] * brightness) / 0xFF; + if (rgb[1] > 0) + rgb[1] = (rgb[1] * brightness) / 0xFF; + if (rgb[2] > 0) + rgb[2] = (rgb[2] * brightness) / 0xFF; + + // Update with the new color + g_notification.color = (rgb[0] << 16) + (rgb[1] << 8) + rgb[2]; + } + handle_speaker_battery_locked(dev); pthread_mutex_unlock(&g_lock); return 0; |
