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"
56 #include "recording.h"
59 bool show_credits(void)
61 plugin_load("/.rockbox/rocks/credits.rock",NULL
);
66 extern bool simulate_usb(void);
69 #ifdef HAVE_LCD_CHARCELLS
70 #define SIZE_FMT "%s%s"
72 #define SIZE_FMT "%s %s"
78 unsigned long size
, free
;
79 long buflen
= ((audiobufend
- audiobuf
) * 2) / 2097; /* avoid overflow */
84 #ifdef HAVE_MULTIVOLUME
86 unsigned long size2
, free2
;
88 #ifdef HAVE_LCD_CHARCELLS
92 const unsigned char *kbyte_units
[] = {
104 fat_size( IF_MV2(0,) &size
, &free
);
105 #ifdef HAVE_MULTIVOLUME
106 if (fat_ismounted(1))
107 fat_size( 1, &size2
, &free2
);
112 if (global_settings
.talk_menu
)
113 { /* say whatever is reasonable, no real connection to the screen */
114 bool enqueue
= false; /* enqueue all but the first */
115 if (battery_level() >= 0)
117 talk_id(LANG_BATTERY_TIME
, enqueue
);
119 talk_value(battery_level(), UNIT_PERCENT
, true);
120 #if CONFIG_CHARGING >= CHARGING_MONITOR
121 if (charge_state
== CHARGING
)
122 talk_id(LANG_BATTERY_CHARGE
, true);
123 else if (charge_state
== TOPOFF
)
124 talk_id(LANG_BATTERY_TOPOFF_CHARGE
, true);
125 else if (charge_state
== TRICKLE
)
126 talk_id(LANG_BATTERY_TRICKLE_CHARGE
, true);
130 talk_id(LANG_DISK_FREE_INFO
, enqueue
);
131 #ifdef HAVE_MULTIVOLUME
132 talk_id(LANG_DISK_NAME_INTERNAL
, true);
133 output_dyn_value(NULL
, 0, free
, kbyte_units
, true);
136 talk_id(LANG_DISK_NAME_MMC
, true);
137 output_dyn_value(NULL
, 0, free2
, kbyte_units
, true);
140 output_dyn_value(NULL
, 0, free
, kbyte_units
, true);
145 struct tm
* tm
= get_time();
146 talk_id(VOICE_CURRENT_TIME
, true);
147 talk_value(tm
->tm_hour
, UNIT_HOUR
, true);
148 talk_value(tm
->tm_min
, UNIT_MIN
, true);
149 talk_value(tm
->tm_sec
, UNIT_SEC
, true);
150 talk_id(LANG_MONTH_JANUARY
+ tm
->tm_mon
, true);
151 talk_number(tm
->tm_mday
, true);
152 talk_number(1900 + tm
->tm_year
, true);
161 screens
[i
].clear_display();
162 #ifdef HAVE_LCD_BITMAP
163 screens
[i
].puts(0, y
, str(LANG_ROCKBOX_INFO
));
166 #ifdef HAVE_LCD_BITMAP
170 #ifdef HAVE_LCD_CHARCELLS
174 int integer
= buflen
/ 1000;
175 int decimal
= buflen
% 1000;
177 #ifdef HAVE_LCD_CHARCELLS
178 snprintf(s
, sizeof(s
), (char *)str(LANG_BUFFER_STAT_PLAYER
),
181 snprintf(s
, sizeof(s
), (char *)str(LANG_BUFFER_STAT_RECORDER
),
185 screens
[i
].puts_scroll(0, y
, (unsigned char *)s
);
187 #if CONFIG_CHARGING == CHARGING_CONTROL
188 if (charge_state
== CHARGING
)
189 snprintf(s
, sizeof(s
), (char *)str(LANG_BATTERY_CHARGE
));
190 else if (charge_state
== TOPOFF
)
191 snprintf(s
, sizeof(s
), (char *)str(LANG_BATTERY_TOPOFF_CHARGE
));
192 else if (charge_state
== TRICKLE
)
193 snprintf(s
, sizeof(s
), (char *)str(LANG_BATTERY_TRICKLE_CHARGE
));
196 if (battery_level() >= 0)
197 snprintf(s
, sizeof(s
), (char *)str(LANG_BATTERY_TIME
), battery_level(),
198 battery_time() / 60, battery_time() % 60);
200 strncpy(s
, "(n/a)", sizeof(s
));
202 screens
[i
].puts_scroll(0, y
, (unsigned char *)s
);
206 #ifdef HAVE_LCD_CHARCELLS
210 #ifdef HAVE_MULTIVOLUME
211 output_dyn_value(s1
, sizeof s1
, free
, kbyte_units
, true);
212 output_dyn_value(s2
, sizeof s2
, size
, kbyte_units
, true);
213 snprintf(s
, sizeof s
, "%s %s/%s", str(LANG_DISK_NAME_INTERNAL
),
216 screens
[i
].puts_scroll(0, y
, (unsigned char *)s
);
220 output_dyn_value(s1
, sizeof s1
, free2
, kbyte_units
, true);
221 output_dyn_value(s2
, sizeof s2
, size2
, kbyte_units
, true);
222 snprintf(s
, sizeof s
, "%s %s/%s", str(LANG_DISK_NAME_MMC
),
225 screens
[i
].puts_scroll(0, y
, (unsigned char *)s
);
229 output_dyn_value(s1
, sizeof s1
, size
, kbyte_units
, true);
230 snprintf(s
, sizeof s
, SIZE_FMT
, str(LANG_DISK_SIZE_INFO
), s1
);
232 screens
[i
].puts_scroll(0, y
, (unsigned char *)s
);
234 output_dyn_value(s1
, sizeof s1
, free
, kbyte_units
, true);
235 snprintf(s
, sizeof s
, SIZE_FMT
, str(LANG_DISK_FREE_INFO
), s1
);
237 screens
[i
].puts_scroll(0, y
, (unsigned char *)s
);
242 #if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
247 /* Wait for a key to be pushed */
248 key
= get_action(CONTEXT_MAINMENU
,HZ
*5);
251 case ACTION_STD_CANCEL
:
255 #ifdef HAVE_LCD_CHARCELLS
256 case ACTION_STD_NEXT
:
257 case ACTION_STD_PREV
:
258 page
= (page
== 0) ? 1 : 0;
264 gui_syncsplash(0, true, str(LANG_DIRCACHE_BUILDING
));
265 fat_recalc_free(IF_MV(0));
266 #ifdef HAVE_MULTIVOLUME
267 if (fat_ismounted(1))
275 if (default_event_handler(key
) == SYS_USB_CONNECTED
)
280 action_signalscreenchange();
284 static bool plugin_browse(void)
286 return rockbox_browse(PLUGIN_DIR
, SHOW_PLUGINS
);
289 static bool custom_theme_browse(void)
291 return rockbox_browse(THEME_DIR
, SHOW_CFG
);
294 #ifdef HAVE_RECORDING
296 static bool rec_menu_recording_screen(void)
298 return recording_screen(false);
301 static bool recording_settings(void)
304 #ifdef HAVE_FMRADIO_IN
305 int rec_source
= global_settings
.rec_source
;
308 ret
= recording_menu(false);
310 #ifdef HAVE_FMRADIO_IN
311 if (rec_source
!= global_settings
.rec_source
)
313 if (rec_source
== AUDIO_SRC_FMRADIO
)
315 /* If AUDIO_SRC_FMRADIO was selected from something else,
316 the recording screen will start the radio */
329 static const struct menu_item items
[] = {
330 { ID2P(LANG_RECORDING_MENU
), rec_menu_recording_screen
},
331 { ID2P(LANG_RECORDING_SETTINGS
), recording_settings
},
334 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
336 result
= menu_run(m
);
349 static const struct menu_item items
[] = {
350 { ID2P(LANG_INFO_MENU
), show_info
},
351 { ID2P(LANG_VERSION
), show_credits
},
352 { ID2P(LANG_DEBUG
), debug_menu
},
354 { ID2P(LANG_USB
), simulate_usb
},
355 #ifdef ROCKBOX_HAS_LOGF
356 {"logf", logfdisplay
},
357 {"logfdump", logfdump
},
362 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
364 result
= menu_run(m
);
370 #ifdef HAVE_LCD_CHARCELLS
371 static bool do_shutdown(void)
385 struct menu_item items
[11];
387 items
[i
].desc
= ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS
);
388 items
[i
++].function
= bookmark_mrb_load
;
390 items
[i
].desc
= ID2P(LANG_SOUND_SETTINGS
);
391 items
[i
++].function
= sound_menu
;
393 items
[i
].desc
= ID2P(LANG_GENERAL_SETTINGS
);
394 items
[i
++].function
= settings_menu
;
396 items
[i
].desc
= ID2P(LANG_MANAGE_MENU
);
397 items
[i
++].function
= manage_settings_menu
;
399 items
[i
].desc
= ID2P(LANG_CUSTOM_THEME
);
400 items
[i
++].function
= custom_theme_browse
;
403 if(radio_hardware_present()) {
404 items
[i
].desc
= ID2P(LANG_FM_RADIO
);
405 items
[i
++].function
= radio_screen
;
409 #ifdef HAVE_RECORDING
410 items
[i
].desc
= ID2P(LANG_RECORDING
);
411 items
[i
++].function
= rec_menu
;
414 items
[i
].desc
= ID2P(LANG_PLAYLIST_MENU
);
415 items
[i
++].function
= playlist_menu
;
417 items
[i
].desc
= ID2P(LANG_PLUGINS
);
418 items
[i
++].function
= plugin_browse
;
420 items
[i
].desc
= ID2P(LANG_INFO
);
421 items
[i
++].function
= info_menu
;
423 #ifdef HAVE_LCD_CHARCELLS
424 items
[i
].desc
= ID2P(LANG_SHUTDOWN
);
425 items
[i
++].function
= do_shutdown
;
428 m
=menu_init( items
, i
, NULL
, NULL
, NULL
, NULL
);
429 #ifdef HAVE_LCD_CHARCELLS
430 status_set_param(true);
432 result
= menu_run(m
);
433 #ifdef HAVE_LCD_CHARCELLS
434 status_set_param(false);
442 /* -----------------------------------------------------------------
443 * vim: et sw=4 ts=8 sts=4 tw=78