diff options
| author | Steve Kondik <steve@cyngn.com> | 2016-07-28 05:06:26 -0700 |
|---|---|---|
| committer | Davide Garberi <dade.garberi@gmail.com> | 2018-01-24 15:18:06 +0100 |
| commit | db1d5c409cb76990db1cf35d660bc848f9c4cc55 (patch) | |
| tree | 31ff76d04689be48b1da21035ecff15d307edd34 | |
| parent | cae9b7734ec4be2beb389dd58a5859020e12b4f4 (diff) | |
z2_plus: Lights improvements
* Include the proper LED sysfs node permissions
* Set up the RGB sync stuff
Change-Id: I3517994c93ccc2d1789d7ceecf8b445ff3d27d5b
Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
| -rw-r--r-- | liblight/lights.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/liblight/lights.c b/liblight/lights.c index 4a5e783..1f74712 100644 --- a/liblight/lights.c +++ b/liblight/lights.c @@ -108,6 +108,9 @@ static const char GREEN_BLINK_FILE[] static const char BLUE_BLINK_FILE[] = "/sys/class/leds/blue/blink"; +static const char RGB_BLINK_FILE[] + = "/sys/class/leds/rgb/rgb_blink"; + #define RAMP_SIZE 8 static int BRIGHTNESS_RAMP[RAMP_SIZE] = { 0, 12, 25, 37, 50, 72, 85, 100 }; @@ -249,16 +252,10 @@ set_speaker_light_locked(struct light_device_t* dev, red = (colorRGB >> 16) & 0xFF; green = (colorRGB >> 8) & 0xFF; blue = colorRGB & 0xFF; - // bias for true white - if (colorRGB != 0 && red == green && green == blue) { - blue = (blue * 171) / 256; - } blink = onMS > 0 && offMS > 0; - // disable all blinking to start - write_int(RED_BLINK_FILE, 0); - write_int(GREEN_BLINK_FILE, 0); - write_int(BLUE_BLINK_FILE, 0); + // Disable all blinking to start + write_int(RGB_BLINK_FILE, 0); if (blink) { stepDuration = RAMP_STEP_DURATION; @@ -301,12 +298,15 @@ set_speaker_light_locked(struct light_device_t* dev, write_int(BLUE_RAMP_STEP_MS_FILE, stepDuration); free(duty); - // start the party - write_int(RED_BLINK_FILE, red); - write_int(GREEN_BLINK_FILE, green); - write_int(BLUE_BLINK_FILE, blue); + // Start the party + write_int(RGB_BLINK_FILE, 1); } else { + if (red == 0 && green == 0 && blue == 0) { + write_int(RED_BLINK_FILE, 0); + write_int(GREEN_BLINK_FILE, 0); + write_int(BLUE_BLINK_FILE, 0); + } write_int(RED_LED_FILE, red); write_int(GREEN_LED_FILE, green); write_int(BLUE_LED_FILE, blue); |
