summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-06-25 13:26:04 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-06-25 13:26:04 +0000
commitbb9aaf50654bb32184d289b18f110cf9fd6687d1 (patch)
tree188943fa5d709086a89de94f1b3f98ed12979bea /apps
parent3f9c7c2ab5edef46346fed58807307ea4499b39c (diff)
downloadrockbox-bb9aaf50654bb32184d289b18f110cf9fd6687d1.zip
rockbox-bb9aaf50654bb32184d289b18f110cf9fd6687d1.tar.gz
rockbox-bb9aaf50654bb32184d289b18f110cf9fd6687d1.tar.bz2
rockbox-bb9aaf50654bb32184d289b18f110cf9fd6687d1.tar.xz
A step towards WPS
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1184 a1c6a512-1295-4272-9138-f99709370657
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 a1af9bc..b43c1d7 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -34,6 +34,7 @@
#include "mpeg.h"
#include "playlist.h"
#include "menu.h"
+#include "wps.h"
#ifdef HAVE_LCD_BITMAP
#include "icons.h"
@@ -198,31 +199,31 @@ char* peek_next_track(int type)
return NULL;
switch(playing) {
- default:
- case 1:
- /* play-full-dir mode */
+ default:
+ case 1:
+ /* play-full-dir mode */
- /* get next track in dir */
- while (dircursor + start + 1 < numentries ) {
- if(dircursor+1 < TREE_MAX_ON_SCREEN)
- dircursor++;
- else
- start++;
- if ( dircacheptr[dircursor+start]->file &&
- dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
- snprintf(buf,sizeof buf,"%s/%s",
- currdir, dircacheptr[dircursor+start]->name );
- lcd_clear_display();
- lcd_puts(0,0,"<Playing>");
- lcd_puts(0,1,"<all files>");
- return buf;
- }
- }
- break;
+ /* get next track in dir */
+ while (dircursor + start + 1 < numentries ) {
+ if(dircursor+1 < TREE_MAX_ON_SCREEN)
+ dircursor++;
+ else
+ start++;
+ if ( dircacheptr[dircursor+start]->file &&
+ dircacheptr[dircursor+start]->name[strlen(dircacheptr[dircursor+start]->name)-1] == '3') {
+ snprintf(buf,sizeof buf,"%s/%s",
+ currdir, dircacheptr[dircursor+start]->name );
+ lcd_clear_display();
+ lcd_puts(0,0,"<Playing>");
+ lcd_puts(0,1,"<all files>");
+ return buf;
+ }
+ }
+ break;
- case 2:
- /* playlist mode */
- return playlist_next(type);
+ case 2:
+ /* playlist mode */
+ return playlist_next(type);
}
return NULL;
@@ -246,6 +247,7 @@ bool dirbrowse(char *root)
lcd_update();
while(1) {
+ bool restore = false;
button = button_get(true);
switch(button) {
@@ -267,8 +269,7 @@ bool dirbrowse(char *root)
}
else
start = dircursor = 0;
- numentries = showdir(currdir, start);
- put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
+ restore = true;
}
else
mpeg_stop();
@@ -316,8 +317,7 @@ bool dirbrowse(char *root)
playing = 0;
}
}
- numentries = showdir(currdir, start);
- put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
+ restore = true;
break;
case TREE_PREV:
@@ -354,20 +354,28 @@ bool dirbrowse(char *root)
case TREE_MENU:
lcd_stop_scroll();
main_menu();
+ restore = true;
+ break;
- /* restore display */
- /* TODO: this is just a copy from BUTTON_STOP, fix it */
- lcd_clear_display();
- numentries = showdir(currdir, start);
- put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
-
+ case BUTTON_ON:
+ wps_show();
+ restore = true;
break;
+
}
- lcd_stop_scroll();
- if ( numentries )
- lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
- dircacheptr[start+dircursor]->name);
+ if ( restore ) {
+ /* restore display */
+ /* TODO: this is just a copy from BUTTON_STOP, fix it */
+ numentries = showdir(currdir, start);
+ put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
+ }
+ else {
+ lcd_stop_scroll();
+ if ( numentries )
+ lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
+ dircacheptr[start+dircursor]->name);
+ }
lcd_update();
}
diff --git a/apps/wps.c b/apps/wps.c
index fb878d6..bd23a28 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -29,6 +29,7 @@
#include "sprintf.h"
#include "settings.h"
#include "wps.h"
+#include "mpeg.h"
#define LINE_Y 1 /* initial line */
@@ -38,11 +39,12 @@
#define PLAY_DISPLAY_TRACK_TITLE 2
/* demonstrates showing different formats from playtune */
-void wps_show_play(char* filename)
+void wps_show(void)
{
- struct mp3entry mp3;
- mp3info(&mp3,filename);
+ struct mp3entry* id3 = mpeg_current_track();
+ static bool playing = true;
+ lcd_clear_display();
switch ( global_settings.wps_display ) {
case PLAY_DISPLAY_TRACK_TITLE:
{
@@ -54,7 +56,7 @@ void wps_show_play(char* filename)
char szBuff[257];
szBuff[sizeof(szBuff)-1] = 0;
- strncpy(szBuff, filename, sizeof(szBuff));
+ strncpy(szBuff, id3->path, sizeof(szBuff));
szTok = strtok_r(szBuff, "/", &end);
szTok = strtok_r(NULL, "/", &end);
@@ -62,7 +64,7 @@ void wps_show_play(char* filename)
// Assume path format of: Genre/Artist/Album/Mp3_file
strncpy(szArtist,szTok,sizeof(szArtist));
szArtist[sizeof(szArtist)-1] = 0;
- szDelimit = strrchr(filename, ch);
+ szDelimit = strrchr(id3->path, ch);
lcd_puts(0,0, szArtist?szArtist:"<nothing>");
lcd_puts_scroll(0,LINE_Y,(++szDelimit));
break;
@@ -70,12 +72,12 @@ void wps_show_play(char* filename)
case PLAY_DISPLAY_FILENAME_SCROLL:
{
char ch = '/';
- char* szLast = strrchr(filename, ch);
+ char* szLast = strrchr(id3->path, ch);
if (szLast)
lcd_puts_scroll(0,0, (++szLast));
else
- lcd_puts_scroll(0,0, mp3.path);
+ lcd_puts_scroll(0,0, id3->path);
break;
}
@@ -85,27 +87,46 @@ void wps_show_play(char* filename)
char buffer[256];
lcd_puts(0, 0, "[id3 info]");
- lcd_puts(0, LINE_Y, mp3.title?mp3.title:"");
- lcd_puts(0, LINE_Y+1, mp3.album?mp3.album:"");
- lcd_puts(0, LINE_Y+2, mp3.artist?mp3.artist:"");
+ lcd_puts(0, LINE_Y, id3->title?id3->title:"");
+ lcd_puts(0, LINE_Y+1, id3->album?id3->album:"");
+ lcd_puts(0, LINE_Y+2, id3->artist?id3->artist:"");
- snprintf(buffer,sizeof(buffer), "%d ms", mp3.length);
+ snprintf(buffer,sizeof(buffer), "%d ms", id3->length);
lcd_puts(0, LINE_Y+3, buffer);
- snprintf(buffer,sizeof(buffer), "%d kbits", mp3.bitrate);
+ snprintf(buffer,sizeof(buffer), "%d kbits", id3->bitrate);
lcd_puts(0, LINE_Y+4, buffer);
- snprintf(buffer,sizeof(buffer), "%d Hz", mp3.frequency);
+ snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency);
lcd_puts(0, LINE_Y+5, buffer);
#else
- lcd_puts(0, 0, mp3.artist?mp3.artist:"<no artist>");
- lcd_puts(0, 1, mp3.title?mp3.title:"<no title>");
+ lcd_puts(0, 0, id3->artist?id3->artist:"<no artist>");
+ lcd_puts(0, 1, id3->title?id3->title:"<no title>");
#endif
break;
}
+ }
+ lcd_update();
+ while ( 1 ) {
+ switch ( button_get(true) ) {
+ case BUTTON_ON:
+ return;
+#ifdef HAVE_RECORDER_KEYPAD
+ case BUTTON_PLAY:
+#else
+ case BUTTON_UP:
+#endif
+ if ( playing )
+ mpeg_pause();
+ else
+ mpeg_resume();
+
+ playing = !playing;
+ break;
+ }
}
}
diff --git a/apps/wps.h b/apps/wps.h
index 2bc6fbf..4963ffe 100644
--- a/apps/wps.h
+++ b/apps/wps.h
@@ -21,7 +21,7 @@
#include "id3.h"
#include "playlist.h"
-void wps_show_play(char* filename);
+void wps_show(void);
//void wps_show_playlist(char* current, playlist_info_t *list);
#endif