From e2359405dd96735749906e63ba64d3b13ec7764e Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Thu, 26 Jun 2014 16:23:56 +0200 Subject: lights: Properly handle provided colors Signed-off-by: Paul Kocialkowski --- lights/gta04_lights.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lights/gta04_lights.c b/lights/gta04_lights.c index b01c1fe..845a17d 100644 --- a/lights/gta04_lights.c +++ b/lights/gta04_lights.c @@ -139,9 +139,9 @@ int gta04_lights_set_light_notifications(struct light_device_t *device, if (state == NULL) return -EINVAL; - // GTA04 only has red and green - red = state->color & 0x00ff0000; - green = state->color & 0x0000ff00; + // GTA04 only has red and green: blue is merged to green + red = (state->color & 0x00ff0000) >> 16; + green = (state->color & 0x0000ff00) >> 8 | (state->color & 0x000000ff); pthread_mutex_lock(&lights_mutex); @@ -173,9 +173,9 @@ int gta04_lights_set_light_battery(struct light_device_t *device, if (state == NULL) return -EINVAL; - // GTA04 only has red and green - red = state->color & 0x00ff0000; - green = state->color & 0x0000ff00; + // GTA04 only has red and green: blue is merged to green + red = (state->color & 0x00ff0000) >> 16; + green = (state->color & 0x0000ff00) >> 8 | (state->color & 0x000000ff); pthread_mutex_lock(&lights_mutex); -- cgit v1.2.3