summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/battery_bench.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 29fe4a484a..e6efd38d96 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)
248 return main(); 248 return main();
249} 249}
250 250
251long start_tick;
252
251/* Struct for battery information */ 253/* Struct for battery information */
252struct batt_info 254struct batt_info
253{ 255{
254 /* the size of the struct elements is optimised to make the struct size 256 /* the size of the struct elements is optimised to make the struct size
255 * a power of 2 */ 257 * a power of 2 */
256 long ticks; 258 unsigned secs;
257 int eta; 259 int eta;
258 unsigned int voltage; 260 unsigned int voltage;
259 short level; 261 short level;
@@ -329,7 +331,7 @@ static unsigned int charge_state(void)
329static void flush_buffer(void* data) 331static void flush_buffer(void* data)
330{ 332{
331 (void)data; 333 (void)data;
332 int fd, secs; 334 int fd;
333 unsigned int i; 335 unsigned int i;
334 336
335 /* don't access the disk when in usb mode, or when no data is available */ 337 /* 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)
342 344
343 for (i = 0; i < buf_idx; i++) 345 for (i = 0; i < buf_idx; i++)
344 { 346 {
345 secs = bat[i].ticks/HZ;
346 rb->fdprintf(fd, 347 rb->fdprintf(fd,
347 "%02d:%02d:%02d, %05d, %03d%%, " 348 "%02d:%02d:%02d, %05d, %03d%%, "
348 "%02d:%02d, %04d, " 349 "%02d:%02d, %04d, "
@@ -357,7 +358,7 @@ static void flush_buffer(void* data)
357#endif 358#endif
358 "\n", 359 "\n",
359 360
360 HMS(secs), secs, bat[i].level, 361 HMS(bat[i].secs), bat[i].secs, bat[i].level,
361 bat[i].eta / 60, bat[i].eta % 60, 362 bat[i].eta / 60, bat[i].eta % 60,
362 bat[i].voltage 363 bat[i].voltage
363#if CONFIG_CHARGING 364#if CONFIG_CHARGING
@@ -393,7 +394,7 @@ void thread(void)
393 /* add data to buffer */ 394 /* add data to buffer */
394 if (buf_idx < BUF_ELEMENTS) 395 if (buf_idx < BUF_ELEMENTS)
395 { 396 {
396 bat[buf_idx].ticks = *rb->current_tick; 397 bat[buf_idx].secs = (*rb->current_tick - start_tick) / HZ;
397 bat[buf_idx].level = rb->battery_level(); 398 bat[buf_idx].level = rb->battery_level();
398 bat[buf_idx].eta = rb->battery_time(); 399 bat[buf_idx].eta = rb->battery_time();
399 bat[buf_idx].voltage = rb->battery_voltage(); 400 bat[buf_idx].voltage = rb->battery_voltage();
@@ -470,6 +471,7 @@ int main(void)
470{ 471{
471 int button, fd; 472 int button, fd;
472 bool on = false; 473 bool on = false;
474 start_tick = *rb->current_tick;
473#ifdef HAVE_LCD_BITMAP 475#ifdef HAVE_LCD_BITMAP
474 int i; 476 int i;
475 const char *msgs[] = { "Battery Benchmark","Check file", BATTERY_LOG, 477 const char *msgs[] = { "Battery Benchmark","Check file", BATTERY_LOG,
@@ -548,8 +550,13 @@ int main(void)
548 "# Battery bench run for %s version %s\n\n" 550 "# Battery bench run for %s version %s\n\n"
549 ,MODEL_NAME,rb->rbversion); 551 ,MODEL_NAME,rb->rbversion);
550 552
553 rb->fdprintf(fd, "# Battery type: %d mAh Buffer Entries: %d\n",
554 rb->global_settings->battery_capacity, (int)BUF_ELEMENTS);
555
556 rb->fdprintf(fd, "# Rockbox has been running for %02d:%02d:%02d\n",
557 HMS((unsigned)start_tick/HZ));
558
551 rb->fdprintf(fd, 559 rb->fdprintf(fd,
552 "# Battery type: %d mAh Buffer Entries: %d\n"
553 "# Time:, Seconds:, Level:, Time Left:, Voltage[mV]:" 560 "# Time:, Seconds:, Level:, Time Left:, Voltage[mV]:"
554#if CONFIG_CHARGING 561#if CONFIG_CHARGING
555 ", C:" 562 ", C:"
@@ -560,9 +567,7 @@ int main(void)
560#ifdef HAVE_USB_POWER 567#ifdef HAVE_USB_POWER
561 ", U:" 568 ", U:"
562#endif 569#endif
563 "\n" 570 "\n");
564 ,rb->global_settings->battery_capacity,
565 (int)BUF_ELEMENTS);
566 rb->close(fd); 571 rb->close(fd);
567 } 572 }
568 else 573 else
@@ -575,10 +580,12 @@ int main(void)
575 { 580 {
576 rb->close(fd); 581 rb->close(fd);
577 fd = rb->open(BATTERY_LOG, O_RDWR | O_APPEND); 582 fd = rb->open(BATTERY_LOG, O_RDWR | O_APPEND);
578 rb->fdprintf(fd, "\n--File already present. Resuming Benchmark--\n"); 583 rb->fdprintf(fd, "\n# --File already present. Resuming Benchmark--\n");
579 rb->fdprintf(fd, 584 rb->fdprintf(fd,
580 "Battery bench run for %s version %s\n\n" 585 "# Battery bench run for %s version %s\n\n"
581 ,MODEL_NAME,rb->rbversion); 586 ,MODEL_NAME,rb->rbversion);
587 rb->fdprintf(fd, "# Rockbox has been running for %02d:%02d:%02d\n",
588 HMS((unsigned)start_tick/HZ));
582 rb->close(fd); 589 rb->close(fd);
583 } 590 }
584 591