summaryrefslogtreecommitdiff
path: root/apps/wps.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/wps.c')
-rw-r--r--apps/wps.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/apps/wps.c b/apps/wps.c
index fb878d6aaf..bd23a28557 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -29,6 +29,7 @@
29#include "sprintf.h" 29#include "sprintf.h"
30#include "settings.h" 30#include "settings.h"
31#include "wps.h" 31#include "wps.h"
32#include "mpeg.h"
32 33
33 34
34#define LINE_Y 1 /* initial line */ 35#define LINE_Y 1 /* initial line */
@@ -38,11 +39,12 @@
38#define PLAY_DISPLAY_TRACK_TITLE 2 39#define PLAY_DISPLAY_TRACK_TITLE 2
39 40
40/* demonstrates showing different formats from playtune */ 41/* demonstrates showing different formats from playtune */
41void wps_show_play(char* filename) 42void wps_show(void)
42{ 43{
43 struct mp3entry mp3; 44 struct mp3entry* id3 = mpeg_current_track();
44 mp3info(&mp3,filename); 45 static bool playing = true;
45 46
47 lcd_clear_display();
46 switch ( global_settings.wps_display ) { 48 switch ( global_settings.wps_display ) {
47 case PLAY_DISPLAY_TRACK_TITLE: 49 case PLAY_DISPLAY_TRACK_TITLE:
48 { 50 {
@@ -54,7 +56,7 @@ void wps_show_play(char* filename)
54 char szBuff[257]; 56 char szBuff[257];
55 szBuff[sizeof(szBuff)-1] = 0; 57 szBuff[sizeof(szBuff)-1] = 0;
56 58
57 strncpy(szBuff, filename, sizeof(szBuff)); 59 strncpy(szBuff, id3->path, sizeof(szBuff));
58 60
59 szTok = strtok_r(szBuff, "/", &end); 61 szTok = strtok_r(szBuff, "/", &end);
60 szTok = strtok_r(NULL, "/", &end); 62 szTok = strtok_r(NULL, "/", &end);
@@ -62,7 +64,7 @@ void wps_show_play(char* filename)
62 // Assume path format of: Genre/Artist/Album/Mp3_file 64 // Assume path format of: Genre/Artist/Album/Mp3_file
63 strncpy(szArtist,szTok,sizeof(szArtist)); 65 strncpy(szArtist,szTok,sizeof(szArtist));
64 szArtist[sizeof(szArtist)-1] = 0; 66 szArtist[sizeof(szArtist)-1] = 0;
65 szDelimit = strrchr(filename, ch); 67 szDelimit = strrchr(id3->path, ch);
66 lcd_puts(0,0, szArtist?szArtist:"<nothing>"); 68 lcd_puts(0,0, szArtist?szArtist:"<nothing>");
67 lcd_puts_scroll(0,LINE_Y,(++szDelimit)); 69 lcd_puts_scroll(0,LINE_Y,(++szDelimit));
68 break; 70 break;
@@ -70,12 +72,12 @@ void wps_show_play(char* filename)
70 case PLAY_DISPLAY_FILENAME_SCROLL: 72 case PLAY_DISPLAY_FILENAME_SCROLL:
71 { 73 {
72 char ch = '/'; 74 char ch = '/';
73 char* szLast = strrchr(filename, ch); 75 char* szLast = strrchr(id3->path, ch);
74 76
75 if (szLast) 77 if (szLast)
76 lcd_puts_scroll(0,0, (++szLast)); 78 lcd_puts_scroll(0,0, (++szLast));
77 else 79 else
78 lcd_puts_scroll(0,0, mp3.path); 80 lcd_puts_scroll(0,0, id3->path);
79 81
80 break; 82 break;
81 } 83 }
@@ -85,27 +87,46 @@ void wps_show_play(char* filename)
85 char buffer[256]; 87 char buffer[256];
86 88
87 lcd_puts(0, 0, "[id3 info]"); 89 lcd_puts(0, 0, "[id3 info]");
88 lcd_puts(0, LINE_Y, mp3.title?mp3.title:""); 90 lcd_puts(0, LINE_Y, id3->title?id3->title:"");
89 lcd_puts(0, LINE_Y+1, mp3.album?mp3.album:""); 91 lcd_puts(0, LINE_Y+1, id3->album?id3->album:"");
90 lcd_puts(0, LINE_Y+2, mp3.artist?mp3.artist:""); 92 lcd_puts(0, LINE_Y+2, id3->artist?id3->artist:"");
91 93
92 snprintf(buffer,sizeof(buffer), "%d ms", mp3.length); 94 snprintf(buffer,sizeof(buffer), "%d ms", id3->length);
93 lcd_puts(0, LINE_Y+3, buffer); 95 lcd_puts(0, LINE_Y+3, buffer);
94 96
95 snprintf(buffer,sizeof(buffer), "%d kbits", mp3.bitrate); 97 snprintf(buffer,sizeof(buffer), "%d kbits", id3->bitrate);
96 98
97 lcd_puts(0, LINE_Y+4, buffer); 99 lcd_puts(0, LINE_Y+4, buffer);
98 100
99 snprintf(buffer,sizeof(buffer), "%d Hz", mp3.frequency); 101 snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency);
100 lcd_puts(0, LINE_Y+5, buffer); 102 lcd_puts(0, LINE_Y+5, buffer);
101#else 103#else
102 104
103 lcd_puts(0, 0, mp3.artist?mp3.artist:"<no artist>"); 105 lcd_puts(0, 0, id3->artist?id3->artist:"<no artist>");
104 lcd_puts(0, 1, mp3.title?mp3.title:"<no title>"); 106 lcd_puts(0, 1, id3->title?id3->title:"<no title>");
105#endif 107#endif
106 break; 108 break;
107 } 109 }
110 }
111 lcd_update();
112 while ( 1 ) {
113 switch ( button_get(true) ) {
114 case BUTTON_ON:
115 return;
108 116
117#ifdef HAVE_RECORDER_KEYPAD
118 case BUTTON_PLAY:
119#else
120 case BUTTON_UP:
121#endif
122 if ( playing )
123 mpeg_pause();
124 else
125 mpeg_resume();
126
127 playing = !playing;
128 break;
129 }
109 } 130 }
110} 131}
111 132