|
|
|
@ -46,6 +46,7 @@ char const*const LED_RED = "/sys/class/sec/led/led_r"; |
|
|
|
|
char const*const LED_GREEN = "/sys/class/sec/led/led_g"; |
|
|
|
|
char const*const LED_BLUE = "/sys/class/sec/led/led_b"; |
|
|
|
|
char const*const LED_BLINK = "/sys/class/sec/led/led_blink"; |
|
|
|
|
char const*const LED_BRIGHTNESS = "/sys/class/sec/led/led_br_lev"; |
|
|
|
|
|
|
|
|
|
#define MAX_WRITE_CMD 25 |
|
|
|
|
|
|
|
|
@ -53,6 +54,7 @@ struct led_config { |
|
|
|
|
int red; |
|
|
|
|
int green; |
|
|
|
|
int blue; |
|
|
|
|
char brightness[MAX_WRITE_CMD]; |
|
|
|
|
char blink[MAX_WRITE_CMD]; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -151,6 +153,7 @@ static int write_leds(struct led_config led) |
|
|
|
|
err = write_int(LED_RED, led.red); |
|
|
|
|
err = write_int(LED_GREEN, led.green); |
|
|
|
|
err = write_int(LED_BLUE, led.blue); |
|
|
|
|
err = write_str(LED_BRIGHTNESS, led.brightness); |
|
|
|
|
err = write_str(LED_BLINK, led.blink); |
|
|
|
|
pthread_mutex_unlock(&g_lock); |
|
|
|
|
|
|
|
|
@ -169,6 +172,7 @@ static int set_light_leds(struct light_state_t const *state, int type) |
|
|
|
|
led.red = 0; |
|
|
|
|
led.green = 0; |
|
|
|
|
led.blue = 0; |
|
|
|
|
snprintf(led.brightness, MAX_WRITE_CMD, "0x00"); |
|
|
|
|
snprintf(led.blink, MAX_WRITE_CMD, "0x000000 0 0"); |
|
|
|
|
break; |
|
|
|
|
case LIGHT_FLASH_TIMED: |
|
|
|
@ -176,6 +180,7 @@ static int set_light_leds(struct light_state_t const *state, int type) |
|
|
|
|
led.red = (colorRGB >> 16) & 0xFF; |
|
|
|
|
led.green = (colorRGB >> 8) & 0xFF; |
|
|
|
|
led.blue = colorRGB & 0xFF; |
|
|
|
|
snprintf(led.brightness, MAX_WRITE_CMD, "0xFF"); |
|
|
|
|
snprintf(led.blink, MAX_WRITE_CMD, "0x%x %d %d", colorRGB, state->flashOnMS, state->flashOffMS); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
@ -204,11 +209,13 @@ static int set_light_battery(struct light_device_t *dev, |
|
|
|
|
led.red = 0; |
|
|
|
|
led.green = 0; |
|
|
|
|
led.blue = 0; |
|
|
|
|
snprintf(led.brightness, MAX_WRITE_CMD, "0x00"); |
|
|
|
|
snprintf(led.blink, MAX_WRITE_CMD, "0x000000 0 0"); |
|
|
|
|
} else { |
|
|
|
|
led.red = (colorRGB >> 16) & 0xFF; |
|
|
|
|
led.green = (colorRGB >> 8) & 0xFF; |
|
|
|
|
led.blue = colorRGB & 0xFF; |
|
|
|
|
snprintf(led.brightness, MAX_WRITE_CMD, "0x00"); |
|
|
|
|
snprintf(led.blink, MAX_WRITE_CMD, "0x%x %d %d", colorRGB, state->flashOnMS, state->flashOffMS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|