diff options
Diffstat (limited to 'apps/plugins/battery_bench.c')
-rw-r--r-- | apps/plugins/battery_bench.c | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index 17d3b918cf..f258492363 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c | |||
@@ -289,11 +289,11 @@ static struct event_queue thread_q SHAREDBSS_ATTR; | |||
289 | static bool in_usb_mode; | 289 | static bool in_usb_mode; |
290 | static unsigned int buf_idx; | 290 | static unsigned int buf_idx; |
291 | 291 | ||
292 | static bool exit_tsr(bool reenter) | 292 | static int exit_tsr(bool reenter) |
293 | { | 293 | { |
294 | bool is_exit; | 294 | int exit_status; |
295 | long button; | 295 | long button; |
296 | (void)reenter; | 296 | |
297 | rb->lcd_clear_display(); | 297 | rb->lcd_clear_display(); |
298 | rb->lcd_puts_scroll(0, 0, "Batt.Bench is currently running."); | 298 | rb->lcd_puts_scroll(0, 0, "Batt.Bench is currently running."); |
299 | rb->lcd_puts_scroll(0, 1, "Press " BATTERY_OFF_TXT " to cancel the test"); | 299 | rb->lcd_puts_scroll(0, 1, "Press " BATTERY_OFF_TXT " to cancel the test"); |
@@ -313,16 +313,17 @@ static bool exit_tsr(bool reenter) | |||
313 | rb->thread_wait(gThread.id); | 313 | rb->thread_wait(gThread.id); |
314 | /* remove the thread's queue from the broadcast list */ | 314 | /* remove the thread's queue from the broadcast list */ |
315 | rb->queue_delete(&thread_q); | 315 | rb->queue_delete(&thread_q); |
316 | is_exit = true; | 316 | exit_status = (reenter ? PLUGIN_TSR_TERMINATE : PLUGIN_TSR_SUSPEND); |
317 | |||
317 | } | 318 | } |
318 | else is_exit = false; | 319 | else exit_status = PLUGIN_TSR_CONTINUE; |
319 | 320 | ||
320 | break; | 321 | break; |
321 | } | 322 | } |
322 | FOR_NB_SCREENS(idx) | 323 | FOR_NB_SCREENS(idx) |
323 | rb->screens[idx]->scroll_stop(); | 324 | rb->screens[idx]->scroll_stop(); |
324 | 325 | ||
325 | return is_exit; | 326 | return exit_status; |
326 | } | 327 | } |
327 | 328 | ||
328 | #define BIT_CHARGER 0x1 | 329 | #define BIT_CHARGER 0x1 |
@@ -502,14 +503,19 @@ static void put_centered_str(const char* str, plcdfunc putsxy, int lcd_width, in | |||
502 | 503 | ||
503 | enum plugin_status plugin_start(const void* parameter) | 504 | enum plugin_status plugin_start(const void* parameter) |
504 | { | 505 | { |
505 | (void)parameter; | ||
506 | int button, fd; | 506 | int button, fd; |
507 | bool resume = false; | ||
507 | bool on = false; | 508 | bool on = false; |
508 | start_tick = *rb->current_tick; | 509 | start_tick = *rb->current_tick; |
509 | int i; | 510 | int i; |
510 | const char *msgs[] = { "Battery Benchmark","Check file", BATTERY_LOG, | 511 | const char *msgs[] = { "Battery Benchmark","Check file", BATTERY_LOG, |
511 | "for more info", BATTERY_ON_TXT, BATTERY_OFF_TXT " - quit" }; | 512 | "for more info", BATTERY_ON_TXT, BATTERY_OFF_TXT " - quit" }; |
512 | rb->lcd_clear_display(); | 513 | |
514 | if (parameter == rb->plugin_tsr) | ||
515 | { | ||
516 | resume = true; | ||
517 | on = true; | ||
518 | } | ||
513 | 519 | ||
514 | rb->lcd_clear_display(); | 520 | rb->lcd_clear_display(); |
515 | rb->lcd_setfont(FONT_SYSFIXED); | 521 | rb->lcd_setfont(FONT_SYSFIXED); |
@@ -529,36 +535,38 @@ enum plugin_status plugin_start(const void* parameter) | |||
529 | rb->lcd_remote_putsxy,LCD_REMOTE_WIDTH,2); | 535 | rb->lcd_remote_putsxy,LCD_REMOTE_WIDTH,2); |
530 | rb->lcd_remote_update(); | 536 | rb->lcd_remote_update(); |
531 | #endif | 537 | #endif |
532 | 538 | if (!resume) | |
533 | do | ||
534 | { | 539 | { |
535 | button = rb->button_get(true); | 540 | do |
536 | switch (button) | ||
537 | { | 541 | { |
538 | case BATTERY_ON: | 542 | button = rb->button_get(true); |
539 | #ifdef BATTERY_RC_ON | 543 | switch (button) |
540 | case BATTERY_RC_ON: | 544 | { |
541 | #endif | 545 | case BATTERY_ON: |
542 | on = true; | 546 | #ifdef BATTERY_RC_ON |
543 | break; | 547 | case BATTERY_RC_ON: |
544 | case BATTERY_OFF: | 548 | #endif |
545 | #ifdef BATTERY_RC_OFF | 549 | on = true; |
546 | case BATTERY_RC_OFF: | 550 | break; |
547 | #endif | 551 | case BATTERY_OFF: |
548 | return PLUGIN_OK; | 552 | #ifdef BATTERY_RC_OFF |
549 | 553 | case BATTERY_RC_OFF: | |
550 | default: | 554 | #endif |
551 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) | 555 | return PLUGIN_OK; |
552 | return PLUGIN_USB_CONNECTED; | 556 | |
553 | } | 557 | default: |
554 | }while(!on); | 558 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) |
555 | 559 | return PLUGIN_USB_CONNECTED; | |
560 | } | ||
561 | }while(!on); | ||
562 | } | ||
556 | fd = rb->open(BATTERY_LOG, O_RDONLY); | 563 | fd = rb->open(BATTERY_LOG, O_RDONLY); |
557 | if (fd < 0) | 564 | if (fd < 0) |
558 | { | 565 | { |
559 | fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT, 0666); | 566 | fd = rb->open(BATTERY_LOG, O_RDWR | O_CREAT, 0666); |
560 | if (fd >= 0) | 567 | if (fd >= 0) |
561 | { | 568 | { |
569 | |||
562 | rb->fdprintf(fd, | 570 | rb->fdprintf(fd, |
563 | "# This plugin will log your battery performance in a\n" | 571 | "# This plugin will log your battery performance in a\n" |
564 | "# file (%s) every minute.\n" | 572 | "# file (%s) every minute.\n" |