Corrected name spelling.
[kugel-rb/myfork.git] / apps / main_menu.c
blob885deea6c40e680cd6fb4c0aea1d89af29ef7177
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Björn Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "menu.h"
21 #include "tree.h"
22 #include "credits.h"
23 #include "lcd.h"
24 #include "button.h"
25 #include "kernel.h"
26 #include "main_menu.h"
27 #include "version.h"
28 #include "debug_menu.h"
29 #include "sprintf.h"
30 #include <string.h>
31 #include "playlist.h"
32 #include "settings.h"
33 #include "settings_menu.h"
34 #include "power.h"
35 #include "powermgmt.h"
36 #include "sound_menu.h"
38 #ifdef HAVE_LCD_BITMAP
39 #include "games_menu.h"
40 #include "screensavers_menu.h"
41 #include "bmp.h"
42 #include "icons.h"
43 #endif
45 int show_logo( void )
47 #ifdef HAVE_LCD_BITMAP
48 char version[32];
49 unsigned char *ptr=rockbox112x37;
50 int height, i, font_h, font_w;
52 lcd_clear_display();
54 for(i=0; i < 37; i+=8) {
55 /* the bitmap function doesn't work with full-height bitmaps
56 so we "stripe" the logo output */
57 lcd_bitmap(ptr, 0, 10+i, 112, (37-i)>8?8:37-i, false);
58 ptr += 112;
60 height = 37;
62 #if 0
64 * This code is not used anymore, but I kept it here since it shows
65 * one way of using the BMP reader function to display an externally
66 * providing logo.
68 unsigned char buffer[112 * 8];
69 int width;
71 int i;
72 int eline;
74 int failure;
75 failure = read_bmp_file("/rockbox112.bmp", &width, &height, buffer);
77 debugf("read_bmp_file() returned %d, width %d height %d\n",
78 failure, width, height);
80 for(i=0, eline=0; i < height; i+=8, eline++) {
81 /* the bitmap function doesn't work with full-height bitmaps
82 so we "stripe" the logo output */
83 lcd_bitmap(&buffer[eline*width], 0, 10+i, width,
84 (height-i)>8?8:height-i, false);
87 #endif
89 snprintf(version, sizeof(version), "Ver. %s", appsversion);
90 lcd_getfontsize(0, &font_w, &font_h);
91 lcd_putsxy((LCD_WIDTH/2) - ((strlen(version)*font_w)/2),
92 height+10+font_h, version, 0);
93 lcd_update();
95 #else
96 char *rockbox = "ROCKbox!";
97 lcd_clear_display();
98 #ifdef HAVE_NEW_CHARCELL_LCD
99 lcd_double_height(true);
100 #endif
101 lcd_puts(0, 0, rockbox);
102 lcd_puts(0, 1, appsversion);
103 #endif
105 return 0;
108 Menu show_credits(void)
110 int j = 0;
111 int btn;
113 show_logo();
114 #ifdef HAVE_NEW_CHARCELL_LCD
115 lcd_double_height(false);
116 #endif
118 for (j = 0; j < 10; j++) {
119 sleep((HZ*2)/10);
121 btn = button_get(false);
122 if (btn != BUTTON_NONE && !(btn & BUTTON_REL))
123 return MENU_OK;
125 roll_credits();
126 return MENU_OK;
129 #ifdef SIMULATOR
130 #define mp3buf 0
131 #define mp3end 0
133 extern Menu simulate_usb(void);
134 #else
135 /* defined in linker script */
136 extern unsigned char mp3buf[];
137 extern unsigned char mp3end[];
138 #endif
139 Menu show_info(void)
141 char s[32];
142 int buflen = ((mp3end - mp3buf) * 100) / 0x100000;
143 int integer, decimal;
144 bool done = false;
146 while(!done)
148 lcd_clear_display();
149 lcd_puts(0, 0, "Rockbox info:");
151 integer = buflen / 100;
152 decimal = buflen % 100;
153 #ifdef HAVE_LCD_CHARCELLS
154 snprintf(s, sizeof(s), "Buf: %d.%02dMb", integer, decimal);
155 lcd_puts(0, 0, s);
156 #else
157 snprintf(s, sizeof(s), "Buffer: %d.%02d Mb", integer, decimal);
158 lcd_puts(0, 2, s);
159 #endif
161 #ifdef HAVE_LCD_CHARCELLS
162 snprintf(s, sizeof(s), "Batt: %d%%%s", battery_level(), battery_level_safe() ? "" : "!");
163 lcd_puts(0, 1, s);
164 #else
165 #ifdef HAVE_CHARGE_CTRL
166 if (charger_enabled)
167 snprintf(s, sizeof(s), "Battery: charging");
168 else
169 snprintf(s, sizeof(s), "Battery: %d%%%s", battery_level(), battery_level_safe() ? "" : " !!");
170 lcd_puts(0, 3, s);
171 #else
172 snprintf(s, sizeof(s), "Battery: %d%%%s", battery_level(), battery_level_safe() ? "" : " !!");
173 lcd_puts(0, 3, s);
174 #endif
175 #endif
177 lcd_update();
179 sleep(HZ/2);
181 /* Wait for a key to be pushed */
182 if(button_get(false) & ~BUTTON_REL)
183 done = true;
186 return MENU_OK;
189 Menu main_menu(void)
191 int m;
192 Menu result;
194 /* main menu */
195 struct menu_items items[] = {
196 { "Sound Settings", sound_menu },
197 { "General Settings", settings_menu },
198 #ifdef HAVE_LCD_BITMAP
199 { "Games", games_menu },
200 { "Screensavers", screensavers_menu },
201 #endif
202 { "Info", show_info },
203 { "Version", show_credits },
204 #ifndef SIMULATOR
205 { "Debug (keep out!)", debug_menu },
206 #else
207 { "USB (sim)", simulate_usb },
208 #endif
211 m=menu_init( items, sizeof items / sizeof(struct menu_items) );
212 #ifdef HAVE_LCD_CHARCELLS
213 lcd_icon(ICON_PARAM, true);
214 #endif
215 result = menu_run(m);
216 #ifdef HAVE_LCD_CHARCELLS
217 lcd_icon(ICON_PARAM, false);
218 #endif
219 menu_exit(m);
221 settings_save();
223 return result;