summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-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)
51 return 0; 51 return 0;
52} 52}
53 53
54void loop(void) 54enum plugin_status loop(void)
55{ 55{
56 while (true) { 56 while (true) {
57 struct tm* t; 57 struct tm* t;
58 char buf[80]; 58 char buf[80];
59 int f; 59 int f;
60 int batt = rb->battery_level(); 60 int batt = rb->battery_level();
61 int button;
61 62
62 /* stop measuring when <5% battery left */ 63 /* stop measuring when <5% battery left */
63 if ((batt > 0) && (batt < 5)) 64 if ((batt > 0) && (batt < 5))
@@ -91,7 +92,23 @@ void loop(void)
91 rb->splash(0, true, buf); 92 rb->splash(0, true, buf);
92 93
93 /* simulate 128kbit/s (16kbyte/s) playback duration */ 94 /* simulate 128kbit/s (16kbyte/s) playback duration */
94 rb->sleep(HZ * (buffersize / 16384) - HZ*10); 95 do {
96 button = rb->button_get_w_tmo(HZ * (buffersize / 16384) - HZ*10);
97
98 /* Check if we shall exit the plugin */
99 if (button==BUTTON_ON ||
100#ifdef HAVE_RECORDER_KEYPAD
101 button==BUTTON_OFF
102#else
103 button==BUTTON_STOP
104#endif
105 )
106 return PLUGIN_OK;
107 if (button==SYS_USB_CONNECTED) {
108 rb->usb_screen();
109 return PLUGIN_USB_CONNECTED;
110 }
111 } while (!(button&(BUTTON_REL|BUTTON_REPEAT)));
95 112
96 /* simulate filling the mp3 buffer */ 113 /* simulate filling the mp3 buffer */
97 f = rb->open("/battery.dummy", O_RDONLY); 114 f = rb->open("/battery.dummy", O_RDONLY);
@@ -102,6 +119,7 @@ void loop(void)
102 rb->read(f, buffer, buffersize); 119 rb->read(f, buffer, buffersize);
103 rb->close(f); 120 rb->close(f);
104 } 121 }
122 return PLUGIN_OK;
105} 123}
106 124
107enum plugin_status plugin_start(struct plugin_api* api, void* parameter) 125enum 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)
113 if (init() < 0) 131 if (init() < 0)
114 return PLUGIN_OK; 132 return PLUGIN_OK;
115 133
116 loop(); 134 return loop();
117
118 return PLUGIN_OK;
119} 135}
120 136