From 88098be7e3f175129a8f9aa78c82206afa063694 Mon Sep 17 00:00:00 2001 From: Markus Braun Date: Fri, 11 Oct 2002 08:56:23 +0000 Subject: 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 --- apps/screens.c | 71 +++++++++++++++++++++++++++++++++++++- apps/screens.h | 1 + apps/tree.c | 1 + apps/wps.c | 5 +++ firmware/kernel.c | 19 +++++++++++ firmware/kernel.h | 2 ++ firmware/usb.c | 85 ++++++++++++---------------------------------- firmware/usb.h | 2 +- uisimulator/common/stubs.c | 3 +- 9 files changed, 122 insertions(+), 67 deletions(-) diff --git a/apps/screens.c b/apps/screens.c index c990f6d445..6ec0695e24 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -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 } diff --git a/apps/screens.h b/apps/screens.h index 22eebb8053..27b156b895 100644 --- a/apps/screens.h +++ b/apps/screens.h @@ -19,6 +19,7 @@ #ifndef _SCREENS_H_ #define _SCREENS_H_ +void usb_display_info(void); void usb_screen(void); #ifdef HAVE_RECORDER_KEYPAD diff --git a/apps/tree.c b/apps/tree.c index f31811b9a5..5cd803adfe 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -1047,6 +1047,7 @@ bool dirbrowse(char *root) #endif case SYS_USB_CONNECTED: + status_set_playmode(STATUS_STOP); usb_screen(); reload_root = true; break; diff --git a/apps/wps.c b/apps/wps.c index e740216d96..82b62ca1b1 100644 --- a/apps/wps.c +++ b/apps/wps.c @@ -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; diff --git a/firmware/kernel.c b/firmware/kernel.c index 6da8a1b057..2b4b09f52b 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c @@ -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; diff --git a/firmware/kernel.h b/firmware/kernel.h index ef287e5689..0f69f43ec0 100644 --- a/firmware/kernel.h +++ b/firmware/kernel.h @@ -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); diff --git a/firmware/usb.c b/firmware/usb.c index 962e373a67..64474c7b66 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -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 -} diff --git a/firmware/usb.h b/firmware/usb.h index 455775c1d2..089b0f23e6 100644 --- a/firmware/usb.h +++ b/firmware/usb.h @@ -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 diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index c0fc6953e6..dee86b078f 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -17,9 +17,10 @@ * ****************************************************************************/ #include +#include #include "debug.h" -#include "usb.h" +#include "screens.h" #include "button.h" #include "menu.h" -- cgit v1.2.3