app.c removed, main_menu.c introduced

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@645 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-05-21 14:35:18 +00:00
parent 6466b62e5d
commit ab2649fbef
3 changed files with 139 additions and 119 deletions

View file

@ -1,116 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 Daniel Stenberg
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "lcd.h"
#include "button.h"
#include "kernel.h"
#include "menu.h"
/* Apps to include */
#include "tree.h"
/* Wait on a key press. Return the key pressed */
int busy_wait(void)
{
int key;
while(1) {
key = button_get();
if(!key)
sleep(1);
else
break;
}
return key;
}
#ifdef HAVE_LCD_BITMAP
void app_main(void)
{
int key;
show_splash();
menu_init();
menu_draw();
put_cursor_menu_top();
while(1) {
key = busy_wait();
switch(key) {
case BUTTON_UP:
if(is_cursor_menu_top()){
/* wrap around to menu bottom */
put_cursor_menu_bottom();
} else {
/* move up */
move_cursor_up();
}
break;
case BUTTON_DOWN:
if(is_cursor_menu_bottom() ){
/* wrap around to menu top */
put_cursor_menu_top();
} else {
/* move down */
move_cursor_down();
}
break;
case BUTTON_RIGHT:
case BUTTON_PLAY:
/* Erase current display state */
lcd_clear_display();
execute_menu_item();
/* Return to previous display state */
lcd_clear_display();
menu_draw();
break;
case BUTTON_OFF:
return;
default:
break;
}
lcd_update();
}
}
#else
void app_main(void)
{
int key;
int cursor = 0;
show_splash();
browse_root();
}
#endif

130
apps/main_menu.c Normal file
View file

@ -0,0 +1,130 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 Björn Stenberg
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "menu.h"
#include "tree.h"
#include "credits.h"
void show_splash(void);
#ifdef HAVE_LCD_BITMAP
#include "screensaver.h"
extern void tetris(void);
/* recorder menu */
enum Main_Menu_Ids {
Tetris, Screen_Saver, Splash, Credits
};
struct menu_items items[] = {
{ Tetris, "Tetris", tetris },
{ Screen_Saver, "Screen Saver", screensaver },
{ Splash, "Splash", show_splash },
{ Credits, "Credits", show_credits },
};
#else
/* player menu */
enum Main_Menu_Ids {
Splash, Credits
};
struct menu_items items[] = {
{ Splash, "Splash", show_splash },
{ Credits, "Credits", show_credits },
};
#endif
#ifdef HAVE_LCD_BITMAP
int show_logo(void)
{
unsigned char buffer[112 * 8];
int failure;
int width=0;
int height=0;
failure = read_bmp_file("/rockbox112.bmp", &width, &height, buffer);
debugf("read_bmp_file() returned %d, width %d height %d\n",
failure, width, height);
if (failure) {
debugf("Unable to find \"/rockbox112.bmp\"\n");
return -1;
} else {
int i;
int eline;
for(i=0, eline=0; i< height; i+=8, eline++) {
int x,y;
/* the bitmap function doesn't work with full-height bitmaps
so we "stripe" the logo output */
lcd_bitmap(&buffer[eline*width], 0, 10+i, width,
(height-i)>8?8:height-i, false);
#if 0
/* for screen output debugging */
for(y=0; y<8 && (i+y < height); y++) {
for(x=0; x < width; x++) {
if(buffer[eline*width + x] & (1<<y)) {
printf("*");
}
else
printf(" ");
}
printf("\n");
}
#endif
}
}
return 0;
}
#endif
void show_splash(void)
{
char *rockbox = "ROCKbox!";
lcd_clear_display();
#ifdef HAVE_LCD_BITMAP
if (show_logo() != 0)
return;
#else
lcd_puts(0, 0, rockbox);
#endif
lcd_update();
while(!button_get());
}
void main_menu(void)
{
menu_init( items, sizeof(items)/sizeof(struct menu_items) );
menu_run();
}

View file

@ -43,7 +43,7 @@ $(KEYPAD) $(DISPLAY)
LDFLAGS = -lX11 -lm -lXt -lXmu -lnsl LDFLAGS = -lX11 -lm -lXt -lXmu -lnsl
INCLUDES = -I. -I$(DRIVERS) -I$(FIRMWAREDIR) -I$(APPDIR) -I$(RECDIR) INCLUDES = -I. -I$(DRIVERS) -I$(COMMON) -I$(FIRMWAREDIR) -I$(APPDIR) -I$(RECDIR)
LIBS = LIBS =
@ -64,8 +64,11 @@ CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES)
FIRMSRCS = chartables.c lcd.c sprintf.c id3.c debug.c FIRMSRCS = chartables.c lcd.c sprintf.c id3.c debug.c
APPS = tetris.c screensaver.c tree.c app.c play.c menu.c icons.c bmp.c credits.c APPS = main.c tree.c play.c menu.c credits.c main_menu.c
ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
APPS += tetris.c screensaver.c icons.c bmp.c
endif
SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c \ SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c \
button-x11.c io.c sleep.c $(APPS) $(FIRMSRCS) button-x11.c io.c sleep.c $(APPS) $(FIRMSRCS)
@ -132,6 +135,9 @@ credits.o: $(APPDIR)/credits.c
menu.o: $(APPDIR)/menu.c menu.o: $(APPDIR)/menu.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
main_menu.o: $(APPDIR)/main_menu.c
$(CC) $(CFLAGS) -c $< -o $@
icons.o: $(RECDIR)/icons.c icons.o: $(RECDIR)/icons.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
@ -141,7 +147,7 @@ tetris.o: $(RECDIR)/tetris.c
screensaver.o: $(RECDIR)/screensaver.c screensaver.o: $(RECDIR)/screensaver.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
app.o: $(APPDIR)/app.c main.o: $(APPDIR)/main.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
bmp.o: $(RECDIR)/bmp.c bmp.o: $(RECDIR)/bmp.c