Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 29fe4a4..e6efd38 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -248,12 +248,14 @@ enum plugin_status plugin_start(const void* parameter)
     return main();
 }

+long start_tick;
+
 /* Struct for battery information */
 struct batt_info
 {
     /* the size of the struct elements is optimised to make the struct size
      * a power of 2 */
-    long ticks;
+    unsigned secs;
     int eta;
     unsigned int voltage;
     short level;
@@ -329,7 +331,7 @@ static unsigned int charge_state(void)
 static void flush_buffer(void* data)
 {
     (void)data;
-    int fd, secs;
+    int fd;
     unsigned int i;

     /* don't access the disk when in usb mode, or when no data is available */
@@ -342,7 +344,6 @@ static void flush_buffer(void* data)

     for (i = 0; i < buf_idx; i++)
     {
-        secs = bat[i].ticks/HZ;
         rb->fdprintf(fd,
                 "%02d:%02d:%02d,  %05d,     %03d%%,     "
                 "%02d:%02d,         %04d,   "
@@ -357,7 +358,7 @@ static void flush_buffer(void* data)
 #endif
                 "\n",

-                HMS(secs), secs, bat[i].level,
+                HMS(bat[i].secs), bat[i].secs, bat[i].level,
                 bat[i].eta / 60, bat[i].eta % 60,
                 bat[i].voltage
 #if CONFIG_CHARGING
@@ -393,7 +394,7 @@ void thread(void)
         /* add data to buffer */
         if (buf_idx < BUF_ELEMENTS)
         {
-            bat[buf_idx].ticks = *rb->current_tick;
+            bat[buf_idx].secs = (*rb->current_tick - start_tick) / HZ;
             bat[buf_idx].level = rb->battery_level();
             bat[buf_idx].eta = rb->battery_time();
             bat[buf_idx].voltage = rb->battery_voltage();
@@ -470,6 +471,7 @@ int main(void)
 {
     int button, fd;
     bool on = false;
+    start_tick = *rb->current_tick;
 #ifdef HAVE_LCD_BITMAP
     int i;
     const char *msgs[] = { "Battery Benchmark","Check file", BATTERY_LOG,
@@ -548,8 +550,13 @@ int main(void)
                 "# Battery bench run for %s version %s\n\n"
                 ,MODEL_NAME,rb->rbversion);

+            rb->fdprintf(fd, "# Battery type: %d mAh      Buffer Entries: %d\n",
+                rb->global_settings->battery_capacity, (int)BUF_ELEMENTS);
+
+            rb->fdprintf(fd, "# Rockbox has been running for %02d:%02d:%02d\n",
+                HMS((unsigned)start_tick/HZ));
+
             rb->fdprintf(fd,
-                "# Battery type: %d mAh      Buffer Entries: %d\n"
                 "# Time:,  Seconds:,  Level:,  Time Left:,  Voltage[mV]:"
 #if CONFIG_CHARGING
                 ", C:"
@@ -560,9 +567,7 @@ int main(void)
 #ifdef HAVE_USB_POWER
                 ", U:"
 #endif
-                "\n"
-                ,rb->global_settings->battery_capacity,
-                (int)BUF_ELEMENTS);
+                "\n");
             rb->close(fd);
         }
         else
@@ -575,10 +580,12 @@ int main(void)
     {
         rb->close(fd);
         fd = rb->open(BATTERY_LOG, O_RDWR | O_APPEND);
-        rb->fdprintf(fd, "\n--File already present. Resuming Benchmark--\n");
+        rb->fdprintf(fd, "\n# --File already present. Resuming Benchmark--\n");
         rb->fdprintf(fd,
-            "Battery bench run for %s version %s\n\n"
+            "# Battery bench run for %s version %s\n\n"
             ,MODEL_NAME,rb->rbversion);
+        rb->fdprintf(fd, "# Rockbox has been running for %02d:%02d:%02d\n",
+            HMS((unsigned)start_tick/HZ));
         rb->close(fd);
     }