Enable status bar in usb mode.

Moved usb_display_info() to screens.c
Added functions queue_wait_w_tmo() and usb_wait_for_disconnect_w_tmo().


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2574 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Markus Braun 2002-10-11 08:56:23 +00:00
parent 8232306d80
commit 88098be7e3
9 changed files with 122 additions and 67 deletions

View file

@ -28,14 +28,83 @@
#include "mpeg.h"
#include "usb.h"
#include "settings.h"
#include "status.h"
#include "playlist.h"
#ifdef HAVE_LCD_BITMAP
#define BMPHEIGHT_usb_logo 32
#define BMPWIDTH_usb_logo 100
static unsigned char usb_logo[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08,
0x04, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x81, 0x81, 0x81,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0xf1, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0,
0x00, 0x00, 0xe0, 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x81, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0,
0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x1c,
0x0c, 0x0e, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f,
0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x1f, 0x00, 0xf8, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x02, 0x02, 0x02, 0x82, 0x7e, 0x00, 0xc0, 0x3e, 0x01,
0x70, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00, 0x07, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f,
0x0f, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f,
0x1f, 0x3f, 0x7b, 0xf3, 0xe3, 0xc3, 0x83, 0x83, 0x83, 0x83, 0xe3, 0xe3, 0xe3,
0xe3, 0xe3, 0xe3, 0x03, 0x03, 0x03, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x02,
0xc0, 0x3e, 0x01, 0xe0, 0x9f, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0xf0, 0x0f, 0x80, 0x78, 0x07, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x10, 0x20, 0x40, 0x40, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x81, 0x87, 0x87, 0x87,
0x87, 0x87, 0x87, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0,
0x0f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00,
};
#endif
void usb_display_info(void)
{
lcd_stop_scroll();
lcd_clear_display();
#ifdef HAVE_LCD_BITMAP
/* lcd_bitmap() only supports 16 pixels height! */
lcd_bitmap(usb_logo, 6, 16,
BMPWIDTH_usb_logo, 8, false);
lcd_bitmap(usb_logo+BMPWIDTH_usb_logo, 6, 24,
BMPWIDTH_usb_logo, 8, false);
lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*2, 6, 32,
BMPWIDTH_usb_logo, 8, false);
lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*3, 6, 40,
BMPWIDTH_usb_logo, 8, false);
status_draw();
lcd_update();
#else
lcd_puts(0, 0, "[USB Mode]");
lcd_icon(ICON_PARAM, false);
lcd_icon(ICON_AUDIO, false);
lcd_icon(ICON_USB, true);
#endif
}
void usb_screen(void)
{
#ifndef SIMULATOR
backlight_on();
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_wait_for_disconnect(&button_queue);
while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) {
if(usb_inserted()) {
usb_display_info();
}
}
backlight_on();
#endif
}

View file

@ -19,6 +19,7 @@
#ifndef _SCREENS_H_
#define _SCREENS_H_
void usb_display_info(void);
void usb_screen(void);
#ifdef HAVE_RECORDER_KEYPAD

View file

@ -1047,6 +1047,7 @@ bool dirbrowse(char *root)
#endif
case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen();
reload_root = true;
break;

View file

@ -284,6 +284,7 @@ static int browse_id3(void)
break;
case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen();
return SYS_USB_CONNECTED;
break;
@ -397,6 +398,7 @@ static bool ffwd_rew(int button)
break;
case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen();
usb = true;
exit = true;
@ -482,6 +484,7 @@ static bool keylock(void)
break;
case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen();
return true;
@ -603,6 +606,7 @@ static bool menu(void)
break;
case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen();
return true;
}
@ -852,6 +856,7 @@ int wps_show(void)
return 0;
case SYS_USB_CONNECTED:
status_set_playmode(STATUS_STOP);
usb_screen();
return SYS_USB_CONNECTED;

View file

