summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-04-16 16:10:05 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-15 05:20:14 +0000
commitc46f569a39210c5ecc7f2f767b6a77c9554f3d73 (patch)
tree8d5544c243b4f305706e448013f31bba61588679 /common
parent53eb009d52fe82409784dfa6f079d45e7a2339b5 (diff)
downloadchrome-ec-c46f569a39210c5ecc7f2f767b6a77c9554f3d73.tar.gz
Add standalone lightbar simulation tool
This adds an "extra/" directory to hold various experiments and optional programs. With this change, we add a tool that can simulate the lightbar behavior on the build machine. That can be used to experment with variations in the lightbar pattern code without needing to reflash a Pixel with a new EC to see the effect. There is no functional change to the EC code, just a couple of #ifdefs to allow common/lightbar.c to be compiled separately from the EC. BUG=none BRANCH=ToT TEST=make buildall -j cd extra make ./lightbar You may need to install the libxcb1-dev package on your build machine. Change-Id: I847ce7ea97cae792b1de1b91f488819e873b6555 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/199883
Diffstat (limited to 'common')
-rw-r--r--common/lightbar.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/common/lightbar.c b/common/lightbar.c
index 6508d897fb..82cc723555 100644
--- a/common/lightbar.c
+++ b/common/lightbar.c
@@ -6,6 +6,9 @@
* LED controls.
*/
+#ifdef LIGHTBAR_SIMULATION
+#include "simulation.h"
+#else
#include "battery.h"
#include "charge_state.h"
#include "common.h"
@@ -20,6 +23,7 @@
#include "task.h"
#include "timer.h"
#include "util.h"
+#endif
/*
* The Link lightbar had no version command, so defaulted to zero. We have
@@ -139,7 +143,7 @@ static void lightbar_restore_state(void)
static int last_backlight_level;
#endif
-static int demo_mode;
+static int demo_mode = DEMO_MODE_DEFAULT;
/* Update the known state. */
static void get_battery_level(void)
@@ -1016,7 +1020,7 @@ static void show_params(const struct lightbar_params *p)
ccprintf("%d\t\t# .s0a_tick_delay (battery)\n", p->s0a_tick_delay[0]);
ccprintf("%d\t\t# .s0a_tick_delay (AC)\n", p->s0a_tick_delay[1]);
ccprintf("%d\t\t# .s0s3_ramp_down\n", p->s0s3_ramp_down);
- ccprintf("%d\t# .s3_sleep_for\n", p->s3_sleep_for);
+ ccprintf("%d\t\t# .s3_sleep_for\n", p->s3_sleep_for);
ccprintf("%d\t\t# .s3_ramp_up\n", p->s3_ramp_up);
ccprintf("%d\t\t# .s3_ramp_down\n", p->s3_ramp_down);
ccprintf("%d\t\t# .new_s0\n", p->new_s0);
@@ -1032,7 +1036,7 @@ static void show_params(const struct lightbar_params *p)
p->bright_bl_on_min[0], p->bright_bl_on_min[1]);
ccprintf("0x%02x 0x%02x\t# .bright_bl_on_max (battery, AC)\n",
p->bright_bl_on_max[0], p->bright_bl_on_max[1]);
- ccprintf("%d %d %d\t\t# .battery_threshold\n",
+ ccprintf("%d %d %d\t# .battery_threshold\n",
p->battery_threshold[0],
p->battery_threshold[1],
p->battery_threshold[2]);
@@ -1089,6 +1093,10 @@ static int command_lightbar(int argc, char **argv)
}
if (!strcasecmp(argv[1], "params")) {
+#ifdef LIGHTBAR_SIMULATION
+ if (argc > 2)
+ lb_read_params_from_file(argv[2], &st.p);
+#endif
show_params(&st.p);
return EC_SUCCESS;
}