liblights: Store LED battery status and restore it after a notification LED blinking

Change-Id: Ifd01e3dea28ecc0dac94f2ff44b94e81493ba2a4
tirimbino
XpLoDWilD 12 years ago
parent 48421e2da2
commit f2d31f2429
  1. 13
      exynos4/exynos4x12/liblights/lights.c

@ -57,6 +57,8 @@ struct led_config {
char blink[MAX_WRITE_CMD];
};
struct led_config g_BatteryStore;
void init_g_lock(void)
{
pthread_mutex_init(&g_lock, NULL);
@ -167,10 +169,8 @@ static int set_light_leds(struct light_state_t const *state, int type)
switch (state->flashMode) {
case LIGHT_FLASH_NONE:
led.red = 0;
led.green = 0;
led.blue = 0;
snprintf(led.blink, MAX_WRITE_CMD, "0x000000 0 0");
// use battery led state stored (black if nothing)
led = g_BatteryStore;
break;
case LIGHT_FLASH_TIMED:
case LIGHT_FLASH_HARDWARE:
@ -213,6 +213,7 @@ static int set_light_battery(struct light_device_t *dev,
}
pthread_mutex_lock(&g_lock);
g_BatteryStore = led;
err = write_int(LED_RED, led.red);
err = write_int(LED_GREEN, led.green);
err = write_int(LED_BLUE, led.blue);
@ -246,6 +247,10 @@ static int open_lights(const struct hw_module_t *module, char const *name,
pthread_once(&g_init, init_g_lock);
g_BatteryStore.red = 0;
g_BatteryStore.green = 0;
g_BatteryStore.blue = 0;
struct light_device_t *dev = malloc(sizeof(struct light_device_t));
memset(dev, 0, sizeof(*dev));

Loading…
Cancel
Save