summaryrefslogtreecommitdiff
path: root/apps/wps.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/wps.c')
-rw-r--r--apps/wps.c145
1 files changed, 80 insertions, 65 deletions
diff --git a/apps/wps.c b/apps/wps.c
index 9840b50566..3462be90de 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -44,75 +44,88 @@
44static void draw_screen(struct mp3entry* id3) 44static void draw_screen(struct mp3entry* id3)
45{ 45{
46 lcd_clear_display(); 46 lcd_clear_display();
47 switch ( global_settings.wps_display ) { 47 if(!id3)
48 case PLAY_DISPLAY_TRACK_TITLE: 48 {
49 { 49#ifdef HAVE_LCD_CHARCELLS
50 char ch = '/'; 50 lcd_puts(0, 0, "End of list");
51 char* end; 51 lcd_puts(0, 1, "<Press ON>");
52 char* szTok; 52#else
53 char* szDelimit; 53 lcd_puts(0, 2, "<End of song list>");
54 char* szPeriod; 54 lcd_puts(5, 4, "Press ON");
55 char szArtist[26]; 55#endif
56 char szBuff[257]; 56 }
57 szBuff[sizeof(szBuff)-1] = 0; 57 else
58 58 {
59 strncpy(szBuff, id3->path, sizeof(szBuff)); 59 switch ( global_settings.wps_display ) {
60 60 case PLAY_DISPLAY_TRACK_TITLE:
61 szTok = strtok_r(szBuff, "/", &end); 61 {
62 szTok = strtok_r(NULL, "/", &end); 62 char ch = '/';
63 63 char* end;
64 // Assume path format of: Genre/Artist/Album/Mp3_file 64 char* szTok;
65 strncpy(szArtist,szTok,sizeof(szArtist)); 65 char* szDelimit;
66 szArtist[sizeof(szArtist)-1] = 0; 66 char* szPeriod;
67 szDelimit = strrchr(id3->path, ch); 67 char szArtist[26];
68 lcd_puts(0,0, szArtist?szArtist:"<nothing>"); 68 char szBuff[257];
69 69 szBuff[sizeof(szBuff)-1] = 0;
70 // removes the .mp3 from the end of the display buffer 70
71 szPeriod = strrchr(szDelimit, '.'); 71 strncpy(szBuff, id3->path, sizeof(szBuff));
72 if (szPeriod != NULL) 72
73 *szPeriod = 0; 73 szTok = strtok_r(szBuff, "/", &end);
74 74 szTok = strtok_r(NULL, "/", &end);
75 lcd_puts_scroll(0,LINE_Y,(++szDelimit)); 75
76 break; 76 // Assume path format of: Genre/Artist/Album/Mp3_file
77 } 77 strncpy(szArtist,szTok,sizeof(szArtist));
78 case PLAY_DISPLAY_FILENAME_SCROLL: 78 szArtist[sizeof(szArtist)-1] = 0;
79 { 79 szDelimit = strrchr(id3->path, ch);
80 char ch = '/'; 80 lcd_puts(0,0, szArtist?szArtist:"<nothing>");
81 char* szLast = strrchr(id3->path, ch); 81
82 82 // removes the .mp3 from the end of the display buffer
83 if (szLast) 83 szPeriod = strrchr(szDelimit, '.');
84 lcd_puts_scroll(0,0, (++szLast)); 84 if (szPeriod != NULL)
85 else 85 *szPeriod = 0;
86 lcd_puts_scroll(0,0, id3->path); 86
87 break; 87 lcd_puts_scroll(0,LINE_Y,(++szDelimit));
88 } 88 break;
89 case PLAY_DISPLAY_DEFAULT: 89 }
90 { 90 case PLAY_DISPLAY_FILENAME_SCROLL:
91 int l = 0; 91 {
92 char ch = '/';
93 char* szLast = strrchr(id3->path, ch);
94
95 if (szLast)
96 lcd_puts_scroll(0,0, (++szLast));
97 else
98 lcd_puts_scroll(0,0, id3->path);
99 break;
100 }
101 case PLAY_DISPLAY_DEFAULT:
102 {
103 int l = 0;
92#ifdef HAVE_LCD_BITMAP 104#ifdef HAVE_LCD_BITMAP
93 char buffer[64]; 105 char buffer[64];
94 106
95 lcd_puts_scroll(0, l++, id3->path); 107 lcd_puts_scroll(0, l++, id3->path);
96 lcd_puts(0, l++, id3->title?id3->title:""); 108 lcd_puts(0, l++, id3->title?id3->title:"");
97 lcd_puts(0, l++, id3->album?id3->album:""); 109 lcd_puts(0, l++, id3->album?id3->album:"");
98 lcd_puts(0, l++, id3->artist?id3->artist:""); 110 lcd_puts(0, l++, id3->artist?id3->artist:"");
99 111
100 if(id3->vbr) 112 if(id3->vbr)
101 snprintf(buffer, sizeof(buffer), "%d kbit (avg)", 113 snprintf(buffer, sizeof(buffer), "%d kbit (avg)",
102 id3->bitrate); 114 id3->bitrate);
103 else 115 else
104 snprintf(buffer, sizeof(buffer), "%d kbit", id3->bitrate); 116 snprintf(buffer, sizeof(buffer), "%d kbit", id3->bitrate);
105 117
106 lcd_puts(0, l++, buffer); 118 lcd_puts(0, l++, buffer);
107 119
108 snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency); 120 snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency);
109 lcd_puts(0, l++, buffer); 121 lcd_puts(0, l++, buffer);
110#else 122#else
111 123
112 lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>"); 124 lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>");
113 lcd_puts_scroll(0, l++, id3->title?id3->title:"<no title>"); 125 lcd_puts_scroll(0, l++, id3->title?id3->title:"<no title>");
114#endif 126#endif
115 break; 127 break;
128 }
116 } 129 }
117 } 130 }
118 status_draw(); 131 status_draw();
@@ -128,6 +141,7 @@ int wps_show(void)
128 bool dont_go_to_menu = false; 141 bool dont_go_to_menu = false;
129 142
130 lcd_clear_display(); 143 lcd_clear_display();
144 draw_screen(id3);
131 145
132 while ( 1 ) { 146 while ( 1 ) {
133 int i; 147 int i;
@@ -135,11 +149,12 @@ int wps_show(void)
135 149
136 if(mpeg_has_changed_track()) 150 if(mpeg_has_changed_track())
137 { 151 {
138 lcd_stop_scroll(); 152 lcd_stop_scroll();
153 id3 = mpeg_current_track();
139 draw_screen(id3); 154 draw_screen(id3);
140 } 155 }
141 156
142 if (playing) 157 if (playing && id3)
143 { 158 {
144#ifdef HAVE_LCD_BITMAP 159#ifdef HAVE_LCD_BITMAP
145 snprintf(buffer,sizeof(buffer), "Time: %d:%02d / %d:%02d", 160 snprintf(buffer,sizeof(buffer), "Time: %d:%02d / %d:%02d",
@@ -154,13 +169,12 @@ int wps_show(void)
154 // Display time with the filename scroll only because the screen has room. 169 // Display time with the filename scroll only because the screen has room.
155 if (global_settings.wps_display == PLAY_DISPLAY_FILENAME_SCROLL) 170 if (global_settings.wps_display == PLAY_DISPLAY_FILENAME_SCROLL)
156 { 171 {
157
158 snprintf(buffer,sizeof(buffer), "Time: %d:%02d / %d:%02d", 172 snprintf(buffer,sizeof(buffer), "Time: %d:%02d / %d:%02d",
159 id3->elapsed / 60000, 173 id3->elapsed / 60000,
160 id3->elapsed % 60000 / 1000, 174 id3->elapsed % 60000 / 1000,
161 id3->length / 60000, 175 id3->length / 60000,
162 id3->length % 60000 / 1000 ); 176 id3->length % 60000 / 1000 );
163 177
164 lcd_puts(0, 1, buffer); 178 lcd_puts(0, 1, buffer);
165 lcd_update(); 179 lcd_update();
166 } 180 }
@@ -289,6 +303,7 @@ int wps_show(void)
289 { 303 {
290 lcd_stop_scroll(); 304 lcd_stop_scroll();
291 main_menu(); 305 main_menu();
306 id3 = mpeg_current_track();
292 draw_screen(id3); 307 draw_screen(id3);
293 /* Prevent any stray BUTTON_REL events from going 308 /* Prevent any stray BUTTON_REL events from going
294 back to the main menu until we get a new 309 back to the main menu until we get a new