summaryrefslogtreecommitdiff
path: root/apps/wps.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/wps.c')
-rw-r--r--apps/wps.c91
1 files changed, 65 insertions, 26 deletions
diff --git a/apps/wps.c b/apps/wps.c
index c3398e2ea4..db97a3c708 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -34,8 +34,16 @@
34#include "power.h" 34#include "power.h"
35#include "status.h" 35#include "status.h"
36#include "main_menu.h" 36#include "main_menu.h"
37#ifdef HAVE_LCD_BITMAP
38#include "icons.h"
39#include "widgets.h"
40#endif
37 41
38#define LINE_Y 1 /* initial line */ 42#ifdef HAVE_LCD_BITMAP
43#define LINE_Y (global_settings.statusbar&&statusbar_enabled?1:0) /* Y position the entry-list starts at */
44#else /* HAVE_LCD_BITMAP */
45#define LINE_Y 0 /* Y position the entry-list starts at */
46#endif /* HAVE_LCD_BITMAP */
39 47
40#define PLAY_DISPLAY_DEFAULT 0 48#define PLAY_DISPLAY_DEFAULT 0
41#define PLAY_DISPLAY_FILENAME_SCROLL 1 49#define PLAY_DISPLAY_FILENAME_SCROLL 1
@@ -47,6 +55,8 @@
47#define RELEASE_MASK (BUTTON_MENU | BUTTON_STOP) 55#define RELEASE_MASK (BUTTON_MENU | BUTTON_STOP)
48#endif 56#endif
49 57
58bool keys_locked = false;
59
50static void draw_screen(struct mp3entry* id3) 60static void draw_screen(struct mp3entry* id3)
51{ 61{
52 lcd_clear_display(); 62 lcd_clear_display();
@@ -83,14 +93,14 @@ static void draw_screen(struct mp3entry* id3)
83 strncpy(szArtist,szTok,sizeof(szArtist)); 93 strncpy(szArtist,szTok,sizeof(szArtist));
84 szArtist[sizeof(szArtist)-1] = 0; 94 szArtist[sizeof(szArtist)-1] = 0;
85 szDelimit = strrchr(id3->path, ch); 95 szDelimit = strrchr(id3->path, ch);
86 lcd_puts(0,0, szArtist?szArtist:"<nothing>"); 96 lcd_puts(0,LINE_Y, szArtist?szArtist:"<nothing>");
87 97
88 // removes the .mp3 from the end of the display buffer 98 // removes the .mp3 from the end of the display buffer
89 szPeriod = strrchr(szDelimit, '.'); 99 szPeriod = strrchr(szDelimit, '.');
90 if (szPeriod != NULL) 100 if (szPeriod != NULL)
91 *szPeriod = 0; 101 *szPeriod = 0;
92 102
93 lcd_puts_scroll(0,LINE_Y,(++szDelimit)); 103 lcd_puts_scroll(0,LINE_Y+1,(++szDelimit));
94 break; 104 break;
95 } 105 }
96 case PLAY_DISPLAY_FILENAME_SCROLL: 106 case PLAY_DISPLAY_FILENAME_SCROLL:
@@ -99,14 +109,14 @@ static void draw_screen(struct mp3entry* id3)
99 char* szLast = strrchr(id3->path, ch); 109 char* szLast = strrchr(id3->path, ch);
100 110
101 if (szLast) 111 if (szLast)
102 lcd_puts_scroll(0,0, (++szLast)); 112 lcd_puts_scroll(0,LINE_Y, (++szLast));
103 else 113 else
104 lcd_puts_scroll(0,0, id3->path); 114 lcd_puts_scroll(0,LINE_Y, id3->path);
105 break; 115 break;
106 } 116 }
107 case PLAY_DISPLAY_DEFAULT: 117 case PLAY_DISPLAY_DEFAULT:
108 { 118 {
109 int l = 0; 119 int l = LINE_Y;
110#ifdef HAVE_LCD_BITMAP 120#ifdef HAVE_LCD_BITMAP
111 char buffer[64]; 121 char buffer[64];
112 122
@@ -115,16 +125,28 @@ static void draw_screen(struct mp3entry* id3)
115 lcd_puts(0, l++, id3->album?id3->album:""); 125 lcd_puts(0, l++, id3->album?id3->album:"");
116 lcd_puts(0, l++, id3->artist?id3->artist:""); 126 lcd_puts(0, l++, id3->artist?id3->artist:"");
117 127
118 if(id3->vbr) 128 if(LINE_Y==0) {
119 snprintf(buffer, sizeof(buffer), "%d kbit (avg)", 129 if(id3->vbr)
120 id3->bitrate); 130 snprintf(buffer, sizeof(buffer), "%d kbit (avg)",
121 else 131 id3->bitrate);
122 snprintf(buffer, sizeof(buffer), "%d kbit", id3->bitrate); 132 else
133 snprintf(buffer, sizeof(buffer), "%d kbit", id3->bitrate);
134
135 lcd_puts(0, l++, buffer);
123 136
124 lcd_puts(0, l++, buffer); 137 snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency);
138 lcd_puts(0, l++, buffer);
139 }
140 else {
141 if(id3->vbr)
142 snprintf(buffer, sizeof(buffer), "%dkbit(a) %dHz",
143 id3->bitrate, id3->frequency);
144 else
145 snprintf(buffer, sizeof(buffer), "%dkbit %dHz",
146 id3->bitrate, id3->frequency);
125 147
126 snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency); 148 lcd_puts(0, l++, buffer);
127 lcd_puts(0, l++, buffer); 149 }
128#else 150#else
129 151
130 lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>"); 152 lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>");
@@ -166,7 +188,6 @@ void display_keylock_text(bool locked)
166int wps_show(void) 188int wps_show(void)
167{ 189{
168 struct mp3entry* id3 = NULL; 190 struct mp3entry* id3 = NULL;
169 bool keys_locked = false;
170 bool dont_go_to_menu = false; 191 bool dont_go_to_menu = false;
171 bool menu_button_is_down = false; 192 bool menu_button_is_down = false;
172 bool pending_keylock = true; /* Keylock will go ON next time */ 193 bool pending_keylock = true; /* Keylock will go ON next time */
@@ -364,9 +385,15 @@ int wps_show(void)
364#endif 385#endif
365 if(!keys_locked && !dont_go_to_menu && menu_button_is_down) 386 if(!keys_locked && !dont_go_to_menu && menu_button_is_down)
366 { 387 {
388#ifdef HAVE_LCD_BITMAP
389 bool laststate=statusbar(false);
390#endif
367 lcd_stop_scroll(); 391 lcd_stop_scroll();
368 button_set_release(old_release_mask); 392 button_set_release(old_release_mask);
369 main_menu(); 393 main_menu();
394#ifdef HAVE_LCD_BITMAP
395 statusbar(laststate);
396#endif
370 old_release_mask = button_set_release(RELEASE_MASK); 397 old_release_mask = button_set_release(RELEASE_MASK);
371 id3 = mpeg_current_track(); 398 id3 = mpeg_current_track();
372 draw_screen(id3); 399 draw_screen(id3);
@@ -379,6 +406,17 @@ int wps_show(void)
379 break; 406 break;
380 407
381#ifdef HAVE_RECORDER_KEYPAD 408#ifdef HAVE_RECORDER_KEYPAD
409 case BUTTON_F3:
410#ifdef HAVE_LCD_BITMAP
411 if(global_settings.statusbar) {
412 statusbar_toggle();
413 draw_screen(id3);
414 }
415#endif
416 break;
417#endif
418
419#ifdef HAVE_RECORDER_KEYPAD
382 case BUTTON_OFF: 420 case BUTTON_OFF:
383#else 421#else
384 case BUTTON_STOP: 422 case BUTTON_STOP:
@@ -396,7 +434,10 @@ int wps_show(void)
396 return 0; 434 return 0;
397 435
398#ifndef SIMULATOR 436#ifndef SIMULATOR
399 case SYS_USB_CONNECTED: 437 case SYS_USB_CONNECTED: {
438#ifdef HAVE_LCD_BITMAP
439 bool laststate=statusbar(false);
440#endif
400 /* Tell the USB thread that we are safe */ 441 /* Tell the USB thread that we are safe */
401 DEBUGF("wps got SYS_USB_CONNECTED\n"); 442 DEBUGF("wps got SYS_USB_CONNECTED\n");
402 usb_acknowledge(SYS_USB_CONNECTED_ACK); 443 usb_acknowledge(SYS_USB_CONNECTED_ACK);
@@ -404,16 +445,20 @@ int wps_show(void)
404 /* Wait until the USB cable is extracted again */ 445 /* Wait until the USB cable is extracted again */
405 usb_wait_for_disconnect(&button_queue); 446 usb_wait_for_disconnect(&button_queue);
406 447
448#ifdef HAVE_LCD_BITMAP
449 statusbar(laststate);
450#endif
407 /* Signal to our caller that we have been in USB mode */ 451 /* Signal to our caller that we have been in USB mode */
408 return SYS_USB_CONNECTED; 452 return SYS_USB_CONNECTED;
409 break; 453 break;
454 }
410#endif 455#endif
411 case BUTTON_NONE: /* Timeout */ 456 case BUTTON_NONE: /* Timeout */
412 if (mpeg_is_playing() && id3) 457 if (mpeg_is_playing() && id3)
413 { 458 {
414#ifdef HAVE_LCD_BITMAP 459#ifdef HAVE_LCD_BITMAP
415 snprintf(buffer,sizeof(buffer), 460 snprintf(buffer,sizeof(buffer),
416 "Time: %d:%02d / %d:%02d", 461 "Time:%3d:%02d/%d:%02d",
417 id3->elapsed / 60000, 462 id3->elapsed / 60000,
418 id3->elapsed % 60000 / 1000, 463 id3->elapsed % 60000 / 1000,
419 id3->length / 60000, 464 id3->length / 60000,
@@ -421,9 +466,9 @@ int wps_show(void)
421 466
422 lcd_puts(0, 6, buffer); 467 lcd_puts(0, 6, buffer);
423 468
424 lcd_slidebar(1, LCD_HEIGHT-7, LCD_WIDTH-2, 5, 469 slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6,
425 id3->elapsed*100/id3->length, 470 id3->elapsed*100/id3->length,
426 BAR_RIGHT); 471 Grow_Right);
427 472
428 lcd_update(); 473 lcd_update();
429#else 474#else
@@ -432,7 +477,7 @@ int wps_show(void)
432 if (global_settings.wps_display == 477 if (global_settings.wps_display ==
433 PLAY_DISPLAY_FILENAME_SCROLL) 478 PLAY_DISPLAY_FILENAME_SCROLL)
434 { 479 {
435 snprintf(buffer,sizeof(buffer), "%d:%02d/%d:%02d", 480 snprintf(buffer,sizeof(buffer), "Time:%3d:%02d/%d:%02d",
436 id3->elapsed / 60000, 481 id3->elapsed / 60000,
437 id3->elapsed % 60000 / 1000, 482 id3->elapsed % 60000 / 1000,
438 id3->length / 60000, 483 id3->length / 60000,
@@ -445,12 +490,6 @@ int wps_show(void)
445 } 490 }
446 491
447 status_draw(); 492 status_draw();
448#ifdef HAVE_LCD_BITMAP
449 /* draw battery indicator line */
450 lcd_clearline(0,LCD_HEIGHT-1,LCD_WIDTH-1, LCD_HEIGHT-1);
451 lcd_drawline(0,LCD_HEIGHT-1,battery_level() *
452 (LCD_WIDTH-1) / 100, LCD_HEIGHT-1);
453#endif
454 break; 493 break;
455 } 494 }
456 } 495 }