summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/Makefile2
-rw-r--r--apps/main.c13
-rw-r--r--apps/menu.c40
-rw-r--r--apps/tree.c44
-rw-r--r--apps/wps.c47
5 files changed, 109 insertions, 37 deletions
diff --git a/apps/Makefile b/apps/Makefile
index 3629813595..0347c03507 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -25,7 +25,7 @@ TARGET = -DARCHOS_PLAYER_OLD=1
25# store output files in this directory: 25# store output files in this directory:
26OBJDIR = . 26OBJDIR = .
27 27
28CFLAGS = -O -W -Wall -m1 -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) $(TARGET) $(DEFINES) -DAPPSVERSION=\"$(VERSION)\" 28CFLAGS = -O -W -Wall -m1 -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) $(TARGET) $(DEFINES) -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES)
29AFLAGS += -small -relax 29AFLAGS += -small -relax
30 30
31ifdef DEBUG 31ifdef DEBUG
diff --git a/apps/main.c b/apps/main.c
index 895f79af3b..887c85b64e 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -44,10 +44,11 @@
44#include "backlight.h" 44#include "backlight.h"
45#include "status.h" 45#include "status.h"
46#include "debug_menu.h" 46#include "debug_menu.h"
47
48#include "version.h" 47#include "version.h"
49
50#include "sprintf.h" 48#include "sprintf.h"
49#ifdef LOADABLE_FONTS
50#include "unicode.h"
51#endif
51 52
52char appsversion[]=APPSVERSION; 53char appsversion[]=APPSVERSION;
53 54
@@ -64,6 +65,9 @@ void app_main(void)
64void init(void) 65void init(void)
65{ 66{
66 init_threads(); 67 init_threads();
68#ifdef LOADABLE_FONTS
69 unicode_init();
70#endif
67 lcd_init(); 71 lcd_init();
68 show_logo(); 72 show_logo();
69 settings_reset(); 73 settings_reset();
@@ -153,8 +157,11 @@ void init(void)
153 157
154 status_init(); 158 status_init();
155 usb_start_monitoring(); 159 usb_start_monitoring();
156
157 power_init(); 160 power_init();
161#ifdef LOADABLE_FONTS
162 unicode_init();
163 lcd_init_fonts();
164#endif
158} 165}
159 166
160int main(void) 167int main(void)
diff --git a/apps/menu.c b/apps/menu.c
index c8a5d0e73d..7267afe193 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -22,11 +22,14 @@
22#include "button.h" 22#include "button.h"
23#include "kernel.h" 23#include "kernel.h"
24#include "debug.h" 24#include "debug.h"
25#include "panic.h"
25 26
26#ifdef HAVE_LCD_BITMAP 27#ifdef HAVE_LCD_BITMAP
27#include "icons.h" 28#include "icons.h"
28#endif 29#endif
29 30#ifdef LOADABLE_FONTS
31#include "ajf.h"
32#endif
30struct menu { 33struct menu {
31 int top; 34 int top;
32 int cursor; 35 int cursor;
@@ -54,11 +57,19 @@ static bool inuse[MAX_MENUS] = { false };
54/* count in letter posistions, NOT pixels */ 57/* count in letter posistions, NOT pixels */
55void put_cursorxy(int x, int y, bool on) 58void put_cursorxy(int x, int y, bool on)
56{ 59{
60#ifdef LOADABLE_FONTS
61 int fh;
62 unsigned char* font = lcd_getcurrentldfont();
63 fh = ajf_get_fontheight(font);
64#else
65 int fh = 8;
66#endif
67
57 /* place the cursor */ 68 /* place the cursor */
58 if(on) { 69 if(on) {
59#ifdef HAVE_LCD_BITMAP 70#ifdef HAVE_LCD_BITMAP
60 lcd_bitmap ( bitmap_icons_6x8[Cursor], 71 lcd_bitmap ( bitmap_icons_6x8[Cursor],
61 x*6, y*8, 4, 8, true); 72 x*6, y*fh, 4, 8, true);
62#elif defined(SIMULATOR) 73#elif defined(SIMULATOR)
63 /* player simulator */ 74 /* player simulator */
64 unsigned char cursor[] = { 0x7f, 0x3e, 0x1c, 0x08 }; 75 unsigned char cursor[] = { 0x7f, 0x3e, 0x1c, 0x08 };
@@ -70,7 +81,7 @@ void put_cursorxy(int x, int y, bool on)
70 else { 81 else {
71#if defined(HAVE_LCD_BITMAP) 82#if defined(HAVE_LCD_BITMAP)
72 /* I use xy here since it needs to disregard the margins */ 83 /* I use xy here since it needs to disregard the margins */
73 lcd_clearrect (x*6, y*8, 4, 8); 84 lcd_clearrect (x*6, y*fh, 4, 8);
74#elif defined(SIMULATOR) 85#elif defined(SIMULATOR)
75 /* player simulator in action */ 86 /* player simulator in action */
76 lcd_clearrect (x*6, 12+y*16, 4, 8); 87 lcd_clearrect (x*6, 12+y*16, 4, 8);
@@ -83,6 +94,15 @@ void put_cursorxy(int x, int y, bool on)
83static void menu_draw(int m) 94static void menu_draw(int m)
84{ 95{
85 int i = 0; 96 int i = 0;
97#ifdef LOADABLE_FONTS
98 int menu_lines;
99 int fh;
100 unsigned char* font = lcd_getcurrentldfont();
101 fh = ajf_get_fontheight(font);
102 menu_lines = LCD_HEIGHT/fh;
103#else
104 int menu_lines = MENU_LINES;
105#endif
86 106
87 lcd_clear_display(); 107 lcd_clear_display();
88 lcd_stop_scroll(); 108 lcd_stop_scroll();
@@ -91,7 +111,7 @@ static void menu_draw(int m)
91 lcd_setfont(0); 111 lcd_setfont(0);
92#endif 112#endif
93 for (i = menus[m].top; 113 for (i = menus[m].top;
94 (i < menus[m].itemcount) && (i<menus[m].top+MENU_LINES); 114 (i < menus[m].itemcount) && (i<menus[m].top+menu_lines);
95 i++) { 115 i++) {
96 if((menus[m].cursor - menus[m].top)==(i-menus[m].top)) 116 if((menus[m].cursor - menus[m].top)==(i-menus[m].top))
97 lcd_puts_scroll(1, i-menus[m].top, menus[m].items[i].desc); 117 lcd_puts_scroll(1, i-menus[m].top, menus[m].items[i].desc);
@@ -111,7 +131,15 @@ static void menu_draw(int m)
111static void put_cursor(int m, int target) 131static void put_cursor(int m, int target)
112{ 132{
113 bool do_update = true; 133 bool do_update = true;
114 134#ifdef LOADABLE_FONTS
135 int menu_lines;
136 int fh;
137 unsigned char* font = lcd_getcurrentldfont();
138 fh = ajf_get_fontheight(font);
139 menu_lines = LCD_HEIGHT/fh;
140#else
141 int menu_lines = MENU_LINES;
142#endif
115 put_cursorxy(0, menus[m].cursor - menus[m].top, false); 143 put_cursorxy(0, menus[m].cursor - menus[m].top, false);
116 menus[m].cursor = target; 144 menus[m].cursor = target;
117 menu_draw(m); 145 menu_draw(m);
@@ -121,7 +149,7 @@ static void put_cursor(int m, int target)
121 menu_draw(m); 149 menu_draw(m);
122 do_update = false; 150 do_update = false;
123 } 151 }
124 else if ( target-menus[m].top > MENU_LINES-1 ) { 152 else if ( target-menus[m].top > menu_lines-1 ) {
125 menus[m].top++; 153 menus[m].top++;
126 menu_draw(m); 154 menu_draw(m);
127 do_update = false; 155 do_update = false;
diff --git a/apps/tree.c b/apps/tree.c
index cbb19fc2bd..80af6e01d6 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -43,6 +43,10 @@
43#include "icons.h" 43#include "icons.h"
44#endif 44#endif
45 45
46#ifdef LOADABLE_FONTS
47#include "ajf.h"
48#endif
49
46#define MAX_FILES_IN_DIR 200 50#define MAX_FILES_IN_DIR 200
47#define TREE_MAX_FILENAMELEN MAX_PATH 51#define TREE_MAX_FILENAMELEN MAX_PATH
48#define MAX_DIR_LEVELS 10 52#define MAX_DIR_LEVELS 10
@@ -152,8 +156,20 @@ static int showdir(char *path, int start)
152{ 156{
153#ifdef HAVE_LCD_BITMAP 157#ifdef HAVE_LCD_BITMAP
154 int icon_type = 0; 158 int icon_type = 0;
159 int line_height = LINE_HEIGTH;
155#endif 160#endif
156 int i; 161 int i;
162 int tree_max_on_screen;
163#ifdef LOADABLE_FONTS
164 int fh;
165 unsigned char *font = lcd_getcurrentldfont();
166 fh = ajf_get_fontheight(font);
167 tree_max_on_screen = ((LCD_HEIGHT-MARGIN_Y)/fh)-LINE_Y;
168 line_height = fh;
169#else
170 tree_max_on_screen = TREE_MAX_ON_SCREEN;
171#endif
172
157 173
158 /* new dir? cache it */ 174 /* new dir? cache it */
159 if (strncmp(path,lastdir,sizeof(lastdir))) { 175 if (strncmp(path,lastdir,sizeof(lastdir))) {
@@ -217,7 +233,7 @@ static int showdir(char *path, int start)
217 lcd_setfont(0); 233 lcd_setfont(0);
218#endif 234#endif
219 235
220 for ( i=start; i < start+TREE_MAX_ON_SCREEN; i++ ) { 236 for ( i=start; i < start+tree_max_on_screen; i++ ) {
221 int len; 237 int len;
222 238
223 if ( i >= filesindir ) 239 if ( i >= filesindir )
@@ -235,9 +251,10 @@ static int showdir(char *path, int start)
235 icon_type = File; 251 icon_type = File;
236 } 252 }
237 lcd_bitmap(bitmap_icons_6x8[icon_type], 253 lcd_bitmap(bitmap_icons_6x8[icon_type],
238 6, MARGIN_Y+(LINE_Y+i-start)*LINE_HEIGTH, 6, 8, true); 254 6, MARGIN_Y+(LINE_Y+i-start)*line_height, 6, 8, true);
239#endif 255#endif
240 256
257
241 /* if MP3 filter is on, cut off the extension */ 258 /* if MP3 filter is on, cut off the extension */
242 if (global_settings.mp3filter && 259 if (global_settings.mp3filter &&
243 (dircacheptr[i]->attr & (TREE_ATTR_M3U|TREE_ATTR_MP3))) 260 (dircacheptr[i]->attr & (TREE_ATTR_M3U|TREE_ATTR_MP3)))
@@ -270,6 +287,15 @@ bool dirbrowse(char *root)
270 int rc; 287 int rc;
271 int button; 288 int button;
272 int start_index; 289 int start_index;
290 int tree_max_on_screen;
291#ifdef LOADABLE_FONTS
292 int fh;
293 unsigned char *font = lcd_getcurrentldfont();
294 fh = ajf_get_fontheight(font);
295 tree_max_on_screen = ((LCD_HEIGHT-MARGIN_Y)/fh)-LINE_Y;
296#else
297 tree_max_on_screen = TREE_MAX_ON_SCREEN;
298#endif
273 299
274 memcpy(currdir,root,sizeof(currdir)); 300 memcpy(currdir,root,sizeof(currdir));
275 numentries = showdir(root, start); 301 numentries = showdir(root, start);
@@ -379,7 +405,7 @@ bool dirbrowse(char *root)
379 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); 405 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
380 } 406 }
381 else { 407 else {
382 if (numentries < TREE_MAX_ON_SCREEN) { 408 if (numentries < tree_max_on_screen) {
383 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, 409 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor,
384 false); 410 false);
385 dircursor = numentries - 1; 411 dircursor = numentries - 1;
@@ -387,11 +413,11 @@ bool dirbrowse(char *root)
387 true); 413 true);
388 } 414 }
389 else { 415 else {
390 start = numentries - TREE_MAX_ON_SCREEN; 416 start = numentries - tree_max_on_screen;
391 dircursor = TREE_MAX_ON_SCREEN - 1; 417 dircursor = tree_max_on_screen - 1;
392 numentries = showdir(currdir, start); 418 numentries = showdir(currdir, start);
393 put_cursorxy(0, CURSOR_Y + LINE_Y + 419 put_cursorxy(0, CURSOR_Y + LINE_Y +
394 TREE_MAX_ON_SCREEN - 1, true); 420 tree_max_on_screen - 1, true);
395 } 421 }
396 } 422 }
397 } 423 }
@@ -404,7 +430,7 @@ bool dirbrowse(char *root)
404 if(filesindir) 430 if(filesindir)
405 { 431 {
406 if (dircursor + start + 1 < numentries ) { 432 if (dircursor + start + 1 < numentries ) {
407 if(dircursor+1 < TREE_MAX_ON_SCREEN) { 433 if(dircursor+1 < tree_max_on_screen) {
408 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, 434 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor,
409 false); 435 false);
410 dircursor++; 436 dircursor++;
@@ -417,7 +443,7 @@ bool dirbrowse(char *root)
417 } 443 }
418 } 444 }
419 else { 445 else {
420 if(numentries < TREE_MAX_ON_SCREEN) { 446 if(numentries < tree_max_on_screen) {
421 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, 447 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor,
422 false); 448 false);
423 start = dircursor = 0; 449 start = dircursor = 0;
@@ -512,7 +538,7 @@ bool dirbrowse(char *root)
512 /* restore display */ 538 /* restore display */
513 /* We need to adjust if the number of lines on screen have 539 /* We need to adjust if the number of lines on screen have
514 changed because of a status bar change */ 540 changed because of a status bar change */
515 if(CURSOR_Y+LINE_Y+dircursor>TREE_MAX_ON_SCREEN) { 541 if(CURSOR_Y+LINE_Y+dircursor>tree_max_on_screen) {
516 start++; 542 start++;
517 dircursor--; 543 dircursor--;
518 } 544 }
diff --git a/apps/wps.c b/apps/wps.c
index 53458ca140..2bf384b20c 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -39,6 +39,10 @@
39#include "widgets.h" 39#include "widgets.h"
40#endif 40#endif
41 41
42#ifdef LOADABLE_FONTS
43#include "ajf.h"
44#endif
45
42#ifdef HAVE_LCD_BITMAP 46#ifdef HAVE_LCD_BITMAP
43#define LINE_Y (global_settings.statusbar&&statusbar_enabled?1:0) /* Y position the entry-list starts at */ 47#define LINE_Y (global_settings.statusbar&&statusbar_enabled?1:0) /* Y position the entry-list starts at */
44#else /* HAVE_LCD_BITMAP */ 48#else /* HAVE_LCD_BITMAP */
@@ -59,6 +63,15 @@ bool keys_locked = false;
59 63
60static void draw_screen(struct mp3entry* id3) 64static void draw_screen(struct mp3entry* id3)
61{ 65{
66 int font_height;
67#ifdef LOADABLE_FONTS
68 unsigned char *font = lcd_getcurrentldfont();
69 font_height = ajf_get_fontheight(font);
70#else
71 font_height = 8;
72#endif
73
74
62 lcd_clear_display(); 75 lcd_clear_display();
63 if(!id3) 76 if(!id3)
64 { 77 {
@@ -125,7 +138,7 @@ static void draw_screen(struct mp3entry* id3)
125 lcd_puts(0, l++, id3->album?id3->album:""); 138 lcd_puts(0, l++, id3->album?id3->album:"");
126 lcd_puts(0, l++, id3->artist?id3->artist:""); 139 lcd_puts(0, l++, id3->artist?id3->artist:"");
127 140
128 if(LINE_Y==0) { 141 if(LINE_Y==0&&font_height<=8) {
129 if(id3->vbr) 142 if(id3->vbr)
130 snprintf(buffer, sizeof(buffer), "%d kbit (avg)", 143 snprintf(buffer, sizeof(buffer), "%d kbit (avg)",
131 id3->bitrate); 144 id3->bitrate);
@@ -133,7 +146,6 @@ static void draw_screen(struct mp3entry* id3)
133 snprintf(buffer, sizeof(buffer), "%d kbit", id3->bitrate); 146 snprintf(buffer, sizeof(buffer), "%d kbit", id3->bitrate);
134 147
135 lcd_puts(0, l++, buffer); 148 lcd_puts(0, l++, buffer);
136
137 snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency); 149 snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency);
138 lcd_puts(0, l++, buffer); 150 lcd_puts(0, l++, buffer);
139 } 151 }
@@ -148,7 +160,6 @@ static void draw_screen(struct mp3entry* id3)
148 lcd_puts(0, l++, buffer); 160 lcd_puts(0, l++, buffer);
149 } 161 }
150#else 162#else
151
152 lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>"); 163 lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>");
153 lcd_puts_scroll(0, l++, id3->title?id3->title:"<no title>"); 164 lcd_puts_scroll(0, l++, id3->title?id3->title:"<no title>");
154#endif 165#endif
@@ -444,13 +455,13 @@ int wps_show(void)
444 if(!keys_locked && !dont_go_to_menu && menu_button_is_down) 455 if(!keys_locked && !dont_go_to_menu && menu_button_is_down)
445 { 456 {
446#ifdef HAVE_LCD_BITMAP 457#ifdef HAVE_LCD_BITMAP
447 bool laststate=statusbar(false); 458 bool laststate=statusbar(false);
448#endif 459#endif
449 lcd_stop_scroll(); 460 lcd_stop_scroll();
450 button_set_release(old_release_mask); 461 button_set_release(old_release_mask);
451 main_menu(); 462 main_menu();
452#ifdef HAVE_LCD_BITMAP 463#ifdef HAVE_LCD_BITMAP
453 statusbar(laststate); 464 statusbar(laststate);
454#endif 465#endif
455 old_release_mask = button_set_release(RELEASE_MASK); 466 old_release_mask = button_set_release(RELEASE_MASK);
456 id3 = mpeg_current_track(); 467 id3 = mpeg_current_track();
@@ -464,14 +475,14 @@ int wps_show(void)
464 break; 475 break;
465 476
466#ifdef HAVE_RECORDER_KEYPAD 477#ifdef HAVE_RECORDER_KEYPAD
467 case BUTTON_F3: 478 case BUTTON_F3:
468#ifdef HAVE_LCD_BITMAP 479#ifdef HAVE_LCD_BITMAP
469 if(global_settings.statusbar) { 480 if(global_settings.statusbar) {
470 statusbar_toggle(); 481 statusbar_toggle();
471 draw_screen(id3); 482 draw_screen(id3);
472 } 483 }
473#endif 484#endif
474 break; 485 break;
475#endif 486#endif
476 487
477#ifdef HAVE_RECORDER_KEYPAD 488#ifdef HAVE_RECORDER_KEYPAD
@@ -504,19 +515,19 @@ int wps_show(void)
504 usb_wait_for_disconnect(&button_queue); 515 usb_wait_for_disconnect(&button_queue);
505 516
506#ifdef HAVE_LCD_BITMAP 517#ifdef HAVE_LCD_BITMAP
507 statusbar(laststate); 518 statusbar(laststate);
508#endif 519#endif
509 /* Signal to our caller that we have been in USB mode */ 520 /* Signal to our caller that we have been in USB mode */
510 return SYS_USB_CONNECTED; 521 return SYS_USB_CONNECTED;
511 break; 522 break;
512 } 523 }
513#endif 524#endif
514 case BUTTON_NONE: /* Timeout */ 525 case BUTTON_NONE: /* Timeout */
515 if (mpeg_is_playing() && id3) 526 if (mpeg_is_playing() && id3)
516 { 527 {
517#ifdef HAVE_LCD_BITMAP 528#ifdef HAVE_LCD_BITMAP
518 snprintf(buffer,sizeof(buffer), 529 snprintf(buffer,sizeof(buffer),
519 "Time:%3d:%02d/%d:%02d", 530 "Time:%3d:%02d/%d:%02d",
520 id3->elapsed / 60000, 531 id3->elapsed / 60000,
521 id3->elapsed % 60000 / 1000, 532 id3->elapsed % 60000 / 1000,
522 id3->length / 60000, 533 id3->length / 60000,
@@ -524,9 +535,9 @@ int wps_show(void)
524 535
525 lcd_puts(0, 6, buffer); 536 lcd_puts(0, 6, buffer);
526 537
527 slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6, 538 slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6,
528 id3->elapsed*100/id3->length, 539 id3->elapsed*100/id3->length,
529 Grow_Right); 540 Grow_Right);
530 541
531 lcd_update(); 542 lcd_update();
532#else 543#else
@@ -535,7 +546,7 @@ int wps_show(void)
535 if (global_settings.wps_display == 546 if (global_settings.wps_display ==
536 PLAY_DISPLAY_FILENAME_SCROLL) 547 PLAY_DISPLAY_FILENAME_SCROLL)
537 { 548 {
538 snprintf(buffer,sizeof(buffer), "%d:%02d/%d:%02d ", 549 snprintf(buffer,sizeof(buffer), "%d:%02d/%d:%02d ",
539 id3->elapsed / 60000, 550 id3->elapsed / 60000,
540 id3->elapsed % 60000 / 1000, 551 id3->elapsed % 60000 / 1000,
541 id3->length / 60000, 552 id3->length / 60000,