diff options
| author | codeworkx <daniel.hillenbrand@codeworkx.de> | 2017-06-18 09:44:43 +0200 |
|---|---|---|
| committer | hemantbeast <hemantbeast@gmail.com> | 2017-06-23 08:13:56 +0530 |
| commit | 22a67bda0bc55ced0112ccad3de31bfee219b075 (patch) | |
| tree | fc08082e334b407e57c920e089c106327d9c996f | |
| parent | bb2790b653df66072d54d613010d2772c1790ba4 (diff) | |
s2: lights: fix blinking
Change-Id: I5a66c474374d129668c8be975ce55973f9da0735
| -rw-r--r-- | liblight/lights.c | 76 |
1 files changed, 44 insertions, 32 deletions
diff --git a/liblight/lights.c b/liblight/lights.c index 771955d..2260b79 100644 --- a/liblight/lights.c +++ b/liblight/lights.c @@ -44,23 +44,20 @@ static struct light_state_t g_attention; char const*const RED_LED_FILE = "/sys/class/leds/red/brightness"; -char const*const RED_BLINK_FILE - = "/sys/class/leds/red/blink"; - -char const*const GREEN_BLINK_FILE - = "/sys/class/leds/green/blink"; - -char const*const BLUE_BLINK_FILE - = "/sys/class/leds/blue/blink"; - char const*const GREEN_LED_FILE = "/sys/class/leds/green/brightness"; char const*const BLUE_LED_FILE = "/sys/class/leds/blue/brightness"; -char const*const LCD_FILE - = "/sys/class/leds/lcd-backlight/brightness"; +char const*const RED_BLINK_FILE + = "/sys/class/leds/red/blink"; + +char const*const GREEN_BLINK_FILE + = "/sys/class/leds/green/blink"; + +char const*const BLUE_BLINK_FILE + = "/sys/class/leds/blue/blink"; char const*const RED_BREATH_FILE = "/sys/class/leds/red/led_time"; @@ -71,6 +68,9 @@ char const*const GREEN_BREATH_FILE char const*const BLUE_BREATH_FILE = "/sys/class/leds/blue/led_time"; +char const*const LCD_FILE + = "/sys/class/leds/lcd-backlight/brightness"; + char const*const BUTTON_FILE = "/sys/class/leds/button-backlight/brightness"; @@ -290,6 +290,7 @@ set_speaker_light_locked(struct light_device_t* dev, int red, green, blue; int blink; int onMS, offMS; + int onS, offS; unsigned int colorRGB; char breath_pattern[64] = { 0, }; struct color *nearest = NULL; @@ -320,14 +321,11 @@ set_speaker_light_locked(struct light_device_t* dev, colorRGB = state->color; - ALOGD("set_speaker_light_locked mode %d, colorRGB=%08X, onMS=%d, offMS=%d\n", - state->flashMode, colorRGB, onMS, offMS); - red = (colorRGB >> 16) & 0xFF; green = (colorRGB >> 8) & 0xFF; blue = colorRGB & 0xFF; - blink = onMS > 0 && offMS > 0; + blink = onMS > 1 && offMS > 1; if (blink) { // Driver doesn't permit us to set individual duty cycles, so only @@ -340,34 +338,48 @@ set_speaker_light_locked(struct light_device_t* dev, // Make sure the values are between 1 and 7 seconds if (onMS < 1000) - onMS = 1000; + onS = 0; else if (onMS > 7000) - onMS = 7000; + onS = 7; + else + onS = (int)(onMS/1000); if (offMS < 1000) - offMS = 1000; + offS = 0; else if (offMS > 7000) - offMS = 7000; + offS = 7; + else + offS = (int)(offMS/1000); // ramp up, lit, ramp down, unlit. in seconds. - sprintf(breath_pattern,"1 %d 1 %d",(int)(onMS/1000),(int)(offMS/1000)); + sprintf(breath_pattern,"%d %d %d %d", onS, onS, offS, offS); + + write_int(RED_LED_FILE, red); + write_int(GREEN_LED_FILE, green); + write_int(BLUE_LED_FILE, blue); + + if (red) + write_str(RED_BREATH_FILE, breath_pattern); + else if (green) + write_str(GREEN_BREATH_FILE, breath_pattern); + else if (blue) + write_str(BLUE_BREATH_FILE, breath_pattern); } else { blink = 0; - sprintf(breath_pattern,"1 2 1 2"); + sprintf(breath_pattern,"0 0 0 0"); + + write_int(RED_BLINK_FILE, blink); + write_int(GREEN_BLINK_FILE, blink); + write_int(BLUE_BLINK_FILE, blink); + + write_int(RED_LED_FILE, red); + write_int(GREEN_LED_FILE, green); + write_int(BLUE_LED_FILE, blue); } - // Do everything with the lights out, then turn up the brightness - write_str(RED_BREATH_FILE, breath_pattern); - write_int(RED_BLINK_FILE, (blink && red ? 1 : 0)); - write_str(GREEN_BREATH_FILE, breath_pattern); - write_int(GREEN_BLINK_FILE, (blink && green ? 1 : 0)); - write_str(BLUE_BREATH_FILE, breath_pattern); - write_int(BLUE_BLINK_FILE, (blink && blue ? 1 : 0)); - - write_int(RED_LED_FILE, red); - write_int(GREEN_LED_FILE, green); - write_int(BLUE_LED_FILE, blue); + ALOGD("set_speaker_light_locked mode %d, colorRGB=%08X, onMS=%d, offMS=%d, breathPattern=%s\n", + state->flashMode, colorRGB, onMS, offMS, breath_pattern); return 0; } |
