diff options
author | Björn Stenberg <bjorn@haxx.se> | 2003-02-27 14:00:36 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2003-02-27 14:00:36 +0000 |
commit | 0fb3fe66e9ac28ec55473e01cb6ad09d0184004f (patch) | |
tree | af13066f485dbe7ed2ea7194571664ba3d5b69db | |
parent | 6a58106e972c8dd7c1034f13f1b4138ee604869c (diff) | |
download | rockbox-0fb3fe66e9ac28ec55473e01cb6ad09d0184004f.tar.gz rockbox-0fb3fe66e9ac28ec55473e01cb6ad09d0184004f.zip |
Added s.bruder's wonderful full-line player progressbar + time display. Wps tag %pf.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3352 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/wps-display.c | 151 |
1 files changed, 143 insertions, 8 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c index 2ec467866b..04fd5aae2d 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c | |||
@@ -59,8 +59,11 @@ | |||
59 | #define FORMAT_BUFFER_SIZE 300 | 59 | #define FORMAT_BUFFER_SIZE 300 |
60 | 60 | ||
61 | #ifdef HAVE_LCD_CHARCELLS | 61 | #ifdef HAVE_LCD_CHARCELLS |
62 | unsigned char wps_progress_pat=0; | 62 | static unsigned char wps_progress_pat[6]={0,0,0,0,0,0}; |
63 | static bool full_line_progressbar=0; | ||
63 | static bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count); | 64 | static bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count); |
65 | static void draw_player_fullbar(char* buf, int buf_size, | ||
66 | struct mp3entry* id3, int ff_rewwind_count); | ||
64 | #endif | 67 | #endif |
65 | 68 | ||
66 | static char format_buffer[FORMAT_BUFFER_SIZE]; | 69 | static char format_buffer[FORMAT_BUFFER_SIZE]; |
@@ -382,12 +385,21 @@ static char* get_tag(struct mp3entry* id3, | |||
382 | case 'b': /* progress bar */ | 385 | case 'b': /* progress bar */ |
383 | *flags |= WPS_REFRESH_PLAYER_PROGRESS; | 386 | *flags |= WPS_REFRESH_PLAYER_PROGRESS; |
384 | #ifdef HAVE_LCD_CHARCELLS | 387 | #ifdef HAVE_LCD_CHARCELLS |
385 | snprintf(buf, buf_size, "%c", wps_progress_pat); | 388 | snprintf(buf, buf_size, "%c", wps_progress_pat[0]); |
389 | full_line_progressbar=0; | ||
386 | return buf; | 390 | return buf; |
387 | #else | 391 | #else |
388 | return "\x01"; | 392 | return "\x01"; |
389 | #endif | 393 | #endif |
390 | 394 | case 'f': /* full-line progress bar */ | |
395 | #ifdef HAVE_LCD_CHARCELLS | ||
396 | *flags |= WPS_REFRESH_PLAYER_PROGRESS; | ||
397 | *flags |= WPS_REFRESH_DYNAMIC; | ||
398 | full_line_progressbar=1; | ||
399 | /* we need 11 characters (full line) for progress-bar */ | ||
400 | snprintf(buf, buf_size, " "); | ||
401 | return buf; | ||
402 | #endif | ||
391 | case 'p': /* Playlist Position */ | 403 | case 'p': /* Playlist Position */ |
392 | *flags |= WPS_REFRESH_STATIC; | 404 | *flags |= WPS_REFRESH_STATIC; |
393 | snprintf(buf, buf_size, "%d", id3->index + 1); | 405 | snprintf(buf, buf_size, "%d", id3->index + 1); |
@@ -644,8 +656,10 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, unsigned char refresh_mo | |||
644 | bool enable_pm = false; | 656 | bool enable_pm = false; |
645 | #endif | 657 | #endif |
646 | #ifdef HAVE_LCD_CHARCELLS | 658 | #ifdef HAVE_LCD_CHARCELLS |
647 | if (wps_progress_pat==0) | 659 | for (i=0; i<6; i++) { |
648 | wps_progress_pat=lcd_get_locked_pattern(); | 660 | if (wps_progress_pat[i]==0) |
661 | wps_progress_pat[i]=lcd_get_locked_pattern(); | ||
662 | } | ||
649 | #endif | 663 | #endif |
650 | 664 | ||
651 | if (!id3) | 665 | if (!id3) |
@@ -703,7 +717,11 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, unsigned char refresh_mo | |||
703 | #else | 717 | #else |
704 | /* progress */ | 718 | /* progress */ |
705 | if (flags & refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) { | 719 | if (flags & refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) { |
706 | draw_player_progress(id3, ff_rewind_count); | 720 | if (full_line_progressbar) |
721 | draw_player_fullbar(buf, sizeof(buf), | ||
722 | id3, ff_rewind_count); | ||
723 | else | ||
724 | draw_player_progress(id3, ff_rewind_count); | ||
707 | } | 725 | } |
708 | #endif | 726 | #endif |
709 | if (flags & WPS_REFRESH_SCROLL) { | 727 | if (flags & WPS_REFRESH_SCROLL) { |
@@ -780,7 +798,7 @@ bool wps_display(struct mp3entry* id3) | |||
780 | return false; | 798 | return false; |
781 | } | 799 | } |
782 | 800 | ||
783 | #if defined(HAVE_LCD_CHARCELLS) | 801 | #ifdef HAVE_LCD_CHARCELLS |
784 | static bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count) | 802 | static bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count) |
785 | { | 803 | { |
786 | char player_progressbar[7]; | 804 | char player_progressbar[7]; |
@@ -812,9 +830,126 @@ static bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count) | |||
812 | player_progressbar[i] += binline[i*5+j]; | 830 | player_progressbar[i] += binline[i*5+j]; |
813 | } | 831 | } |
814 | } | 832 | } |
815 | lcd_define_pattern(wps_progress_pat, player_progressbar); | 833 | lcd_define_pattern(wps_progress_pat[0], player_progressbar); |
816 | return true; | 834 | return true; |
817 | } | 835 | } |
836 | |||
837 | static void draw_player_fullbar(char* buf, int buf_size, | ||
838 | struct mp3entry* id3, int ff_rewwind_count) | ||
839 | { | ||
840 | int i,j,digit; | ||
841 | |||
842 | char player_progressbar[7]; | ||
843 | char binline[36]; | ||
844 | char numbers[11][4][3]={{{1,1,1},{1,0,1},{1,0,1},{1,1,1}},/*0*/ | ||
845 | {{0,1,0},{1,1,0},{0,1,0},{0,1,0}},/*1*/ | ||
846 | {{1,1,1},{0,0,1},{0,1,0},{1,1,1}},/*2*/ | ||
847 | {{1,1,1},{0,0,1},{0,1,1},{1,1,1}},/*3*/ | ||
848 | {{1,0,0},{1,1,0},{1,1,1},{0,1,0}},/*4*/ | ||
849 | {{1,1,1},{1,1,0},{0,0,1},{1,1,0}},/*5*/ | ||
850 | {{1,1,1},{1,0,0},{1,1,1},{1,1,1}},/*6*/ | ||
851 | {{1,1,1},{0,0,1},{0,1,0},{1,0,0}},/*7*/ | ||
852 | {{1,1,1},{1,1,1},{1,0,1},{1,1,1}},/*8*/ | ||
853 | {{1,1,1},{1,1,1},{0,0,1},{1,1,1}},/*9*/ | ||
854 | {{0,0,0},{0,1,0},{0,0,0},{0,1,0}}};/*:*/ | ||
855 | |||
856 | int songpos = 0; | ||
857 | int digits[5]; | ||
858 | |||
859 | for (i=0; i < buf_size; i++) | ||
860 | buf[i] = ' '; | ||
861 | |||
862 | if(id3->elapsed >= id3->length) | ||
863 | songpos = 11; | ||
864 | else { | ||
865 | if(wps_time_countup == false) | ||
866 | songpos = ((id3->elapsed - ff_rewwind_count) * 55) / id3->length; | ||
867 | else | ||
868 | songpos = ((id3->elapsed + ff_rewwind_count) * 55) / id3->length; | ||
869 | } | ||
870 | |||
871 | int time=(id3->elapsed + ff_rewind_count); | ||
872 | |||
873 | digits[4]=(time % 60000 / 1000 ) % 10; | ||
874 | digits[3]=(time % 60000 / 10000) % 10; | ||
875 | digits[2]=10; /*:*/ | ||
876 | digits[1]=(time / 60000 ) % 10; | ||
877 | digits[0]=(time / 600000) % 10; | ||
878 | |||
879 | /* build the progressbar-icon */ | ||
880 | for (digit=0; digit <=4; digit++) { | ||
881 | memset(binline, 0, sizeof binline); | ||
882 | memset(player_progressbar, 0, sizeof player_progressbar); | ||
883 | |||
884 | /* make the character (progressbar & digit)*/ | ||
885 | for (i=0; i<=6; i++) { | ||
886 | for (j=0;j<5;j++) { | ||
887 | /* make the progressbar */ | ||
888 | if (digit==(songpos/5)) { | ||
889 | /* partial */ | ||
890 | if ((j<(songpos%5))&&(i>4)) | ||
891 | binline[i*5+j] = 1; | ||
892 | else | ||
893 | binline[i*5+j] = 0; | ||
894 | } | ||
895 | else { | ||
896 | if (digit<(songpos/5)) { | ||
897 | /* full character */ | ||
898 | if (i>4) | ||
899 | binline[i*5+j] = 1; | ||
900 | } | ||
901 | } | ||
902 | /* insert the digit */ | ||
903 | if ((j<3)&&(i<4)) { | ||
904 | if (numbers[digits[digit]][i][j]==1) | ||
905 | binline[i*5+j] = 1; | ||
906 | } | ||
907 | } | ||
908 | } | ||
909 | |||
910 | for (i=0; i<=6; i++) { | ||
911 | for (j=0;j<5;j++) { | ||
912 | player_progressbar[i] <<= 1; | ||
913 | player_progressbar[i] += binline[i*5+j]; | ||
914 | } | ||
915 | } | ||
916 | |||
917 | lcd_define_pattern(wps_progress_pat[digit],player_progressbar); | ||
918 | buf[digit]=wps_progress_pat[digit]; | ||
919 | |||
920 | } | ||
921 | |||
922 | /* make rest of the progressbar if necessary */ | ||
923 | if (songpos/5>4) { | ||
924 | |||
925 | memset(binline, 0, sizeof binline); | ||
926 | memset(player_progressbar, 0, sizeof player_progressbar); | ||
927 | |||
928 | for (i=5; i<=6; i++) { | ||
929 | for (j=0;j<5;j++) { | ||
930 | if (j<(songpos%5)) { | ||
931 | binline[i*5+j] = 1; | ||
932 | } | ||
933 | } | ||
934 | } | ||
935 | |||
936 | for (i=0; i<=6; i++) { | ||
937 | for (j=0;j<5;j++) { | ||
938 | player_progressbar[i] <<= 1; | ||
939 | player_progressbar[i] += binline[i*5+j]; | ||
940 | } | ||
941 | } | ||
942 | |||
943 | lcd_define_pattern(wps_progress_pat[5],player_progressbar); | ||
944 | |||
945 | for (i=5; i < (songpos/5); i++) | ||
946 | buf[i] = 0x86; /* '_' */ | ||
947 | |||
948 | buf[songpos/5]=wps_progress_pat[5]; | ||
949 | } | ||
950 | |||
951 | } | ||
952 | |||
818 | #endif | 953 | #endif |
819 | 954 | ||
820 | /* ----------------------------------------------------------------- | 955 | /* ----------------------------------------------------------------- |