lightbar: fix battery level hysteresis bug

Fix bug in get_battery_level() where we attempt to apply hysteresis
to the battery percentage when it jumps between levels. The problem
is if the battery jumps up multiple levels, then it won't always
update the battery level. For example, using level thresholds of
{14, 40, 99}, if you jump from 0% to 99%, it won't update the battery
level because it compares the new percentage, 99%, with the
battery threshold for the new level + 1 (100%).

BUG=chrome-os-partner:45878
BRANCH=smaug
TEST=use the battfake console command to jump from 5% to 99% and
verify that the lightbar goes from all red to google colors. note:
without this CL, the lightbar stays all red.

Change-Id: I5ae658c8c92469ebc7f516a04bda7b7fbcd32146
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302684
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
1 file changed