2002-04-27 23:41:18 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2002-04-28 20:35:33 +00:00
|
|
|
* Copyright (C) 2002 Daniel Stenberg
|
2002-04-27 23:41:18 +00:00
|
|
|
*
|
|
|
|
* 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 "types.h"
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "button.h"
|
2002-04-28 08:37:15 +00:00
|
|
|
#include "kernel.h"
|
2002-04-27 23:41:18 +00:00
|
|
|
|
2002-05-04 10:03:41 +00:00
|
|
|
/* Apps to include */
|
2002-04-30 13:17:11 +00:00
|
|
|
#include "tree.h"
|
2002-05-04 10:03:41 +00:00
|
|
|
#include "screensaver.h"
|
2002-04-30 13:17:11 +00:00
|
|
|
|
2002-05-04 12:27:18 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
2002-04-28 08:37:15 +00:00
|
|
|
extern void tetris(void);
|
2002-04-27 23:41:18 +00:00
|
|
|
|
2002-05-03 05:21:58 +00:00
|
|
|
#define MENU_ITEM_FONT 0
|
|
|
|
#define MENU_ITEM_Y_LOC 6
|
|
|
|
#define MENU_LINE_HEIGHT 8
|
2002-04-27 23:41:18 +00:00
|
|
|
|
2002-05-04 10:03:41 +00:00
|
|
|
enum Menu_Ids {
|
|
|
|
Tetris, Screen_Saver, Browse, Last_Id
|
|
|
|
};
|
2002-04-27 23:41:18 +00:00
|
|
|
|
2002-05-04 10:03:41 +00:00
|
|
|
struct Menu_Items {
|
|
|
|
int menu_id;
|
|
|
|
const char *menu_desc;
|
|
|
|
void (*function) (void);
|
|
|
|
};
|
2002-05-03 05:21:58 +00:00
|
|
|
|
2002-05-04 10:03:41 +00:00
|
|
|
struct Menu_Items items[] = {
|
|
|
|
{ Tetris, "Tetris", tetris },
|
|
|
|
{ Screen_Saver, "Screen Saver", screensaver },
|
2002-05-04 12:27:18 +00:00
|
|
|
{ Browse, "Browse", browse_root },
|
2002-05-04 10:03:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int menu_top = Tetris;
|
|
|
|
int menu_bottom = Last_Id-1;
|
2002-05-03 05:21:58 +00:00
|
|
|
|
|
|
|
void add_menu_item(int location, char *string)
|
|
|
|
{
|
|
|
|
lcd_puts(MENU_ITEM_Y_LOC, MENU_LINE_HEIGHT*location,
|
|
|
|
string, MENU_ITEM_FONT);
|
|
|
|
if (location < menu_top)
|
|
|
|
menu_top = location;
|
|
|
|
if (location > menu_bottom)
|
|
|
|
menu_bottom = location;
|
|
|
|
}
|
2002-04-28 00:11:50 +00:00
|
|
|
|
|
|
|
void menu_init(void)
|
2002-04-27 23:41:18 +00:00
|
|
|
{
|
2002-05-04 10:03:41 +00:00
|
|
|
int i = 0;
|
|
|
|
for (i = i; i < Last_Id; i++)
|
|
|
|
add_menu_item(items[i].menu_id, (char *) items[i].menu_desc);
|
2002-05-03 05:21:58 +00:00
|
|
|
|
|
|
|
lcd_puts(8, 38, "Rockbox!", 2);
|
|
|
|
}
|
|
|
|
|
2002-05-03 06:11:39 +00:00
|
|
|
/*
|
|
|
|
* Move the cursor to a particular id,
|
|
|
|
* current: where it is now
|
|
|
|
* target: where you want it to be
|
|
|
|
* Returns: the new current location
|
|
|
|
*/
|
2002-05-03 05:21:58 +00:00
|
|
|
int put_cursor(int current, int target)
|
|
|
|
{
|
|
|
|
lcd_puts(0, current*MENU_LINE_HEIGHT, " ", 0);
|
|
|
|
lcd_puts(0, target*MENU_LINE_HEIGHT, "-", 0);
|
|
|
|
return target;
|
2002-04-28 00:11:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void app_main(void)
|
|
|
|
{
|
2002-05-03 05:21:58 +00:00
|
|
|
int key;
|
|
|
|
int cursor = 0;
|
2002-04-27 23:41:18 +00:00
|
|
|
|
2002-05-03 05:21:58 +00:00
|
|
|
menu_init();
|
2002-05-03 06:00:54 +00:00
|
|
|
cursor = put_cursor(menu_top, menu_top);
|
2002-04-28 00:11:50 +00:00
|
|
|
|
2002-05-03 05:21:58 +00:00
|
|
|
while(1) {
|
|
|
|
key = button_get();
|
2002-04-27 23:41:18 +00:00
|
|
|
|
2002-05-03 05:21:58 +00:00
|
|
|
if(!key) {
|
|
|
|
sleep(1);
|
|
|
|
continue;
|
|
|
|
}
|
2002-05-03 06:00:54 +00:00
|
|
|
|
2002-05-03 05:21:58 +00:00
|
|
|
switch(key) {
|
|
|
|
case BUTTON_UP:
|
|
|
|
if(cursor == menu_top ){
|
|
|
|
/* wrap around to menu bottom */
|
|
|
|
cursor = put_cursor(cursor, menu_bottom);
|
|
|
|
} else {
|
|
|
|
/* move up */
|
|
|
|
cursor = put_cursor(cursor, cursor-1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BUTTON_DOWN:
|
|
|
|
if(cursor == menu_bottom ){
|
|
|
|
/* wrap around to menu top */
|
|
|
|
cursor = put_cursor(cursor, menu_top);
|
|
|
|
} else {
|
|
|
|
/* move down */
|
|
|
|
cursor = put_cursor(cursor, cursor+1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BUTTON_RIGHT:
|
|
|
|
case BUTTON_PLAY:
|
|
|
|
/* Erase current display state */
|
|
|
|
lcd_clear_display();
|
|
|
|
|
2002-05-05 10:30:41 +00:00
|
|
|
/* call the proper function for this line */
|
|
|
|
items[cursor].function();
|
|
|
|
|
2002-05-03 05:21:58 +00:00
|
|
|
/* Return to previous display state */
|
|
|
|
lcd_clear_display();
|
|
|
|
menu_init();
|
2002-05-03 06:00:54 +00:00
|
|
|
cursor = put_cursor(cursor, cursor);
|
|
|
|
break;
|
|
|
|
case BUTTON_OFF:
|
|
|
|
return;
|
|
|
|
default:
|
2002-05-03 05:21:58 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-05-03 06:00:54 +00:00
|
|
|
|
2002-05-03 05:21:58 +00:00
|
|
|
lcd_update();
|
2002-04-27 23:41:18 +00:00
|
|
|
}
|
|
|
|
}
|
2002-05-03 06:00:54 +00:00
|
|
|
|
2002-05-04 12:27:18 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
void app_main(void)
|
|
|
|
{
|
|
|
|
int key;
|
|
|
|
int cursor = 0;
|
|
|
|
|
|
|
|
lcd_puts(0,0, "Mooo!");
|
|
|
|
lcd_puts(1,1, " Rockbox!");
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
key = button_get();
|
|
|
|
|
|
|
|
if(!key) {
|
|
|
|
sleep(1);
|
|
|
|
continue;
|
|
|
|
}
|
2002-05-03 06:00:54 +00:00
|
|
|
|
2002-05-04 12:27:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2002-05-03 06:00:54 +00:00
|
|
|
|
2002-05-04 12:27:18 +00:00
|
|
|
#endif
|