1
0
Fork 0
forked from len0rd/rockbox

Adapted to changes in the lcd API.

Added player support to the dir browser.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@541 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-05-10 14:56:52 +00:00
parent 71cda11e65
commit c492d24cce
8 changed files with 296 additions and 254 deletions

View file

@ -97,15 +97,7 @@ void app_main(void)
lcd_puts(0,0, "Mooo!"); lcd_puts(0,0, "Mooo!");
lcd_puts(1,1, " Rockbox!"); lcd_puts(1,1, " Rockbox!");
while(1) { browse_root();
key = button_get();
if(!key) {
sleep(1);
continue;
}
}
} }

View file

@ -86,7 +86,7 @@ void move_cursor_down(void)
void redraw_cursor(void) void redraw_cursor(void)
{ {
lcd_puts(0, cursor*menu_line_height, "-", 0); lcd_putsxy(0, cursor*menu_line_height, "-", 0);
} }
/* /*
@ -96,9 +96,9 @@ void redraw_cursor(void)
*/ */
void put_cursor(int target) void put_cursor(int target)
{ {
lcd_puts(0, cursor*menu_line_height, " ", 0); lcd_putsxy(0, cursor*menu_line_height, " ",0);
cursor = target; cursor = target;
lcd_puts(0, cursor*menu_line_height, "-", 0); lcd_putsxy(0, cursor*menu_line_height, "-",0);
} }
/* We call the function pointer related to the current cursor position */ /* We call the function pointer related to the current cursor position */
@ -110,8 +110,8 @@ void execute_menu_item(void)
void add_menu_item(int location, char *string) void add_menu_item(int location, char *string)
{ {
lcd_puts(MENU_ITEM_Y_LOC, MENU_LINE_HEIGHT*location, lcd_putsxy(MENU_ITEM_Y_LOC, MENU_LINE_HEIGHT*location, string,
string, MENU_ITEM_FONT); MENU_ITEM_FONT);
if (location < menu_top) if (location < menu_top)
menu_top = location; menu_top = location;
if (location > menu_bottom) if (location > menu_bottom)
@ -130,7 +130,7 @@ void menu_init(void)
for (i = i; i < Last_Id; i++) for (i = i; i < Last_Id; i++)
add_menu_item(items[i].menu_id, (char *) items[i].menu_desc); add_menu_item(items[i].menu_id, (char *) items[i].menu_desc);
lcd_puts(8, 38, "Rockbox!", 2); lcd_putsxy(8, 38, "Rockbox!",2);
redraw_cursor(); redraw_cursor();
} }

View file

