1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
19 #include <timefuncs.h>
29 #include "main_menu.h"
30 #include "debug_menu.h"
34 #include "settings_menu.h"
36 #include "powermgmt.h"
37 #include "sound_menu.h"
43 #include "playlist_menu.h"
52 #include "filetypes.h"
55 #include "recording.h"
58 #ifdef HAVE_REMOTE_LCD
59 #include "lcd-remote.h"
62 bool show_credits(void)
64 plugin_load("/.rockbox/rocks/credits.rock",NULL
);
69 extern bool simulate_usb(void);
72 #ifdef HAVE_LCD_CHARCELLS
73 #define SIZE_FMT "%s%s"
75 #define SIZE_FMT "%s %s"
81 long buflen
= ((audiobufend
- audiobuf
) * 2) / 2097; /* avoid overflow */
86 unsigned long size
, free
;
87 #ifdef HAVE_MULTIVOLUME
89 unsigned long size2
= 0;
90 unsigned long free2
= 0;
93 const unsigned char *kbyte_units
[] = {
99 fat_size( IF_MV2(0,) &size
, &free
);
100 #ifdef HAVE_MULTIVOLUME
101 if (fat_ismounted(1))
102 fat_size( 1, &size2
, &free2
);
105 if (global_settings
.talk_menu
)
106 { /* say whatever is reasonable, no real connection to the screen */
107 bool enqueue
= false; /* enqueue all but the first */
108 if (battery_level() >= 0)
110 talk_id(LANG_BATTERY_TIME
, enqueue
);
112 talk_value(battery_level(), UNIT_PERCENT
, true);
115 talk_id(LANG_DISK_FREE_INFO
, enqueue
);
116 #ifdef HAVE_MULTIVOLUME
117 talk_id(LANG_DISK_NAME_INTERNAL
, true);
118 output_dyn_value(NULL
, 0, free
, kbyte_units
, true);
121 talk_id(LANG_DISK_NAME_MMC
, true);
122 output_dyn_value(NULL
, 0, free2
, kbyte_units
, true);
125 output_dyn_value(NULL
, 0, free
, kbyte_units
, true); /* NULL == talk */
130 struct tm
* tm
= get_time();
131 talk_id(VOICE_CURRENT_TIME
, true);
132 talk_value(tm
->tm_hour
, UNIT_HOUR
, true);
133 talk_value(tm
->tm_min
, UNIT_MIN
, true);
134 talk_value(tm
->tm_sec
, UNIT_SEC
, true);
135 talk_id(LANG_MONTH_JANUARY
+ tm
->tm_mon
, true);
136 talk_number(tm
->tm_mday
, true);
137 talk_number(1900 + tm
->tm_year
, true);
146 #ifdef HAVE_LCD_BITMAP
147 lcd_puts(0, y
++, str(LANG_ROCKBOX_INFO
));
153 integer
= buflen
/ 1000;
154 decimal
= buflen
% 1000;
155 #ifdef HAVE_LCD_CHARCELLS
156 snprintf(s
, sizeof(s
), (char *)str(LANG_BUFFER_STAT_PLAYER
),
159 snprintf(s
, sizeof(s
), (char *)str(LANG_BUFFER_STAT_RECORDER
),
162 lcd_puts(0, y
++, (unsigned char *)s
);
164 #ifdef HAVE_CHARGE_CTRL
165 if (charge_state
== 1)
166 snprintf(s
, sizeof(s
), (char *)str(LANG_BATTERY_CHARGE
));
167 else if (charge_state
== 2)
168 snprintf(s
, sizeof(s
), (char *)str(LANG_BATTERY_TOPOFF_CHARGE
));
169 else if (charge_state
== 3)
170 snprintf(s
, sizeof(s
), (char *)str(LANG_BATTERY_TRICKLE_CHARGE
));
173 if (battery_level() >= 0)
174 snprintf(s
, sizeof(s
), (char *)str(LANG_BATTERY_TIME
), battery_level(),
175 battery_time() / 60, battery_time() % 60);
177 strncpy(s
, "(n/a)", sizeof(s
));
178 lcd_puts(0, y
++, (unsigned char *)s
);
182 #ifdef HAVE_MULTIVOLUME
183 output_dyn_value(s1
, sizeof s1
, free
, kbyte_units
, true);
184 output_dyn_value(s2
, sizeof s2
, size
, kbyte_units
, true);
185 snprintf(s
, sizeof s
, "%s %s/%s", str(LANG_DISK_NAME_INTERNAL
),
188 output_dyn_value(s1
, sizeof s1
, size
, kbyte_units
, true);
189 snprintf(s
, sizeof s
, SIZE_FMT
, str(LANG_DISK_SIZE_INFO
), s1
);
191 lcd_puts(0, y
++, (unsigned char *)s
);
193 #ifdef HAVE_MULTIVOLUME
195 output_dyn_value(s1
, sizeof s1
, free2
, kbyte_units
, true);
196 output_dyn_value(s2
, sizeof s2
, size2
, kbyte_units
, true);
197 snprintf(s
, sizeof s
, "%s %s/%s", str(LANG_DISK_NAME_MMC
),
199 lcd_puts(0, y
++, (unsigned char *)s
);
202 output_dyn_value(s1
, sizeof s1
, free
, kbyte_units
, true);
203 snprintf(s
, sizeof s
, SIZE_FMT
, str(LANG_DISK_FREE_INFO
), s1
);
204 lcd_puts(0, y
++, (unsigned char *)s
);
209 /* Wait for a key to be pushed */
210 key
= button_get_w_tmo(HZ
*5);
217 case SETTINGS_CANCEL
:
230 if(default_event_handler(key
) == SYS_USB_CONNECTED
)
239 static bool plugin_browse(void)
241 return rockbox_browse(PLUGIN_DIR
, SHOW_PLUGINS
);
244 static bool custom_theme_browse(void)
246 return rockbox_browse(THEME_DIR
, SHOW_CFG
);
249 #ifdef HAVE_RECORDING
251 static bool recording_settings(void)
253 return recording_menu(false);
262 static const struct menu_item items
[] = {
263 { ID2P(LANG_RECORDING_MENU
), recording_screen
},
264 { ID2P(LANG_RECORDING_SETTINGS
), recording_settings
},
267 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
269 result
= menu_run(m
);
282 static const struct menu_item items
[] = {
283 { ID2P(LANG_INFO_MENU
), show_info
},
284 { ID2P(LANG_VERSION
), show_credits
},
286 { ID2P(LANG_DEBUG
), debug_menu
},
288 { ID2P(LANG_USB
), simulate_usb
},
289 #ifdef ROCKBOX_HAS_LOGF
290 {"logf", logfdisplay
},
291 {"logfdump", logfdump
},
296 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
298 result
= menu_run(m
);
304 #ifdef HAVE_LCD_CHARCELLS
305 static bool do_shutdown(void)
319 struct menu_item items
[11];
321 items
[i
].desc
= ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS
);
322 items
[i
++].function
= bookmark_mrb_load
;
324 items
[i
].desc
= ID2P(LANG_SOUND_SETTINGS
);
325 items
[i
++].function
= sound_menu
;
327 items
[i
].desc
= ID2P(LANG_GENERAL_SETTINGS
);
328 items
[i
++].function
= settings_menu
;
330 items
[i
].desc
= ID2P(LANG_MANAGE_MENU
);
331 items
[i
++].function
= manage_settings_menu
;
333 items
[i
].desc
= ID2P(LANG_CUSTOM_THEME
);
334 items
[i
++].function
= custom_theme_browse
;
337 if(radio_hardware_present()) {
338 items
[i
].desc
= ID2P(LANG_FM_RADIO
);
339 items
[i
++].function
= radio_screen
;
343 #ifdef HAVE_RECORDING
344 items
[i
].desc
= ID2P(LANG_RECORDING
);
345 items
[i
++].function
= rec_menu
;
348 items
[i
].desc
= ID2P(LANG_PLAYLIST_MENU
);
349 items
[i
++].function
= playlist_menu
;
351 items
[i
].desc
= ID2P(LANG_PLUGINS
);
352 items
[i
++].function
= plugin_browse
;
354 items
[i
].desc
= ID2P(LANG_INFO
);
355 items
[i
++].function
= info_menu
;
357 #ifdef HAVE_LCD_CHARCELLS
358 items
[i
].desc
= ID2P(LANG_SHUTDOWN
);
359 items
[i
++].function
= do_shutdown
;
362 m
=menu_init( items
, i
, NULL
, NULL
, NULL
, NULL
);
363 #ifdef HAVE_LCD_CHARCELLS
364 status_set_param(true);
366 result
= menu_run(m
);
367 #ifdef HAVE_LCD_CHARCELLS
368 status_set_param(false);
376 /* -----------------------------------------------------------------
377 * vim: et sw=4 ts=8 sts=4 tw=78