summaryrefslogtreecommitdiffstats
path: root/apps/plugins/battery_test.c
diff options
context:
space:
mode:
authorKjell Ericson <kjell@haxx.se>2004-06-23 08:49:55 +0000
committerKjell Ericson <kjell@haxx.se>2004-06-23 08:49:55 +0000
commit8877ad943eb077d10a0725b47c55a8b2f55f319a (patch)
tree6a3032671fbb1238572b84d13fbffde50f448cdf /apps/plugins/battery_test.c
parent986675dfd5436caf71c5e250665be8738900cf4e (diff)
downloadrockbox-8877ad943eb077d10a0725b47c55a8b2f55f319a.tar.gz
rockbox-8877ad943eb077d10a0725b47c55a8b2f55f319a.zip
Fixed so that the plugin is exitable (was irritating that the first plugin
in the list was the one you couldn't exit). Negative impact: It seems to do a disk acess in the beginning and update the display twice. Positive impact: Pressing a key (like play) will "stress" the test and force another disk access (and display update). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4801 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/battery_test.c')
-rw-r--r--apps/plugins/battery_test.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/apps/plugins/battery_test.c b/apps/plugins/battery_test.c
index 843c03ea7b..53e94ad02a 100644
--- a/apps/plugins/battery_test.c
+++ b/apps/plugins/battery_test.c
@@ -51,13 +51,14 @@ int init(void)
return 0;
}
-void loop(void)
+enum plugin_status loop(void)
{
while (true) {
struct tm* t;
char buf[80];
int f;
int batt = rb->battery_level();
+ int button;
/* stop measuring when <5% battery left */
if ((batt > 0) && (batt < 5))
@@ -91,7 +92,23 @@ void loop(void)
rb->splash(0, true, buf);
/* simulate 128kbit/s (16kbyte/s) playback duration */
- rb->sleep(HZ * (buffersize / 16384) - HZ*10);
+ do {
+ button = rb->button_get_w_tmo(HZ * (buffersize / 16384) - HZ*10);
+
+ /* Check if we shall exit the plugin */
+ if (button==BUTTON_ON ||
+#ifdef HAVE_RECORDER_KEYPAD
+ button==BUTTON_OFF
+#else
+ button==BUTTON_STOP
+#endif
+ )
+ return PLUGIN_OK;
+ if (button==SYS_USB_CONNECTED) {
+ rb->usb_screen();
+ return PLUGIN_USB_CONNECTED;
+ }
+ } while (!(button&(BUTTON_REL|BUTTON_REPEAT)));
/* simulate filling the mp3 buffer */
f = rb->open("/battery.dummy", O_RDONLY);
@@ -102,6 +119,7 @@ void loop(void)
rb->read(f, buffer, buffersize);
rb->close(f);
}
+ return PLUGIN_OK;
}
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
@@ -113,8 +131,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
if (init() < 0)
return PLUGIN_OK;
- loop();
-
- return PLUGIN_OK;
+ return loop();
}