summaryrefslogtreecommitdiff
path: root/apps/wps.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/wps.c')
-rw-r--r--apps/wps.c131
1 files changed, 123 insertions, 8 deletions
diff --git a/apps/wps.c b/apps/wps.c
index 7e3e626297..dc588a56da 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -53,6 +53,7 @@
53 #define PLAY_DISPLAY_2LINEID3 1 53 #define PLAY_DISPLAY_2LINEID3 1
54 #define PLAY_DISPLAY_FILENAME_SCROLL 2 54 #define PLAY_DISPLAY_FILENAME_SCROLL 2
55 #define PLAY_DISPLAY_TRACK_TITLE 3 55 #define PLAY_DISPLAY_TRACK_TITLE 3
56 #define PLAY_DISPLAY_CUSTOM_WPS 4
56#endif 57#endif
57 58
58#ifdef HAVE_RECORDER_KEYPAD 59#ifdef HAVE_RECORDER_KEYPAD
@@ -189,23 +190,21 @@ static void draw_screen(struct mp3entry* id3)
189 char* szLast = strrchr(id3->path, ch); 190 char* szLast = strrchr(id3->path, ch);
190 191
191 if(id3->artist && id3->title) 192 if(id3->artist && id3->title)
192 {
193 snprintf(buffer, sizeof(buffer), "%d/%d: %s - %s", 193 snprintf(buffer, sizeof(buffer), "%d/%d: %s - %s",
194 id3->index + 1, 194 id3->index + 1, playlist.amount,
195 playlist.amount,
196 id3->artist?id3->artist:"<no artist>", 195 id3->artist?id3->artist:"<no artist>",
197 id3->title?id3->title:"<no title>"); 196 id3->title?id3->title:"<no title>");
198 }
199 else 197 else
200 {
201 snprintf(buffer, sizeof(buffer), "%d/%d: %s", 198 snprintf(buffer, sizeof(buffer), "%d/%d: %s",
202 id3->index + 1, 199 id3->index + 1, playlist.amount,
203 playlist.amount,
204 szLast?++szLast:id3->path); 200 szLast?++szLast:id3->path);
205 }
206 lcd_puts_scroll(0, 0, buffer); 201 lcd_puts_scroll(0, 0, buffer);
207 break; 202 break;
208 } 203 }
204 case PLAY_DISPLAY_CUSTOM_WPS:
205 {
206 wps_load_custom_config();
207 }
209#endif 208#endif
210 } 209 }
211 } 210 }
@@ -213,6 +212,121 @@ static void draw_screen(struct mp3entry* id3)
213 lcd_update(); 212 lcd_update();
214} 213}
215 214
215int wps_load_custom_config(void)
216{
217 char buffer[128];
218 char tmpbuf[64];
219 char cchr1[0] = "";
220 char cchr2[0] = "";
221 int i;
222 int fd;
223 struct mp3entry* id3 = NULL;
224
225 id3 = mpeg_current_track();
226 char ch = '/';
227 char* szLast = strrchr(id3->path, ch);
228
229 snprintf(buffer, sizeof(buffer), "");
230 lcd_stop_scroll();
231 fd = open("/wps.config", O_RDONLY);
232 if(-1 == fd)
233 {
234 lcd_puts(0, 0, " *Error* ");
235 sleep(HZ);
236 lcd_puts_scroll(0, 1, "--Couldn't Load wps.config--");
237 sleep(HZ*5);
238 global_settings.wps_display = 0;
239 settings_save();
240 draw_screen(id3);
241 return(-1);
242 }
243 while(1)
244 {
245 i = read(fd, cchr1, 1);
246 if(i <= 0)
247 {
248 close(fd);
249 lcd_puts_scroll(0, 0, buffer);
250 return(1);
251 }
252 switch(cchr1[0])
253 {
254 case '%':
255 i = read(fd, cchr2, 1);
256 if(i <= 0)
257 {
258 close(fd);
259 lcd_puts_scroll(0, 0, buffer);
260 return(1);
261 }
262 switch(cchr2[0])
263 {
264 case 't': /* ID3 Title */
265 snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->title);
266 break;
267 case 'a': /* ID3 Artist */
268 snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->artist);
269 break;
270 case 'n': /* ID3 Track Number */
271 snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->tracknum);
272 break;
273 case 'u': /* ID3 Album */
274 snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->album);
275 break;
276 case 'c': /* Conditional Filename \ ID3 Artist-Title */
277 if(id3->artist && id3->title)
278 snprintf(tmpbuf, sizeof(tmpbuf), "%s - %s",
279 id3->artist?id3->artist:"<no artist>",
280 id3->title?id3->title:"<no title>");
281 else
282 snprintf(tmpbuf, sizeof(tmpbuf), "%s",
283 szLast?++szLast:id3->path);
284 break;
285 case 'b': /* File Bitrate */
286 snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->bitrate);
287 break;
288 case 'f': /* File Frequency */
289 snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->frequency);
290 break;
291 case 'p': /* File Path */
292 snprintf(tmpbuf, sizeof(tmpbuf), "%s", id3->path);
293 break;
294 case 'm': /* File Name */
295 snprintf(tmpbuf, sizeof(tmpbuf), "%s",
296 szLast?++szLast:id3->path);
297 break;
298 case 's': /* File Size (In Kilobytes) */
299 snprintf(tmpbuf, sizeof(tmpbuf), "%d",
300 id3->filesize / 1024);
301 break;
302 case 'i': /* Playlist Position */
303 snprintf(tmpbuf, sizeof(tmpbuf), "%d", id3->index + 1);
304 break;
305 case 'l': /* Playlist Total Entries */
306 snprintf(tmpbuf, sizeof(tmpbuf), "%d", playlist.amount);
307 break;
308 case 'e': /* Elapsed Time */
309 snprintf(tmpbuf, sizeof(tmpbuf), "%d:%02d",
310 id3->elapsed / 60000,
311 id3->elapsed % 60000 / 1000);
312 break;
313 case 'o': /* Total Time */
314 snprintf(tmpbuf, sizeof(tmpbuf), "%d:%02d",
315 id3->elapsed / 60000,
316 id3->elapsed % 60000 / 1000);
317 break;
318
319 }
320 break;
321 default:
322 snprintf(tmpbuf, sizeof(tmpbuf), "%s", cchr1);
323 break;
324 }
325 snprintf(buffer, sizeof(buffer), "%s%s", buffer, tmpbuf);
326 }
327}
328
329
216int player_id3_show(void) 330int player_id3_show(void)
217{ 331{
218#ifdef HAVE_PLAYER_KEYPAD 332#ifdef HAVE_PLAYER_KEYPAD
@@ -358,6 +472,7 @@ static void display_file_time(unsigned int elapsed, unsigned int length)
358 the screen has room. */ 472 the screen has room. */
359 if ((global_settings.wps_display == PLAY_DISPLAY_FILENAME_SCROLL) || 473 if ((global_settings.wps_display == PLAY_DISPLAY_FILENAME_SCROLL) ||
360 global_settings.wps_display == PLAY_DISPLAY_1LINEID3 || 474 global_settings.wps_display == PLAY_DISPLAY_1LINEID3 ||
475 global_settings.wps_display == PLAY_DISPLAY_CUSTOM_WPS ||
361 ff_rewind) 476 ff_rewind)
362 { 477 {
363 snprintf(buffer,sizeof(buffer), "%d:%02d/%d:%02d ", 478 snprintf(buffer,sizeof(buffer), "%d:%02d/%d:%02d ",