Pressing "R" to refresh does not update regulator and sensor values
Fix this bug, and read regulator and sensor datas again when "R"
key pressed.
Signed-off-by: Shaojie Sun <shaojie.sun@linaro.com>
diff --git a/sensor.c b/sensor.c
index bd8c354..0645d25 100644
--- a/sensor.c
+++ b/sensor.c
@@ -161,6 +161,11 @@
return 0;
}
+static int read_sensor_info(struct tree *tree)
+{
+ return tree_for_each(tree, read_sensor_cb, NULL);
+}
+
static int fill_sensor_cb(struct tree *t, void *data)
{
struct sensor_info *sensor;
@@ -250,7 +255,7 @@
return ret;
}
-static int sensor_display(bool refresh)
+static int sensor_print_info(struct tree *tree)
{
int ret, line = 0;
@@ -258,13 +263,21 @@
sensor_print_header();
- ret = tree_for_each(sensor_tree, sensor_display_cb, &line);
+ ret = tree_for_each(tree, sensor_display_cb, &line);
display_refresh_pad(SENSOR);
return ret;
}
+static int sensor_display(bool refresh)
+{
+ if (refresh && read_sensor_info(sensor_tree))
+ return -1;
+
+ return sensor_print_info(sensor_tree);
+}
+
static struct display_ops sensor_ops = {
.display = sensor_display,
};