summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/plugins/SOURCES1
-rw-r--r--apps/plugins/battery_test.c159
2 files changed, 0 insertions, 160 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index b7afa811e9..713ac8df7b 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -1,6 +1,5 @@
1/* plugins common to all models */ 1/* plugins common to all models */
2battery_bench.c 2battery_bench.c
3battery_test.c
4chessclock.c 3chessclock.c
5credits.c 4credits.c
6cube.c 5cube.c
diff --git a/apps/plugins/battery_test.c b/apps/plugins/battery_test.c
deleted file mode 100644
index cbea016d13..0000000000
--- a/apps/plugins/battery_test.c
+++ /dev/null
@@ -1,159 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004 Björn Stenberg
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "plugin.h"
20
21/* This plugin is designed to measure your battery performance in real-time.
22 It will create a big file, read it every ~90 seconds and log the
23 battery level in /battery.log
24
25 When battery level goes below 5% the plugin exits, to avoid writing to
26 disk in very low battery situations.
27
28 Note that this test will run for 10-15 hours or more and is very boring
29 to watch.
30*/
31
32PLUGIN_HEADER
33
34/* variable button definitions */
35#if CONFIG_KEYPAD == RECORDER_PAD
36#define BATTERY_TEST_QUIT BUTTON_OFF
37#elif CONFIG_KEYPAD == ONDIO_PAD
38#define BATTERY_TEST_QUIT BUTTON_OFF
39#elif CONFIG_KEYPAD == PLAYER_PAD
40#define BATTERY_TEST_QUIT BUTTON_STOP
41#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
42 (CONFIG_KEYPAD == IRIVER_H300_PAD)
43#define BATTERY_TEST_QUIT BUTTON_OFF
44#define BATTERY_TEST_RC_QUIT BUTTON_RC_STOP
45#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
46#define BATTERY_TEST_QUIT BUTTON_PLAY
47#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
48 (CONFIG_KEYPAD == IPOD_3G_PAD)
49#define BATTERY_TEST_QUIT BUTTON_MENU
50#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
51#define BATTERY_TEST_QUIT BUTTON_POWER
52#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
53#define BATTERY_TEST_QUIT BUTTON_A
54#endif
55
56static struct plugin_api* rb;
57
58void* buffer;
59int buffersize;
60
61int init(void)
62{
63 int f;
64 buffer = rb->plugin_get_audio_buffer(&buffersize);
65
66#ifdef HAVE_MMC
67 /* present info what's going on. MMC is slow. */
68 rb->splash(0, true, "Creating dummy file.");
69#endif
70
71 /* create a big dummy file */
72 f = rb->creat("/battery.dummy", O_WRONLY);
73 if (f<0) {
74 rb->splash(HZ, true, "Can't create /battery.dummy");
75 return -1;
76 }
77 rb->write(f, buffer, buffersize);
78 rb->close(f);
79
80 return 0;
81}
82
83enum plugin_status loop(void)
84{
85 while (true) {
86 struct tm* t;
87 char buf[80];
88 int f;
89 int batt = rb->battery_level();
90 int button;
91
92 /* stop measuring when <5% battery left */
93 if ((batt > 0) && (batt < 5))
94 break;
95
96 /* log current time */
97 f = rb->open("/battery.log", O_WRONLY | O_APPEND | O_CREAT);
98 if (f<0) {
99 rb->splash(HZ, true, "Failed creating /battery.log");
100 break;
101 }
102#ifdef CONFIG_RTC
103 t = rb->get_time();
104#else
105 {
106 static struct tm temp;
107 long t2 = *rb->current_tick/HZ;
108 temp.tm_hour=t2/3600;
109 temp.tm_min=(t2/60)%60;
110 temp.tm_sec=t2%60;
111 t=&temp;
112 }
113#endif
114 rb->snprintf(buf, sizeof buf, "%02d:%02d:%02d Battery %d%%\n",
115 t->tm_hour, t->tm_min, t->tm_sec, batt);
116 rb->write(f, buf, rb->strlen(buf));
117 rb->close(f);
118
119 rb->snprintf(buf, sizeof buf, "%02d:%02d:%02d Battery %d%%%%",
120 t->tm_hour, t->tm_min, t->tm_sec, batt);
121 rb->splash(0, true, buf);
122
123 /* simulate 128 kbit/s (16000 byte/s) playback duration */
124 rb->button_clear_queue();
125 button = rb->button_get_w_tmo(HZ * buffersize / 16000 - HZ*10);
126
127 if (button == BATTERY_TEST_QUIT
128#ifdef BATTERY_TEST_RC_QUIT
129 || button == BATTERY_TEST_RC_QUIT
130#endif
131 )
132 return PLUGIN_OK;
133
134 if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
135 return PLUGIN_USB_CONNECTED;
136
137 /* simulate filling the mp3 buffer */
138 f = rb->open("/battery.dummy", O_RDONLY);
139 if (f<0) {
140 rb->splash(HZ, true, "Failed opening /battery.dummy");
141 break;
142 }
143 rb->read(f, buffer, buffersize);
144 rb->close(f);
145 }
146 return PLUGIN_OK;
147}
148
149enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
150{
151 (void)parameter;
152 rb = api;
153
154 if (init() < 0)
155 return PLUGIN_OK;
156
157 return loop();
158}
159