WPS screen now handles USB detection

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1282 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2002-07-01 11:06:23 +00:00
parent 53b8c99521
commit c4c52f8209
3 changed files with 48 additions and 20 deletions

View file

@ -256,6 +256,7 @@ bool dirbrowse(char *root)
char buf[255]; char buf[255];
int i; int i;
int button; int button;
int rc;
memcpy(currdir,root,sizeof(currdir)); memcpy(currdir,root,sizeof(currdir));
numentries = showdir(root, start); numentries = showdir(root, start);
@ -341,7 +342,13 @@ bool dirbrowse(char *root)
mpeg_play(buf); mpeg_play(buf);
} }
lcd_stop_scroll(); lcd_stop_scroll();
wps_show(); rc = wps_show();
if(rc == SYS_USB_CONNECTED)
{
/* Force a re-read of the root directory */
strcpy(currdir, "/");
lastdir[0] = 0;
}
} }
restore = true; restore = true;
break; break;
@ -391,27 +398,31 @@ bool dirbrowse(char *root)
case BUTTON_ON: case BUTTON_ON:
if ( play_mode ) { if ( play_mode ) {
lcd_stop_scroll(); lcd_stop_scroll();
wps_show(); rc = wps_show();
if(rc == SYS_USB_CONNECTED)
{
/* Force a re-read of the root directory */
strcpy(currdir, "/");
lastdir[0] = 0;
}
restore = true; restore = true;
} }
break; break;
#ifndef SIMULATOR #ifndef SIMULATOR
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
/* Tell the USB thread that we are safe */ /* Tell the USB thread that we are safe */
DEBUGF("dirbrowse got SYS_USB_CONNECTED\n"); DEBUGF("dirbrowse got SYS_USB_CONNECTED\n");
usb_acknowledge(SYS_USB_CONNECTED_ACK); usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_display_info(); /* Wait until the USB cable is extracted again */
usb_wait_for_disconnect(&button_queue);
/* Wait until the USB cable is extracted again */
usb_wait_for_disconnect(&button_queue); /* Force a re-read of the root directory */
restore = true;
/* Force a re-read of the root directory */ strcpy(currdir, "/");
restore = 1; lastdir[0] = 0;
strcpy(currdir, "/"); break;
lastdir[0] = 0;
break;
#endif #endif
} }

View file

@ -30,6 +30,7 @@
#include "settings.h" #include "settings.h"
#include "wps.h" #include "wps.h"
#include "mpeg.h" #include "mpeg.h"
#include "usb.h"
#define LINE_Y 1 /* initial line */ #define LINE_Y 1 /* initial line */
@ -112,7 +113,7 @@ static void draw_screen(struct mp3entry* id3)
} }
/* demonstrates showing different formats from playtune */ /* demonstrates showing different formats from playtune */
void wps_show(void) int wps_show(void)
{ {
static bool playing = true; static bool playing = true;
struct mp3entry* id3 = mpeg_current_track(); struct mp3entry* id3 = mpeg_current_track();
@ -159,7 +160,7 @@ void wps_show(void)
for ( i=0;i<5;i++ ) { for ( i=0;i<5;i++ ) {
switch ( button_get(false) ) { switch ( button_get(false) ) {
case BUTTON_ON: case BUTTON_ON:
return; return 0;
#ifdef HAVE_RECORDER_KEYPAD #ifdef HAVE_RECORDER_KEYPAD
case BUTTON_PLAY: case BUTTON_PLAY:
@ -205,6 +206,22 @@ void wps_show(void)
#endif #endif
mpeg_stop(); mpeg_stop();
break; break;
#ifndef SIMULATOR
case SYS_USB_CONNECTED:
/* Tell the USB thread that we are safe */
DEBUGF("dirbrowse got SYS_USB_CONNECTED\n");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_display_info();
/* Wait until the USB cable is extracted again */
usb_wait_for_disconnect(&button_queue);
/* Signal to our caller that we have been in USB mode */
return SYS_USB_CONNECTED;
break;
#endif
} }
sleep(HZ/10); sleep(HZ/10);
} }

View file

@ -21,6 +21,6 @@
#include "id3.h" #include "id3.h"
#include "playlist.h" #include "playlist.h"
void wps_show(void); int wps_show(void);
#endif #endif