@ -102,6 +102,25 @@ void queue_wait(struct event_queue *q, struct event *ev)
*ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
}
void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks)
{
unsigned int timeout = current_tick + ticks;
while(q->read == q->write && TIME_BEFORE( current_tick, timeout ))
{
switch_thread();
}
if(q->read != q->write)
{
*ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
}
else
{
ev->id = SYS_TIMEOUT;
}
}
void queue_post(struct event_queue *q, int id, void *data)
{
int wr;

View file

@ -37,6 +37,7 @@
#define SYS_USB_CONNECTED_ACK -2
#define SYS_USB_DISCONNECTED -3
#define SYS_USB_DISCONNECTED_ACK -4
#define SYS_TIMEOUT -5
struct event
{
@ -69,6 +70,7 @@ int tick_remove_task(void (*f)(void));
extern void queue_init(struct event_queue *q);
extern void queue_wait(struct event_queue *q, struct event *ev);
extern void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks);
extern void queue_post(struct event_queue *q, int id, void *data);
extern bool queue_empty(struct event_queue* q);
extern int queue_broadcast(int id, void *data);

View file

@ -155,7 +155,6 @@ static void usb_thread(void)
#ifdef USB_REALLY_BRAVE
usb_slave_mode(true);
usb_state = USB_INSERTED;
usb_display_info();
#else
system_reboot();
#endif
@ -292,6 +291,27 @@ void usb_wait_for_disconnect(struct event_queue *q)
}
}
int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks)
{
struct event ev;
/* Don't return until we get SYS_USB_DISCONNECTED or SYS_TIMEOUT */
while(1)
{
queue_wait_w_tmo(q, &ev, ticks);
switch(ev.id)
{
case SYS_USB_DISCONNECTED:
usb_acknowledge(SYS_USB_DISCONNECTED_ACK);
return 0;
break;
case SYS_TIMEOUT:
return 1;
break;
}
}
}
void usb_start_monitoring(void)
{
usb_monitor_enabled = true;
@ -319,66 +339,3 @@ void usb_start_monitoring(void)
}
#endif
#ifdef HAVE_LCD_BITMAP
#define BMPHEIGHT_usb_logo 32
#define BMPWIDTH_usb_logo 100
static unsigned char usb_logo[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08,
0x04, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x81, 0x81, 0x81,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0xf1, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0,
0x00, 0x00, 0xe0, 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x81, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0,
0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x1c,
0x0c, 0x0e, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f,
0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x1f, 0x00, 0xf8, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x02, 0x02, 0x02, 0x82, 0x7e, 0x00, 0xc0, 0x3e, 0x01,
0x70, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00, 0x07, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f,
0x0f, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f,
0x1f, 0x3f, 0x7b, 0xf3, 0xe3, 0xc3, 0x83, 0x83, 0x83, 0x83, 0xe3, 0xe3, 0xe3,
0xe3, 0xe3, 0xe3, 0x03, 0x03, 0x03, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x02,
0xc0, 0x3e, 0x01, 0xe0, 0x9f, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0xf0, 0x0f, 0x80, 0x78, 0x07, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x10, 0x20, 0x40, 0x40, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x81, 0x87, 0x87, 0x87,
0x87, 0x87, 0x87, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0,
0x0f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00,
};
#endif
void usb_display_info(void)
{
lcd_stop_scroll();
lcd_clear_display();
#ifdef HAVE_LCD_BITMAP
/* lcd_bitmap() only supports 16 pixels height! */
lcd_bitmap(usb_logo, 6, 16,
BMPWIDTH_usb_logo, 8, false);
lcd_bitmap(usb_logo+BMPWIDTH_usb_logo, 6, 24,
BMPWIDTH_usb_logo, 8, false);
lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*2, 6, 32,
BMPWIDTH_usb_logo, 8, false);
lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*3, 6, 40,
BMPWIDTH_usb_logo, 8, false);
lcd_update();
#else
lcd_puts(0, 0, "[USB Mode]");
lcd_icon(ICON_PARAM, false);
lcd_icon(ICON_AUDIO, false);
lcd_icon(ICON_USB, true);
#endif
}

View file

@ -25,7 +25,7 @@ void usb_init(void);
void usb_start_monitoring(void);
void usb_acknowledge(int id);
void usb_wait_for_disconnect(struct event_queue *q);
void usb_display_info(void);
int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks);
bool usb_inserted(void);
#endif

View file

@ -17,9 +17,10 @@
*
****************************************************************************/
#include <stdio.h>
#include <stdbool.h>
#include "debug.h"
#include "usb.h"
#include "screens.h"
#include "button.h"
#include "menu.h"