summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Braun <markus.braun@krawel.de>2002-10-11 08:56:23 +0000
committerMarkus Braun <markus.braun@krawel.de>2002-10-11 08:56:23 +0000
commit88098be7e3f175129a8f9aa78c82206afa063694 (patch)
tree38349fdd85b92bd486a23249a46ff7fee663f77b
parent8232306d8007326be0f547844dc01dbb0d65de35 (diff)
downloadrockbox-88098be7e3f175129a8f9aa78c82206afa063694.tar.gz
rockbox-88098be7e3f175129a8f9aa78c82206afa063694.zip
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
-rw-r--r--apps/screens.c71
-rw-r--r--apps/screens.h1
-rw-r--r--apps/tree.c1
-rw-r--r--apps/wps.c5
-rw-r--r--firmware/kernel.c19
-rw-r--r--firmware/kernel.h2
-rw-r--r--firmware/usb.c85
-rw-r--r--firmware/usb.h2
-rw-r--r--uisimulator/common/stubs.c3
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 @@
28#include "mpeg.h" 28#include "mpeg.h"
29#include "usb.h" 29#include "usb.h"
30#include "settings.h" 30#include "settings.h"
31#include "status.h"
31#include "playlist.h" 32#include "playlist.h"
32 33
34#ifdef HAVE_LCD_BITMAP
35#define BMPHEIGHT_usb_logo 32
36#define BMPWIDTH_usb_logo 100
37static unsigned char usb_logo[] = {
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08,
41 0x04, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
42 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x81, 0x81, 0x81,
43 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
44 0x01, 0x01, 0x01, 0x01, 0xf1, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
45 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0,
46 0x00, 0x00, 0xe0, 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
47 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
48 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x81, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0,
49 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x1c,
50 0x0c, 0x0e, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f,
51 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00,
52 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xf8, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
53 0x02, 0x02, 0x02, 0x82, 0x7e, 0x00, 0xc0, 0x3e, 0x01,
54 0x70, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
55 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
56 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00, 0x07, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f,
57 0x0f, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f,
58 0x1f, 0x3f, 0x7b, 0xf3, 0xe3, 0xc3, 0x83, 0x83, 0x83, 0x83, 0xe3, 0xe3, 0xe3,
59 0xe3, 0xe3, 0xe3, 0x03, 0x03, 0x03, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x02,
60 0xc0, 0x3e, 0x01, 0xe0, 0x9f, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
61 0x80, 0x80, 0xf0, 0x0f, 0x80, 0x78, 0x07, 0x00, 0x00,
62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x10, 0x20, 0x40, 0x40, 0x80, 0x80,
65 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
66 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x81, 0x87, 0x87, 0x87,
67 0x87, 0x87, 0x87, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0,
68 0x0f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
69 0x04, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00,
70};
71#endif
72
73void usb_display_info(void)
74{
75 lcd_stop_scroll();
76 lcd_clear_display();
77
78#ifdef HAVE_LCD_BITMAP
79 /* lcd_bitmap() only supports 16 pixels height! */
80 lcd_bitmap(usb_logo, 6, 16,
81 BMPWIDTH_usb_logo, 8, false);
82 lcd_bitmap(usb_logo+BMPWIDTH_usb_logo, 6, 24,
83 BMPWIDTH_usb_logo, 8, false);
84 lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*2, 6, 32,
85 BMPWIDTH_usb_logo, 8, false);
86 lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*3, 6, 40,
87 BMPWIDTH_usb_logo, 8, false);
88 status_draw();
89 lcd_update();
90#else
91 lcd_puts(0, 0, "[USB Mode]");
92 lcd_icon(ICON_PARAM, false);
93 lcd_icon(ICON_AUDIO, false);
94 lcd_icon(ICON_USB, true);
95#endif
96}
97
33void usb_screen(void) 98void usb_screen(void)
34{ 99{
35#ifndef SIMULATOR 100#ifndef SIMULATOR
36 backlight_on(); 101 backlight_on();
37 usb_acknowledge(SYS_USB_CONNECTED_ACK); 102 usb_acknowledge(SYS_USB_CONNECTED_ACK);
38 usb_wait_for_disconnect(&button_queue); 103 while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) {
104 if(usb_inserted()) {
105 usb_display_info();
106 }
107 }
39 backlight_on(); 108 backlight_on();
40#endif 109#endif
41} 110}
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 @@
19#ifndef _SCREENS_H_ 19#ifndef _SCREENS_H_
20#define _SCREENS_H_ 20#define _SCREENS_H_
21 21
22void usb_display_info(void);
22void usb_screen(void); 23void usb_screen(void);
23 24
24#ifdef HAVE_RECORDER_KEYPAD 25#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)
1047#endif 1047#endif
1048 1048
1049 case SYS_USB_CONNECTED: 1049 case SYS_USB_CONNECTED:
1050 status_set_playmode(STATUS_STOP);
1050 usb_screen(); 1051 usb_screen();
1051 reload_root = true; 1052 reload_root = true;
1052 break; 1053 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)
284 break; 284 break;
285 285
286 case SYS_USB_CONNECTED: 286 case SYS_USB_CONNECTED:
287 status_set_playmode(STATUS_STOP);
287 usb_screen(); 288 usb_screen();
288 return SYS_USB_CONNECTED; 289 return SYS_USB_CONNECTED;
289 break; 290 break;
@@ -397,6 +398,7 @@ static bool ffwd_rew(int button)
397 break; 398 break;
398 399
399 case SYS_USB_CONNECTED: 400 case SYS_USB_CONNECTED:
401 status_set_playmode(STATUS_STOP);
400 usb_screen(); 402 usb_screen();
401 usb = true; 403 usb = true;
402 exit = true; 404 exit = true;
@@ -482,6 +484,7 @@ static bool keylock(void)
482 break; 484 break;
483 485
484 case SYS_USB_CONNECTED: 486 case SYS_USB_CONNECTED:
487 status_set_playmode(STATUS_STOP);
485 usb_screen(); 488 usb_screen();
486 return true; 489 return true;
487 490
@@ -603,6 +606,7 @@ static bool menu(void)
603 break; 606 break;
604 607
605 case SYS_USB_CONNECTED: 608 case SYS_USB_CONNECTED:
609 status_set_playmode(STATUS_STOP);
606 usb_screen(); 610 usb_screen();
607 return true; 611 return true;
608 } 612 }
@@ -852,6 +856,7 @@ int wps_show(void)
852 return 0; 856 return 0;
853 857
854 case SYS_USB_CONNECTED: 858 case SYS_USB_CONNECTED:
859 status_set_playmode(STATUS_STOP);
855 usb_screen(); 860 usb_screen();
856 return SYS_USB_CONNECTED; 861 return SYS_USB_CONNECTED;
857 862
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)
102 *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK]; 102 *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
103} 103}
104 104
105void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks)
106{
107 unsigned int timeout = current_tick + ticks;
108
109 while(q->read == q->write && TIME_BEFORE( current_tick, timeout ))
110 {
111 switch_thread();
112 }
113
114 if(q->read != q->write)
115 {
116 *ev = q->events[(q->read++) & QUEUE_LENGTH_MASK];
117 }
118 else
119 {
120 ev->id = SYS_TIMEOUT;
121 }
122}
123
105void queue_post(struct event_queue *q, int id, void *data) 124void queue_post(struct event_queue *q, int id, void *data)
106{ 125{
107 int wr; 126 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 @@
37#define SYS_USB_CONNECTED_ACK -2 37#define SYS_USB_CONNECTED_ACK -2
38#define SYS_USB_DISCONNECTED -3 38#define SYS_USB_DISCONNECTED -3
39#define SYS_USB_DISCONNECTED_ACK -4 39#define SYS_USB_DISCONNECTED_ACK -4
40#define SYS_TIMEOUT -5
40 41
41struct event 42struct event
42{ 43{
@@ -69,6 +70,7 @@ int tick_remove_task(void (*f)(void));
69 70
70extern void queue_init(struct event_queue *q); 71extern void queue_init(struct event_queue *q);
71extern void queue_wait(struct event_queue *q, struct event *ev); 72extern void queue_wait(struct event_queue *q, struct event *ev);
73extern void queue_wait_w_tmo(struct event_queue *q, struct event *ev, int ticks);
72extern void queue_post(struct event_queue *q, int id, void *data); 74extern void queue_post(struct event_queue *q, int id, void *data);
73extern bool queue_empty(struct event_queue* q); 75extern bool queue_empty(struct event_queue* q);
74extern int queue_broadcast(int id, void *data); 76extern 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)
155#ifdef USB_REALLY_BRAVE 155#ifdef USB_REALLY_BRAVE
156 usb_slave_mode(true); 156 usb_slave_mode(true);
157 usb_state = USB_INSERTED; 157 usb_state = USB_INSERTED;
158 usb_display_info();
159#else 158#else
160 system_reboot(); 159 system_reboot();
161#endif 160#endif
@@ -292,6 +291,27 @@ void usb_wait_for_disconnect(struct event_queue *q)
292 } 291 }
293} 292}
294 293
294int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks)
295{
296 struct event ev;
297
298 /* Don't return until we get SYS_USB_DISCONNECTED or SYS_TIMEOUT */
299 while(1)
300 {
301 queue_wait_w_tmo(q, &ev, ticks);
302 switch(ev.id)
303 {
304 case SYS_USB_DISCONNECTED:
305 usb_acknowledge(SYS_USB_DISCONNECTED_ACK);
306 return 0;
307 break;
308 case SYS_TIMEOUT:
309 return 1;
310 break;
311 }
312 }
313}
314
295void usb_start_monitoring(void) 315void usb_start_monitoring(void)
296{ 316{
297 usb_monitor_enabled = true; 317 usb_monitor_enabled = true;
@@ -319,66 +339,3 @@ void usb_start_monitoring(void)
319} 339}
320 340
321#endif 341#endif
322
323#ifdef HAVE_LCD_BITMAP
324#define BMPHEIGHT_usb_logo 32
325#define BMPWIDTH_usb_logo 100
326static unsigned char usb_logo[] = {
327 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
328 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
329 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08,
330 0x04, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
331 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x81, 0x81, 0x81,
332 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
333 0x01, 0x01, 0x01, 0x01, 0xf1, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
334 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0,
335 0x00, 0x00, 0xe0, 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
336 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
337 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x81, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0,
338 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x1c,
339 0x0c, 0x0e, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f,
340 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00,
341 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xf8, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
342 0x02, 0x02, 0x02, 0x82, 0x7e, 0x00, 0xc0, 0x3e, 0x01,
343 0x70, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
344 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
345 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00, 0x07, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f,
346 0x0f, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f,
347 0x1f, 0x3f, 0x7b, 0xf3, 0xe3, 0xc3, 0x83, 0x83, 0x83, 0x83, 0xe3, 0xe3, 0xe3,
348 0xe3, 0xe3, 0xe3, 0x03, 0x03, 0x03, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x02,
349 0xc0, 0x3e, 0x01, 0xe0, 0x9f, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
350 0x80, 0x80, 0xf0, 0x0f, 0x80, 0x78, 0x07, 0x00, 0x00,
351 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
352 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
353 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x10, 0x20, 0x40, 0x40, 0x80, 0x80,
354 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
355 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x81, 0x87, 0x87, 0x87,
356 0x87, 0x87, 0x87, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0,
357 0x0f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
358 0x04, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00,
359};
360
361#endif
362void usb_display_info(void)
363{
364 lcd_stop_scroll();
365 lcd_clear_display();
366
367#ifdef HAVE_LCD_BITMAP
368 /* lcd_bitmap() only supports 16 pixels height! */
369 lcd_bitmap(usb_logo, 6, 16,
370 BMPWIDTH_usb_logo, 8, false);
371 lcd_bitmap(usb_logo+BMPWIDTH_usb_logo, 6, 24,
372 BMPWIDTH_usb_logo, 8, false);
373 lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*2, 6, 32,
374 BMPWIDTH_usb_logo, 8, false);
375 lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*3, 6, 40,
376 BMPWIDTH_usb_logo, 8, false);
377 lcd_update();
378#else
379 lcd_puts(0, 0, "[USB Mode]");
380 lcd_icon(ICON_PARAM, false);
381 lcd_icon(ICON_AUDIO, false);
382 lcd_icon(ICON_USB, true);
383#endif
384}
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);
25void usb_start_monitoring(void); 25void usb_start_monitoring(void);
26void usb_acknowledge(int id); 26void usb_acknowledge(int id);
27void usb_wait_for_disconnect(struct event_queue *q); 27void usb_wait_for_disconnect(struct event_queue *q);
28void usb_display_info(void); 28int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks);
29bool usb_inserted(void); 29bool usb_inserted(void);
30 30
31#endif 31#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 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19#include <stdio.h> 19#include <stdio.h>
20#include <stdbool.h>
20#include "debug.h" 21#include "debug.h"
21 22
22#include "usb.h" 23#include "screens.h"
23#include "button.h" 24#include "button.h"
24#include "menu.h" 25#include "menu.h"
25 26