sensor: shell: Add a 'battery' command

It is useful to show sensor channels for a battery in cohesive block as
it is easier to read. Add a 'battery' command to handle this. It only
supports a single battery, relying on the device-tree alias to select
it.

uart:~$ battery
Temp:  23.55 C
V:     4.31 V
V-desired: 4.40 V
I:    574 mA (CHG)
I-desired:  2000 mA
Charging: Not Allowed
Charge: 100 %
V-design: 3.86 V
Remaining: 6764 mA
Cap-full: 6764 mA
Design: 6910 mA
Time full: 0h:00
Time empty: 0h:00

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2020-05-15 16:26:45 -06:00 committed by Anas Nashif
commit 5afdceee8c
3 changed files with 131 additions and 0 deletions

View file

@ -27,6 +27,14 @@ config SENSOR_SHELL
help
This shell provides access to basic sensor data.
config SENSOR_SHELL_BATTERY
bool "Enable sensor shell 'battery' command"
depends on SHELL
help
This enables the 'battery' command which reports charging information
in a convenient format. It makes use of a fuel gauge to read its
information.
comment "Device Drivers"
source "drivers/sensor/adt7420/Kconfig"