summaryrefslogtreecommitdiffstats
path: root/utils/nwztools/plattools/test_power.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-10-31 17:50:16 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2016-10-31 17:50:16 +0100
commit0a2290653ba6c6361baed9d317e6bc8fee52d6c2 (patch)
tree9df27d31a8fcf87b91707c9fe5c6268c1bbd0475 /utils/nwztools/plattools/test_power.c
parentad9a2d5241ffd7954cb3d15b2cd28f20be63f597 (diff)
downloadrockbox-0a2290653ba6c6361baed9d317e6bc8fee52d6c2.tar.gz
rockbox-0a2290653ba6c6361baed9d317e6bc8fee52d6c2.tar.bz2
rockbox-0a2290653ba6c6361baed9d317e6bc8fee52d6c2.zip
nwztools/plattools: rework/clean and add an all-in-one tool
This new tool (all_tools) embeds all the other tools and provides a menu to choose which one to run. Change-Id: I0e07864dd46559a7079b0f942c25155e6fa07112
Diffstat (limited to 'utils/nwztools/plattools/test_power.c')
-rw-r--r--utils/nwztools/plattools/test_power.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/utils/nwztools/plattools/test_power.c b/utils/nwztools/plattools/test_power.c
index 9c429b989a..f0d374bf7b 100644
--- a/utils/nwztools/plattools/test_power.c
+++ b/utils/nwztools/plattools/test_power.c
@@ -19,6 +19,7 @@
*
****************************************************************************/
#include "nwz_lib.h"
+#include "nwz_plattools.h"
static const char *charge_status_name(int chgstat)
{
@@ -59,7 +60,7 @@ static const char *acc_charge_mode_name(int mode)
}
}
-int main(int argc, char **argv)
+int NWZ_TOOL_MAIN(test_power)(int argc, char **argv)
{
/* clear screen and display welcome message */
nwz_lcdmsg(true, 0, 0, "test_power");
@@ -76,10 +77,21 @@ int main(int argc, char **argv)
int power_fd = nwz_power_open();
if(power_fd < 0)
{
+ nwz_key_close(input_fd);
nwz_lcdmsg(false, 3, 4, "Cannot open power device");
sleep(2);
return 1;
}
+ /* open pminfo device */
+ int pminfo_fd = nwz_pminfo_open();
+ if(pminfo_fd < 0)
+ {
+ nwz_key_close(power_fd);
+ nwz_key_close(input_fd);
+ nwz_lcdmsg(false, 3, 4, "Cannot open pminfo device");
+ sleep(2);
+ return 1;
+ }
/* display input state in a loop */
while(1)
{
@@ -119,6 +131,9 @@ int main(int argc, char **argv)
nwz_power_get_vbat_voltage(power_fd), nwz_power_get_vbat_adval(power_fd));
nwz_lcdmsgf(false, 0, line++, "acc charge mode: %s (%d) ",
acc_charge_mode_name(acc_chg_mode), acc_chg_mode);
+ /* pminfo */
+ line++;
+ nwz_lcdmsgf(false, 0, line++, "pminfo: %#x ", nwz_pminfo_get_factor(pminfo_fd));
/* wait for event (1s) */
int ret = nwz_key_wait_event(input_fd, 1000000);
if(ret != 1)
@@ -130,5 +145,8 @@ int main(int argc, char **argv)
break;
}
/* finish nicely */
+ nwz_key_close(power_fd);
+ nwz_key_close(input_fd);
+ nwz_pminfo_close(pminfo_fd);
return 0;
}