@ -26,6 +26,7 @@
#include <button.h> #include <button.h>
#include "kernel.h" #include "kernel.h"
#include "tree.h" #include "tree.h"
#include "debug.h"
#include "id3.h" #include "id3.h"
@ -33,8 +34,7 @@
#include "x11/mpegplay.h" #include "x11/mpegplay.h"
#endif #endif
#define LINE_Y 8 /* initial line */ #define LINE_Y 1 /* initial line */
#define LINE_HEIGTH 8 /* line height in pixels */
void playtune(char *dir, char *file) void playtune(char *dir, char *file)
{ {
@ -46,31 +46,39 @@ void playtune(char *dir, char *file)
sprintf(buffer, "%s/%s", dir, file); sprintf(buffer, "%s/%s", dir, file);
if(mp3info(&mp3, buffer)) { if(mp3info(&mp3, buffer)) {
debugf("id3 failure!"); DEBUGF("id3 failure!");
good=0; good=0;
} }
#ifdef HAVE_LCD_BITMAP
lcd_clear_display(); lcd_clear_display();
#ifdef HAVE_LCD_BITMAP
lcd_setmargins(0,0);
lcd_setfont(0);
#endif
if(!good) { if(!good) {
lcd_puts(0, 0, "[no id3 info]", 0); lcd_puts(0, 0, "[no id3 info]");
} }
else { else {
lcd_puts(0, 0, "[id3 info]", 0); #ifdef HAVE_LCD_BITMAP
lcd_puts(0, LINE_Y, mp3.title?mp3.title:"", 0); lcd_puts(0, 0, "[id3 info]");
lcd_puts(0, LINE_Y+1*LINE_HEIGTH, mp3.album?mp3.album:"", 0); lcd_puts(0, LINE_Y, mp3.title?mp3.title:"");
lcd_puts(0, LINE_Y+2*LINE_HEIGTH, mp3.artist?mp3.artist:"", 0); lcd_puts(0, LINE_Y+1, mp3.album?mp3.album:"");
lcd_puts(0, LINE_Y+2, mp3.artist?mp3.artist:"");
sprintf(buffer, "%d ms", mp3.length); sprintf(buffer, "%d ms", mp3.length);
lcd_puts(0, LINE_Y+3*LINE_HEIGTH, buffer, 0); lcd_puts(0, LINE_Y+3, buffer);
sprintf(buffer, "%d kbits", mp3.bitrate); sprintf(buffer, "%d kbits", mp3.bitrate);
lcd_puts(0, LINE_Y+4*LINE_HEIGTH, buffer, 0); lcd_puts(0, LINE_Y+4, buffer);
sprintf(buffer, "%d Hz", mp3.frequency); sprintf(buffer, "%d Hz", mp3.frequency);
lcd_puts(0, LINE_Y+5*LINE_HEIGTH, buffer, 0); lcd_puts(0, LINE_Y+5, buffer);
#else
lcd_puts(0, 0, mp3.artist?mp3.artist:"<no artist>");
lcd_puts(0, 1, mp3.title?mp3.title:"<no title>");
#endif
} }
lcd_update(); lcd_update();
#endif
#ifdef MPEG_PLAY #ifdef MPEG_PLAY
sprintf(buffer, "%s/%s", dir, file); sprintf(buffer, "%s/%s", dir, file);

View file

@ -84,11 +84,11 @@ void ss_loop(void)
void screensaver(void) void screensaver(void)
{ {
char w, h; int w, h;
char *off = "[Off] to stop"; char *off = "[Off] to stop";
int len = strlen(SS_TITLE); int len = strlen(SS_TITLE);
lcd_fontsize(SS_TITLE_FONT, &w, &h); lcd_getfontsize(SS_TITLE_FONT, &w, &h);
/* Get horizontel centering for text */ /* Get horizontel centering for text */
len *= w; len *= w;
@ -103,10 +103,10 @@ void screensaver(void)
h /= 2; h /= 2;
lcd_clear_display(); lcd_clear_display();
lcd_puts(LCD_WIDTH/2-len, (LCD_HEIGHT/2)-h, SS_TITLE, SS_TITLE_FONT); lcd_putsxy(LCD_WIDTH/2-len, (LCD_HEIGHT/2)-h, SS_TITLE, SS_TITLE_FONT);
len = strlen(off); len = strlen(off);
lcd_fontsize(0, &w, &h); lcd_getfontsize(0, &w, &h);
/* Get horizontel centering for text */ /* Get horizontel centering for text */
len *= w; len *= w;
@ -120,7 +120,7 @@ void screensaver(void)
else else
h /= 2; h /= 2;
lcd_puts(LCD_WIDTH/2-len, LCD_HEIGHT-(2*h), off, 0); lcd_putsxy(LCD_WIDTH/2-len, LCD_HEIGHT-(2*h), off,0);
lcd_update(); lcd_update();
sleep(150); sleep(150);

View file

@ -310,14 +310,14 @@ void game_loop(void)
sleep(10); sleep(10);
} }
if(gameover()) { if(gameover()) {
char w, h; int w, h;
lcd_fontsize(TETRIS_TITLE_FONT, &w, &h); lcd_getfontsize(TETRIS_TITLE_FONT, &w, &h);
lcd_clearrect(TETRIS_TITLE_XLOC, TETRIS_TITLE_YLOC, lcd_clearrect(TETRIS_TITLE_XLOC, TETRIS_TITLE_YLOC,
TETRIS_TITLE_XLOC+(w*sizeof(TETRIS_TITLE)), TETRIS_TITLE_XLOC+(w*sizeof(TETRIS_TITLE)),
TETRIS_TITLE_YLOC-h); TETRIS_TITLE_YLOC-h);
lcd_puts(TETRIS_TITLE_XLOC, TETRIS_TITLE_YLOC, lcd_putsxy(TETRIS_TITLE_XLOC, TETRIS_TITLE_YLOC, "You lose!",
"You lose!", TETRIS_TITLE_FONT); TETRIS_TITLE_FONT);
lcd_update(); lcd_update();
sleep(2); sleep(2);
return; return;
@ -349,8 +349,8 @@ void tetris(void)
init_tetris(); init_tetris();
draw_frame(start_x-1,start_x+max_x,start_y-1,start_y+max_y); draw_frame(start_x-1,start_x+max_x,start_y-1,start_y+max_y);
lcd_puts(TETRIS_TITLE_XLOC, TETRIS_TITLE_YLOC, lcd_putsxy(TETRIS_TITLE_XLOC, TETRIS_TITLE_YLOC, TETRIS_TITLE,
TETRIS_TITLE, TETRIS_TITLE_FONT); TETRIS_TITLE_FONT);
lcd_update(); lcd_update();
next_b = t_rand(blocks); next_b = t_rand(blocks);

View file

@ -32,13 +32,8 @@
#include "play.h" #include "play.h"
#define TREE_MAX_FILENAMELEN 64
#define TREE_MAX_ON_SCREEN 7
#define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */
void browse_root(void) { #define TREE_MAX_FILENAMELEN 128
dirbrowse("/");
}
struct entry { struct entry {
int file; /* TRUE if file, FALSE if dir */ int file; /* TRUE if file, FALSE if dir */
@ -46,15 +41,35 @@ struct entry {
int namelen; int namelen;
}; };
#define LINE_Y 8 /* Y position the entry-list starts at */ void browse_root(void)
#define LINE_X 12 /* X position the entry-list starts at */ {
#define LINE_HEIGTH 8 /* pixels for each text line */ dirbrowse("/");
}
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#define TREE_MAX_ON_SCREEN 7
#define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */
#define MARGIN_Y 8 /* Y pixel margin */
#define MARGIN_X 12 /* X pixel margin */
#define LINE_Y 0 /* Y position the entry-list starts at */
#define LINE_X 2 /* X position the entry-list starts at */
#define LINE_HEIGTH 8 /* pixels for each text line */
extern unsigned char bitmap_icons_6x8[LastIcon][6]; extern unsigned char bitmap_icons_6x8[LastIcon][6];
extern icons_6x8; extern icons_6x8;
#else /* HAVE_LCD_BITMAP */
#define TREE_MAX_ON_SCREEN 2
#define TREE_MAX_LEN_DISPLAY 11 /* max length that fits on screen */
#define LINE_Y 0 /* Y position the entry-list starts at */
#define LINE_X 1 /* X position the entry-list starts at */
#endif /* HAVE_LCD_BITMAP */
int static showdir(char *path, struct entry *buffer, int start, int static showdir(char *path, struct entry *buffer, int start,
int scrollpos, int* at_end) int scrollpos, int* at_end)
{ {
@ -89,16 +104,21 @@ int static showdir(char *path, struct entry *buffer, int start,
buffer[i].file = !(entry->attribute&ATTR_DIRECTORY); buffer[i].file = !(entry->attribute&ATTR_DIRECTORY);
buffer[i].file?(icon_type=File):(icon_type=Folder); #ifdef HAVE_LCD_BITMAP
lcd_bitmap(bitmap_icons_6x8[icon_type], 6, LINE_Y+i*LINE_HEIGTH, 6, if ( buffer[i].file )
icon_type=File;
else
icon_type=Folder;
lcd_bitmap(bitmap_icons_6x8[icon_type], 6, MARGIN_Y+i*LINE_HEIGTH, 6,
8, TRUE); 8, TRUE);
#endif
if(len < TREE_MAX_LEN_DISPLAY) if(len < TREE_MAX_LEN_DISPLAY)
lcd_puts(LINE_X, LINE_Y+i*LINE_HEIGTH, buffer[i].name, 0); lcd_puts(LINE_X, LINE_Y+i, buffer[i].name);
else { else {
char storage = buffer[i].name[TREE_MAX_LEN_DISPLAY]; char storage = buffer[i].name[TREE_MAX_LEN_DISPLAY];
buffer[i].name[TREE_MAX_LEN_DISPLAY]=0; buffer[i].name[TREE_MAX_LEN_DISPLAY]=0;
lcd_puts(LINE_X, LINE_Y+i*LINE_HEIGTH, buffer[i].name, 0); lcd_puts(LINE_X, LINE_Y+i, buffer[i].name);
buffer[i].name[TREE_MAX_LEN_DISPLAY]=storage; buffer[i].name[TREE_MAX_LEN_DISPLAY]=storage;
} }
@ -113,15 +133,13 @@ int static showdir(char *path, struct entry *buffer, int start,
} }
j = i ; j = i ;
while (j++ < TREE_MAX_ON_SCREEN) { while (j++ < TREE_MAX_ON_SCREEN) {
lcd_puts(LINE_X, LINE_Y+j*LINE_HEIGTH," ", 0); lcd_puts(LINE_X, LINE_Y+j," ");
} }
closedir(dir); closedir(dir);
return i; return i;
} }
#endif
bool dirbrowse(char *root) bool dirbrowse(char *root)
{ {
struct entry buffer[TREE_MAX_ON_SCREEN]; struct entry buffer[TREE_MAX_ON_SCREEN];
@ -133,18 +151,21 @@ bool dirbrowse(char *root)
int start=0; int start=0;
int at_end=0; int at_end=0;
#ifdef HAVE_LCD_BITMAP
lcd_clear_display(); lcd_clear_display();
lcd_puts(0,0, "[Browse]", 0); #ifdef HAVE_LCD_BITMAP
lcd_putsxy(0,0, "[Browse]",0);
lcd_setmargins(0,MARGIN_Y);
lcd_setfont(0);
#endif
memcpy(currdir,root,sizeof(currdir)); memcpy(currdir,root,sizeof(currdir));
numentries = showdir(root, buffer, 0, start, &at_end); numentries = showdir(root, buffer, 0, start, &at_end);
if (numentries == -1) return -1; /* root is not a directory */ if (numentries == -1)
return -1; /* root is not a directory */
lcd_puts(0, LINE_Y+dircursor*LINE_HEIGTH, "-", 0);
lcd_puts(0, dircursor, "-");
lcd_update(); lcd_update();
while(1) { while(1) {
@ -163,21 +184,29 @@ bool dirbrowse(char *root)
i=strlen(currdir); i=strlen(currdir);
if (i==1) { if (i==1) {
return FALSE; return FALSE;
} else { }
while (currdir[i-1]!='/') i--; else {
while (currdir[i-1]!='/')
i--;
strcpy(buf,&currdir[i]); strcpy(buf,&currdir[i]);
if (i==1) currdir[i]=0; if (i==1)
else currdir[i-1]=0; currdir[i]=0;
else
currdir[i-1]=0;
lcd_clear_display(); lcd_clear_display();
lcd_puts(0,0, "[Browse]", 0); #ifdef HAVE_LCD_BITMAP
lcd_putsxy(0,0, "[Browse]",0);
#endif
numentries = showdir(currdir, buffer, 0, 0, &at_end); numentries = showdir(currdir, buffer, 0, 0, &at_end);
dircursor=0; dircursor=0;
start=0; start=0;
while ( (dircursor < TREE_MAX_ON_SCREEN) && while ( (dircursor < TREE_MAX_ON_SCREEN) &&
(strcmp(buffer[dircursor].name,buf)!=0)) dircursor++; (strcmp(buffer[dircursor].name,buf)!=0))
if (dircursor==TREE_MAX_ON_SCREEN) dircursor=0; dircursor++;
lcd_puts(0, LINE_Y+dircursor*LINE_HEIGTH, "-", 0); if (dircursor==TREE_MAX_ON_SCREEN)
dircursor=0;
lcd_puts(0, LINE_Y+dircursor, "-");
lcd_update(); lcd_update();
} }
@ -197,53 +226,65 @@ bool dirbrowse(char *root)
start=0; start=0;
} else { } else {
playtune(currdir, buffer[dircursor].name); playtune(currdir, buffer[dircursor].name);
#ifdef HAVE_LCD_BITMAP
lcd_setmargins(0, MARGIN_Y);
lcd_setfont(0);
#endif
} }
lcd_clear_display(); lcd_clear_display();
lcd_puts(0,0, "[Browse]", 0);
numentries = showdir(currdir, buffer, 0, start, &at_end); numentries = showdir(currdir, buffer, 0, start, &at_end);
lcd_puts(0, LINE_Y+dircursor*LINE_HEIGTH, "-", 0); #ifdef HAVE_LCD_BITMAP
lcd_putsxy(0,0, "[Browse]",0);
#endif
lcd_puts(0, LINE_Y+dircursor, "-");
lcd_update(); lcd_update();
break; break;
case BUTTON_UP: case BUTTON_UP:
if(dircursor) { if(dircursor) {
lcd_puts(0, LINE_Y+dircursor*LINE_HEIGTH, " ", 0); lcd_puts(0, LINE_Y+dircursor, " ");
dircursor--; dircursor--;
lcd_puts(0, LINE_Y+dircursor*LINE_HEIGTH, "-", 0); lcd_puts(0, LINE_Y+dircursor, "-");
lcd_update(); lcd_update();
} else } else
{ {
if (start) { if (start) {
lcd_clear_display(); lcd_clear_display();
lcd_puts(0,0, "[Browse]", 0); start--;
numentries = showdir(currdir, buffer, 0, --start, &at_end); numentries = showdir(currdir, buffer, 0,
lcd_puts(0, LINE_Y+dircursor*LINE_HEIGTH, "-", 0); start, &at_end);
#ifdef HAVE_LCD_BITMAP
lcd_putsxy(0,0, "[Browse]",0);
#endif
lcd_puts(0, LINE_Y+dircursor, "-");
lcd_update(); lcd_update();
} }
} }
break; break;
case BUTTON_DOWN: case BUTTON_DOWN:
if(dircursor+1 < numentries) { if(dircursor+1 < numentries) {
lcd_puts(0, LINE_Y+dircursor*LINE_HEIGTH, " ", 0); lcd_puts(0, LINE_Y+dircursor, " ");
dircursor++; dircursor++;
lcd_puts(0, LINE_Y+dircursor*LINE_HEIGTH, "-", 0); lcd_puts(0, LINE_Y+dircursor, "-");
lcd_update(); lcd_update();
} else } else
{ {
if (!at_end) { if (!at_end) {
lcd_clear_display(); lcd_clear_display();
lcd_puts(0,0, "[Browse]", 0); start++;
numentries = showdir(currdir, buffer, 0, ++start, &at_end); numentries = showdir(currdir, buffer, 0,
start, &at_end);
lcd_puts(0, LINE_Y+dircursor*LINE_HEIGTH, "-", 0); #ifdef HAVE_LCD_BITMAP
lcd_putsxy(0,0, "[Browse]",0);
#endif
lcd_puts(0, LINE_Y+dircursor, "-");
lcd_update(); lcd_update();
} }
} }
break; break;
} }
} }
#endif
return FALSE; return FALSE;
} }

View file

@ -28,8 +28,8 @@ CC = gcc
RM = rm -f RM = rm -f
DEBUG = -g DEBUG = -g
#DISPLAY = -DHAVE_LCD_CHARCELLS DISPLAY = -DHAVE_LCD_CHARCELLS
DISPLAY = -DHAVE_LCD_BITMAP #DISPLAY = -DHAVE_LCD_BITMAP
DEFINES = -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \ DEFINES = -DHAVE_CONFIG_H -DGETTIMEOFDAY_TWO_ARGS -DSIMULATOR \
-DHAVE_RECORDER_KEYPAD $(DISPLAY) -DHAVE_RECORDER_KEYPAD $(DISPLAY)

View file

@ -120,6 +120,7 @@ void lcd_puts(int x, int y, char *string)
strncpy(buffer, string, 11); strncpy(buffer, string, 11);
buffer[11]=0; buffer[11]=0;
sim_lcd_puts(x*6, y*8, buffer, 0); debugf("lcd_puts(%d,%d,%s)\n",x,y,string);
sim_lcd_puts(x, y, buffer, 0);
} }
#endif #endif