diff options
author | ChainsDD <chainsdd@gmail.com> | 2010-03-28 13:19:35 -0500 |
---|---|---|
committer | ChainsDD <chainsdd@gmail.com> | 2010-03-28 13:19:35 -0500 |
commit | d8415746c18c3014f5845e6fa83eb203c92d2e2b (patch) | |
tree | 6d5086aa87d9fcd5e8049100edb3f2766a37a9f8 | |
parent | 44d47e57824349101e3e1917fdb7fa7a6c1fbcee (diff) | |
download | passion-common-d8415746c18c3014f5845e6fa83eb203c92d2e2b.tar.gz |
Ensure period is set within the hardware's limitations.
It is possible for an app to send out a notification that has a period of less than 2 seconds or greater than 12 seconds. When that happens, the period is not set at all and causes strange things to happen.
This commit simply ensures that period is always between 2 and 12. Also it fixes a tiny code formatting issue.
Change-Id: I638f7707cb37e1d3008e768638283b463192f70e
-rw-r--r-- | liblights/lights.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/liblights/lights.c b/liblights/lights.c index a6156d6..2850ac1 100644 --- a/liblights/lights.c +++ b/liblights/lights.c @@ -236,6 +236,8 @@ set_trackball_light(struct light_state_t const* state) if (state->flashMode == LIGHT_FLASH_HARDWARE) { mode = state->flashOnMS; period = state->flashOffMS; + period = (period < 2) ? 2 : period; + period = (period > 12) ? 12 : period; } LOGV("%s color=%08x mode=%d period %d\n", __func__, state->color, mode, period); @@ -262,7 +264,7 @@ set_trackball_light(struct light_state_t const* state) } trackball_mode = mode; -return write_int(&leds[JOGBALL_LED].brightness, mode); + return write_int(&leds[JOGBALL_LED].brightness, mode); } static void |