diff options
Diffstat (limited to 'apps/wps-display.c')
-rw-r--r-- | apps/wps-display.c | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c index ec1e9c76e5..a8980855e4 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c | |||
@@ -37,10 +37,13 @@ | |||
37 | #include "status.h" | 37 | #include "status.h" |
38 | #include "wps-display.h" | 38 | #include "wps-display.h" |
39 | #include "debug.h" | 39 | #include "debug.h" |
40 | #include "mas.h" | ||
40 | #include "lang.h" | 41 | #include "lang.h" |
42 | |||
41 | #ifdef HAVE_LCD_BITMAP | 43 | #ifdef HAVE_LCD_BITMAP |
42 | #include "icons.h" | 44 | #include "icons.h" |
43 | #include "widgets.h" | 45 | #include "widgets.h" |
46 | #include "peakmeter.h" | ||
44 | #endif | 47 | #endif |
45 | 48 | ||
46 | #define WPS_CONFIG ROCKBOX_DIR "/default.wps" | 49 | #define WPS_CONFIG ROCKBOX_DIR "/default.wps" |
@@ -52,12 +55,12 @@ | |||
52 | #endif | 55 | #endif |
53 | 56 | ||
54 | #define FORMAT_BUFFER_SIZE 300 | 57 | #define FORMAT_BUFFER_SIZE 300 |
55 | |||
56 | struct format_flags | 58 | struct format_flags |
57 | { | 59 | { |
58 | bool dynamic; | 60 | bool dynamic; |
59 | bool scroll; | 61 | bool scroll; |
60 | bool player_progress; | 62 | bool player_progress; |
63 | bool peak_meter; | ||
61 | }; | 64 | }; |
62 | 65 | ||
63 | static char format_buffer[FORMAT_BUFFER_SIZE]; | 66 | static char format_buffer[FORMAT_BUFFER_SIZE]; |
@@ -331,6 +334,13 @@ static char* get_tag(struct mp3entry* id3, | |||
331 | case 't': /* Total Time */ | 334 | case 't': /* Total Time */ |
332 | format_time(buf, buf_size, id3->length); | 335 | format_time(buf, buf_size, id3->length); |
333 | return buf; | 336 | return buf; |
337 | |||
338 | #ifdef HAVE_LCD_BITMAP | ||
339 | case 'm': /* Peak Meter */ | ||
340 | flags->peak_meter = true; | ||
341 | flags->dynamic = true; | ||
342 | return "\x01"; | ||
343 | #endif | ||
334 | } | 344 | } |
335 | break; | 345 | break; |
336 | 346 | ||
@@ -518,6 +528,15 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_all) | |||
518 | bool scroll_active = false; | 528 | bool scroll_active = false; |
519 | int i; | 529 | int i; |
520 | 530 | ||
531 | /* to find out wether the peak meter is enabled we | ||
532 | assume it wasn't until we find a line that contains | ||
533 | the peak meter. We can't use peak_meter_enabled itself | ||
534 | because that would mean to turn off the meter thread | ||
535 | temporarily. (That shouldn't matter unless yield | ||
536 | or sleep is called but who knows...) | ||
537 | */ | ||
538 | bool enable_pm = false; | ||
539 | |||
521 | if (!id3) | 540 | if (!id3) |
522 | { | 541 | { |
523 | lcd_stop_scroll(); | 542 | lcd_stop_scroll(); |
@@ -537,6 +556,7 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_all) | |||
537 | flags.dynamic = false; | 556 | flags.dynamic = false; |
538 | flags.scroll = false; | 557 | flags.scroll = false; |
539 | flags.player_progress = false; | 558 | flags.player_progress = false; |
559 | flags.peak_meter = false; | ||
540 | format_display(buf, sizeof(buf), id3, format_lines[i], &flags); | 560 | format_display(buf, sizeof(buf), id3, format_lines[i], &flags); |
541 | dynamic_lines[i] = flags.dynamic; | 561 | dynamic_lines[i] = flags.dynamic; |
542 | 562 | ||
@@ -556,6 +576,30 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_all) | |||
556 | #endif | 576 | #endif |
557 | } | 577 | } |
558 | 578 | ||
579 | #ifdef HAVE_LCD_BITMAP | ||
580 | if (flags.peak_meter) { | ||
581 | int peak_meter_y; | ||
582 | int w,h; | ||
583 | int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0; | ||
584 | lcd_getstringsize("M",&w,&h); | ||
585 | |||
586 | peak_meter_y = i * h + offset; | ||
587 | |||
588 | /* The user might decide to have the peak meter in the last | ||
589 | line so that it is only displayed if no status bar is | ||
590 | visible. If so we neither want do draw nor enable the | ||
591 | peak meter. */ | ||
592 | if (peak_meter_y + h <= LCD_HEIGHT) { | ||
593 | /* found a line with a peak meter -> remember that we must | ||
594 | enable it later */ | ||
595 | enable_pm = true; | ||
596 | peak_meter_draw(0, peak_meter_y, LCD_WIDTH, | ||
597 | MIN(h, LCD_HEIGHT - peak_meter_y)); | ||
598 | } | ||
599 | continue; | ||
600 | } | ||
601 | #endif | ||
602 | |||
559 | if (!scroll_active && flags.scroll && !flags.dynamic) | 603 | if (!scroll_active && flags.scroll && !flags.dynamic) |
560 | { | 604 | { |
561 | scroll_active = true; | 605 | scroll_active = true; |
@@ -567,6 +611,10 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_all) | |||
567 | } | 611 | } |
568 | } | 612 | } |
569 | } | 613 | } |
614 | |||
615 | /* Now we know wether the peak meter is used. | ||
616 | So we can enable / disable the peak meter thread */ | ||
617 | peak_meter_enabled = enable_pm; | ||
570 | lcd_update(); | 618 | lcd_update(); |
571 | 619 | ||
572 | return true; | 620 | return true; |
@@ -602,7 +650,8 @@ void wps_display(struct mp3entry* id3) | |||
602 | "%ia\n" | 650 | "%ia\n" |
603 | "%fb kbit %fv\n" | 651 | "%fb kbit %fv\n" |
604 | "Time: %pc / %pt\n" | 652 | "Time: %pc / %pt\n" |
605 | "%pb\n"); | 653 | "%pb\n" |
654 | "%pm\n"); | ||
606 | #else | 655 | #else |
607 | wps_format("%s%pp/%pe: %?ia<%ia - >%?it<%it|%fm>\n" | 656 | wps_format("%s%pp/%pe: %?ia<%ia - >%?it<%it|%fm>\n" |
608 | "%pc/%pt\n"); | 657 | "%pc/%pt\n"); |