diff options
author | Bill Richardson <wfrichar@chromium.org> | 2014-10-14 11:13:11 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-15 18:22:33 +0000 |
commit | 8fc80e86e4aa90dc88064edf135f6ccae374e647 (patch) | |
tree | 0928d1d234a1cb36352e36a9625ee1ed4f6ac351 /common/lightbar.c | |
parent | 9a2afe9f78f04bce8e74aa0d04be1623d14e899e (diff) | |
download | chrome-ec-8fc80e86e4aa90dc88064edf135f6ccae374e647.tar.gz |
lightbar: bring the TAP sequence in gradually
With only four LED segments, it's confusing to indicate a power
percentage by dimming the top segment unless you can see the
indicator smoothly ramping up from all-off. This does that.
Kind of pretty, if I say so myself.
BUG=chrome-os-partner:29041
BRANCH=ToT, Samus
TEST=make buildall
Run "ectool lightbar demo on", then press the T key to invoke the
pattern and the arrow keys to fake the charge state.
Change-Id: Ib6a56aea56078b8c1fc9edddda469d7f41735ff7
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223300
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'common/lightbar.c')
-rw-r--r-- | common/lightbar.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/common/lightbar.c b/common/lightbar.c index cd6595bb21..f8dce75c50 100644 --- a/common/lightbar.c +++ b/common/lightbar.c @@ -76,7 +76,8 @@ static const struct lightbar_params_v1 default_params = { .s3_ramp_up = 2500, .s3_ramp_down = 10000, .tap_tick_delay = 5000, /* oscillation step time */ - .tap_display_time = 5 * SECOND, /* total sequence time */ + .tap_gate_delay = 200 * MSEC, /* segment gating delay */ + .tap_display_time = 3 * SECOND, /* total sequence time */ .tap_pct_red = 10, /* below this is red */ .tap_pct_green = 97, /* above this is green */ @@ -804,8 +805,10 @@ static uint32_t sequence_TAP_inner(void) { enum { RED, YELLOW, GREEN } base_color; timestamp_t start, now; + uint32_t elapsed_time = 0; int i, ci, max_led; int f_min, f_delta, f_osc, f_power, f_mult; + int gi, gr, gate[NUM_LEDS] = {0, 0, 0, 0}; uint8_t w = 0; f_min = st.p.tap_seg_min_on * FP_SCALE / 100; @@ -826,6 +829,14 @@ static uint32_t sequence_TAP_inner(void) ci = st.p.tap_idx[base_color]; max_led = st.battery_percent / CUT; + /* Enable the segments gradually */ + gi = elapsed_time / st.p.tap_gate_delay; + gr = elapsed_time % st.p.tap_gate_delay; + if (gi < NUM_LEDS) + gate[gi] = FP_SCALE * gr / st.p.tap_gate_delay; + if (gi && gi <= NUM_LEDS) + gate[gi - 1] = FP_SCALE; + for (i = 0; i < NUM_LEDS; i++) { if (max_led > i) { @@ -849,6 +860,8 @@ static uint32_t sequence_TAP_inner(void) f_mult = f_min + f_power * f_delta / FP_SCALE; } + f_mult = f_mult * gate[i] / FP_SCALE; + /* Pulse when charging */ if (st.battery_is_charging) { int scale = (FP_SCALE - @@ -865,7 +878,8 @@ static uint32_t sequence_TAP_inner(void) /* Return after some time has elapsed */ now = get_time(); - if (now.le.lo - start.le.lo > st.p.tap_display_time) + elapsed_time = now.le.lo - start.le.lo; + if (elapsed_time > st.p.tap_display_time) break; } return 0; |