From 4e58d5c46ae9f63f6408ef6a0b47ef8327fad309 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Wed, 4 Mar 2015 17:07:55 -0800 Subject: samus: change tap for battery to not show dimmed last segment Change tap for battery lightbar sequence to not show the last segment dimmed as a percentage of your battery. BUG=chrome-os-partner:37335 BRANCH=samus TEST=use battfake console command to test out every increment of 10% and use "lightbar seq tap" to show tap. Change-Id: I4f38d26a8cfbecfa6efc86fcc8751ca8cb34879b Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/256191 Reviewed-by: Bill Richardson --- common/lightbar.c | 14 +++++++++++++- include/config.h | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/common/lightbar.c b/common/lightbar.c index f99e87f589..563cf70991 100644 --- a/common/lightbar.c +++ b/common/lightbar.c @@ -873,6 +873,7 @@ static uint32_t sequence_KONAMI(void) return r; } +#ifdef CONFIG_LIGHTBAR_TAP_DIM_LAST_SEGMENT /* Returns 0.0 to 1.0 for val in [min, min + ofs] */ static int range(int val, int min, int ofs) { @@ -882,6 +883,7 @@ static int range(int val, int min, int ofs) return FP_SCALE; return (val - min) * FP_SCALE / ofs; } +#endif /* Handy constant */ #define CUT (100 / NUM_LEDS) @@ -892,12 +894,15 @@ static uint32_t sequence_TAP_inner(int dir) timestamp_t start, now; uint32_t elapsed_time = 0; int i, l, ci, max_led; - int f_min, f_delta, f_osc, f_power, f_mult; + int f_osc, f_mult; int gi, gr, gate[NUM_LEDS] = {0, 0, 0, 0}; uint8_t w = 0; +#ifdef CONFIG_LIGHTBAR_TAP_DIM_LAST_SEGMENT + int f_min, f_delta, f_power; f_min = st.p.tap_seg_min_on * FP_SCALE / 100; f_delta = (st.p.tap_seg_max_on - st.p.tap_seg_min_on) * FP_SCALE / 100; +#endif f_osc = st.p.tap_seg_osc * FP_SCALE / 100; start = get_time(); @@ -924,6 +929,7 @@ static uint32_t sequence_TAP_inner(int dir) for (i = 0; i < NUM_LEDS; i++) { +#ifdef CONFIG_LIGHTBAR_TAP_DIM_LAST_SEGMENT if (max_led > i) { f_mult = FP_SCALE; } else if (max_led < i) { @@ -944,6 +950,12 @@ static uint32_t sequence_TAP_inner(int dir) } f_mult = f_min + f_power * f_delta / FP_SCALE; } +#else + if (max_led >= i) + f_mult = FP_SCALE; + else if (max_led < i) + f_mult = 0; +#endif f_mult = f_mult * gate[i] / FP_SCALE; diff --git a/include/config.h b/include/config.h index dc375be962..c4974dd471 100644 --- a/include/config.h +++ b/include/config.h @@ -881,6 +881,12 @@ */ #undef CONFIG_LIGHTBAR_POWER_RAILS +/* + * For tap sequence, show the last segment in dim to give a better idea of + * battery percentage. + */ +#undef CONFIG_LIGHTBAR_TAP_DIM_LAST_SEGMENT + /* * Low power idle options. These are disabled by default and all boards that * want to use low power idle must define it. When using the LFIOSC, the low -- cgit v1.2.1