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
), str(LANG_BUFFER_STAT_PLAYER
),
159 snprintf(s
, sizeof(s
), str(LANG_BUFFER_STAT_RECORDER
),
164 #ifdef HAVE_CHARGE_CTRL
165 if (charge_state
== 1)
166 snprintf(s
, sizeof(s
), str(LANG_BATTERY_CHARGE
));
167 else if (charge_state
== 2)
168 snprintf(s
, sizeof(s
), str(LANG_BATTERY_TOPOFF_CHARGE
));
169 else if (charge_state
== 3)
170 snprintf(s
, sizeof(s
), str(LANG_BATTERY_TRICKLE_CHARGE
));
173 if (battery_level() >= 0)
174 snprintf(s
, sizeof(s
), str(LANG_BATTERY_TIME
), battery_level(),
175 battery_time() / 60, battery_time() % 60);
177 strncpy(s
, "(n/a)", sizeof(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
);
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
),
202 output_dyn_value(s1
, sizeof s1
, free
, kbyte_units
, true);
203 snprintf(s
, sizeof s
, SIZE_FMT
, str(LANG_DISK_FREE_INFO
), s1
);
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 #ifdef HAVE_RECORDING
246 static bool recording_settings(void)
248 return recording_menu(false);
257 static const struct menu_item items
[] = {
258 { ID2P(LANG_RECORDING_MENU
), recording_screen
},
259 { ID2P(LANG_RECORDING_SETTINGS
), recording_settings
},
262 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
264 result
= menu_run(m
);
277 static const struct menu_item items
[] = {
278 { ID2P(LANG_INFO_MENU
), show_info
},
279 { ID2P(LANG_VERSION
), show_credits
},
281 { ID2P(LANG_DEBUG
), debug_menu
},
283 { ID2P(LANG_USB
), simulate_usb
},
284 #ifdef ROCKBOX_HAS_LOGF
285 {"logf", logfdisplay
},
286 {"logfdump", logfdump
},
291 m
=menu_init( items
, sizeof(items
) / sizeof(*items
), NULL
,
293 result
= menu_run(m
);
299 #ifdef HAVE_LCD_CHARCELLS
300 static bool do_shutdown(void)
314 struct menu_item items
[10];
316 items
[i
].desc
= ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS
);
317 items
[i
++].function
= bookmark_mrb_load
;
319 items
[i
].desc
= ID2P(LANG_SOUND_SETTINGS
);
320 items
[i
++].function
= sound_menu
;
322 items
[i
].desc
= ID2P(LANG_GENERAL_SETTINGS
);
323 items
[i
++].function
= settings_menu
;
325 items
[i
].desc
= ID2P(LANG_MANAGE_MENU
);
326 items
[i
++].function
= manage_settings_menu
;
329 if(radio_hardware_present()) {
330 items
[i
].desc
= ID2P(LANG_FM_RADIO
);
331 items
[i
++].function
= radio_screen
;
335 #ifdef HAVE_RECORDING
336 items
[i
].desc
= ID2P(LANG_RECORDING
);
337 items
[i
++].function
= rec_menu
;
340 items
[i
].desc
= ID2P(LANG_PLAYLIST_MENU
);
341 items
[i
++].function
= playlist_menu
;
343 items
[i
].desc
= ID2P(LANG_PLUGINS
);
344 items
[i
++].function
= plugin_browse
;
346 items
[i
].desc
= ID2P(LANG_INFO
);
347 items
[i
++].function
= info_menu
;
349 #ifdef HAVE_LCD_CHARCELLS
350 items
[i
].desc
= ID2P(LANG_SHUTDOWN
);
351 items
[i
++].function
= do_shutdown
;
354 m
=menu_init( items
, i
, NULL
, NULL
, NULL
, NULL
);
355 #ifdef HAVE_LCD_CHARCELLS
356 status_set_param(true);
358 result
= menu_run(m
);
359 #ifdef HAVE_LCD_CHARCELLS
360 status_set_param(false);
368 /* -----------------------------------------------------------------
369 * vim: et sw=4 ts=8 sts=4 tw=78