summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/tree.c82
-rw-r--r--apps/wps.c51
-rw-r--r--apps/wps.h2
3 files changed, 82 insertions, 53 deletions
diff --git a/apps/tree.c b/apps/tree.c
index a1af9bc203..b43c1d725d 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -34,6 +34,7 @@
34#include "mpeg.h" 34#include "mpeg.h"
35#include "playlist.h" 35#include "playlist.h"
36#include "menu.h" 36#include "menu.h"
37#include "wps.h"
37 38
38#ifdef HAVE_LCD_BITMAP 39#ifdef HAVE_LCD_BITMAP
39#include "icons.h" 40#include "icons.h"
@@ -198,31 +199,31 @@ char* peek_next_track(int type)
198 return NULL; 199 return NULL;
199 200
200 switch(playing) { 201 switch(playing) {
201 default: 202 default:
202 case 1: 203 case 1:
203 /* play-full-dir mode */ 204 /* play-full-dir mode */
204 205
205 /* get next track in dir */ 206 /* get next track in dir */
206 while (dircursor + start + 1 < numentries ) { 207 while (dircursor + start + 1 < numentries ) {
207 if(dircursor+1 < TREE_MAX_ON_SCREEN) 208 if(dircursor+1 < TREE_MAX_ON_SCREEN)
208 dircursor++; 209 dircursor++;
209 else 210 else
210 start++; 211 start++;
211 if ( dircacheptr[dircursor+start]->file && 212 if ( dircacheptr[dircursor+start]->file &&
212 dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') { 213 dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
213 snprintf(buf,sizeof buf,"%s/%s", 214 snprintf(buf,sizeof buf,"%s/%s",
214 currdir, dircacheptr[dircursor+start]->name ); 215 currdir, dircacheptr[dircursor+start]->name );
215 lcd_clear_display(); 216 lcd_clear_display();
216 lcd_puts(0,0,"<Playing>"); 217 lcd_puts(0,0,"<Playing>");
217 lcd_puts(0,1,"<all files>"); 218 lcd_puts(0,1,"<all files>");
218 return buf; 219 return buf;
219 } 220 }
220 } 221 }
221 break; 222 break;
222 223
223 case 2: 224 case 2:
224 /* playlist mode */ 225 /* playlist mode */
225 return playlist_next(type); 226 return playlist_next(type);
226 } 227 }
227 228
228 return NULL; 229 return NULL;
@@ -246,6 +247,7 @@ bool dirbrowse(char *root)
246 lcd_update(); 247 lcd_update();
247 248
248 while(1) { 249 while(1) {
250 bool restore = false;
249 button = button_get(true); 251 button = button_get(true);
250 252
251 switch(button) { 253 switch(button) {
@@ -267,8 +269,7 @@ bool dirbrowse(char *root)
267 } 269 }
268 else 270 else
269 start = dircursor = 0; 271 start = dircursor = 0;
270 numentries = showdir(currdir, start); 272 restore = true;
271 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
272 } 273 }
273 else 274 else
274 mpeg_stop(); 275 mpeg_stop();
@@ -316,8 +317,7 @@ bool dirbrowse(char *root)
316 playing = 0; 317 playing = 0;
317 } 318 }
318 } 319 }
319 numentries = showdir(currdir, start); 320 restore = true;
320 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
321 break; 321 break;
322 322
323 case TREE_PREV: 323 case TREE_PREV:
@@ -354,20 +354,28 @@ bool dirbrowse(char *root)
354 case TREE_MENU: 354 case TREE_MENU:
355 lcd_stop_scroll(); 355 lcd_stop_scroll();
356 main_menu(); 356 main_menu();
357 restore = true;
358 break;
357 359
358 /* restore display */ 360 case BUTTON_ON:
359 /* TODO: this is just a copy from BUTTON_STOP, fix it */ 361 wps_show();
360 lcd_clear_display(); 362 restore = true;
361 numentries = showdir(currdir, start);
362 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
363
364 break; 363 break;
364
365 } 365 }
366 366
367 lcd_stop_scroll(); 367 if ( restore ) {
368 if ( numentries ) 368 /* restore display */
369 lcd_puts_scroll(LINE_X, LINE_Y+dircursor, 369 /* TODO: this is just a copy from BUTTON_STOP, fix it */
370 dircacheptr[start+dircursor]->name); 370 numentries = showdir(currdir, start);
371 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
372 }
373 else {
374 lcd_stop_scroll();
375 if ( numentries )
376 lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
377 dircacheptr[start+dircursor]->name);
378 }
371 379
372 lcd_update(); 380 lcd_update();
373 } 381 }
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
diff --git a/apps/wps.h b/apps/wps.h
index 2bc6fbf8dc..4963ffee4f 100644
--- a/apps/wps.h
+++ b/apps/wps.h
@@ -21,7 +21,7 @@
21#include "id3.h" 21#include "id3.h"
22#include "playlist.h" 22#include "playlist.h"
23 23
24void wps_show_play(char* filename); 24void wps_show(void);
25//void wps_show_playlist(char* current, playlist_info_t *list); 25//void wps_show_playlist(char* current, playlist_info_t *list);
26 26
27#endif 27#endif