blob: 00959d074de8715e9751a79d18db95d3a25c6637 [file] [log] [blame]
Jonathan Gordon4718a1e2007-02-08 04:33:41 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Jonathan Gordon4e73b532007-02-13 00:32:17 +00008 * $Id$
Jonathan Gordon4718a1e2007-02-08 04:33:41 +00009 *
10 * Copyright (C) 2007 Jonathan Gordon
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
23#include <stddef.h>
24#include <limits.h>
25#include "config.h"
Jonathan Gordone56f8e92007-02-15 04:41:37 +000026#include "string.h"
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000027#include "lang.h"
28#include "action.h"
29#include "settings.h"
Michael Sevakis3157e132008-12-24 16:58:41 +000030#include "power.h"
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000031#include "powermgmt.h"
32#include "menu.h"
Jonathan Gordonc9397742007-04-12 12:14:54 +000033#include "misc.h"
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000034#include "exported_menus.h"
35#include "tree.h"
Thomas Martitz43203102010-06-06 12:56:23 +000036#include "storage.h"
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000037#ifdef HAVE_RECORDING
38#include "recording.h"
39#endif
Jonathan Gordone56f8e92007-02-15 04:41:37 +000040#include "yesno.h"
41#include "keyboard.h"
42#include "screens.h"
43#include "plugin.h"
44#include "talk.h"
Jonathan Gordon75bf31f2007-02-15 04:49:11 +000045#include "splash.h"
46#include "debug_menu.h"
Jonathan Gordon66f42ac2007-06-07 06:05:08 +000047#include "version.h"
Jonathan Gordond7d6b782007-10-07 08:12:01 +000048#include "time.h"
Thomas Martitz3b75c862009-08-03 15:06:30 +000049#include "wps.h"
Jonathan Gordon2d31d772010-07-29 12:37:48 +000050#include "skin_buffer.h"
Michael Sevakis7d1a47c2013-08-05 22:02:45 -040051#include "disk.h"
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000052
Steve Bavinb76b5b92007-10-24 14:16:02 +000053static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG};
Jonathan Gordone56f8e92007-02-15 04:41:37 +000054
55/***********************************/
56/* MANAGE SETTINGS MENU */
57
58static int reset_settings(void)
59{
Nils Wallménius33c44462008-04-26 09:30:24 +000060 static const char *lines[]={ID2P(LANG_RESET_ASK)};
61 static const char *yes_lines[]={
62 ID2P(LANG_SETTINGS),
Nils Wallménius5b769362007-08-06 13:08:36 +000063 ID2P(LANG_RESET_DONE_CLEAR)
Jonathan Gordone56f8e92007-02-15 04:41:37 +000064 };
Nils Wallménius33c44462008-04-26 09:30:24 +000065 static const char *no_lines[]={
66 ID2P(LANG_SETTINGS),
67 ID2P(LANG_CANCEL)
68 };
69 static const struct text_message message={lines, 1};
70 static const struct text_message yes_message={yes_lines, 2};
71 static const struct text_message no_message={no_lines, 2};
Jonathan Gordone56f8e92007-02-15 04:41:37 +000072
73 switch(gui_syncyesno_run(&message, &yes_message, &no_message))
74 {
75 case YESNO_YES:
76 settings_reset();
Jonathan Gordon8a4549d2007-02-21 13:37:36 +000077 settings_save();
Magnus Holmgrena14f4ac2010-03-06 12:14:12 +000078 settings_apply(true);
Jonathan Gordon4c6b3552010-02-26 08:01:41 +000079 settings_apply_skins();
Jonathan Gordone56f8e92007-02-15 04:41:37 +000080 break;
81 case YESNO_NO:
82 break;
83 case YESNO_USB:
84 return 1;
85 }
86 return 0;
87}
88static int write_settings_file(void* param)
89{
Jens Arnold1f1da8e2007-02-15 21:07:10 +000090 return settings_save_config((intptr_t)param);
Jonathan Gordone56f8e92007-02-15 04:41:37 +000091}
92
Jonathan Gordondaf66942007-03-17 12:33:34 +000093MENUITEM_FUNCTION(browse_configs, MENU_FUNC_USEPARAM, ID2P(LANG_CUSTOM_CFG),
Jonathan Gordone54d8e12007-03-18 07:03:43 +000094 browse_folder, (void*)&config, NULL, Icon_NOICON);
Jonathan Gordondaf66942007-03-17 12:33:34 +000095MENUITEM_FUNCTION(save_settings_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_SETTINGS),
Jonathan Gordone54d8e12007-03-18 07:03:43 +000096 write_settings_file, (void*)SETTINGS_SAVE_ALL, NULL, Icon_NOICON);
Jonathan Gordondaf66942007-03-17 12:33:34 +000097MENUITEM_FUNCTION(save_theme_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_THEME),
Jonathan Gordone54d8e12007-03-18 07:03:43 +000098 write_settings_file, (void*)SETTINGS_SAVE_THEME, NULL, Icon_NOICON);
Jonathan Gordonb8bc45d2007-12-24 22:35:31 +000099MENUITEM_FUNCTION(save_sound_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_SOUND),
100 write_settings_file, (void*)SETTINGS_SAVE_SOUND, NULL, Icon_NOICON);
Jonathan Gordondaf66942007-03-17 12:33:34 +0000101MENUITEM_FUNCTION(reset_settings_item, 0, ID2P(LANG_RESET),
Jonathan Gordone54d8e12007-03-18 07:03:43 +0000102 reset_settings, NULL, NULL, Icon_NOICON);
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000103
Jonathan Gordon02a87172007-03-03 13:52:14 +0000104MAKE_MENU(manage_settings, ID2P(LANG_MANAGE_MENU), NULL, Icon_Config,
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000105 &browse_configs, &reset_settings_item,
Jonathan Gordonb8bc45d2007-12-24 22:35:31 +0000106 &save_settings_item, &save_sound_item, &save_theme_item);
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000107/* MANAGE SETTINGS MENU */
108/**********************************/
109
110/***********************************/
111/* INFO MENU */
112
Thomas Martitz9c0b2472010-08-01 16:15:27 +0000113
William Wilgusdd40c462018-10-15 23:04:04 -0400114static int show_credits(void)
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000115{
Thomas Martitz9c0b2472010-08-01 16:15:27 +0000116 char credits[MAX_PATH] = { '\0' };
117 snprintf(credits, MAX_PATH, "%s/credits.rock", VIEWERS_DIR);
118 if (plugin_load(credits, NULL) != PLUGIN_OK)
Jonathan Gordonc9397742007-04-12 12:14:54 +0000119 {
120 /* show the rockbox logo and version untill a button is pressed */
Jonathan Gordonc9397742007-04-12 12:14:54 +0000121 show_logo();
Jonathan Gordone385ee12008-12-31 05:59:26 +0000122 while (IS_SYSEVENT(get_action(CONTEXT_STD, TIMEOUT_BLOCK)))
123 ;
Jonathan Gordonc9397742007-04-12 12:14:54 +0000124 }
William Wilgusdd40c462018-10-15 23:04:04 -0400125 return 0;
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000126}
127
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000128#ifdef HAVE_LCD_CHARCELLS
129#define SIZE_FMT "%s%s"
130#else
131#define SIZE_FMT "%s %s"
132#endif
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000133struct info_data
134
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000135{
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000136 bool new_data;
137 unsigned long size;
138 unsigned long free;
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000139#ifdef HAVE_MULTIVOLUME
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000140 unsigned long size2;
141 unsigned long free2;
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000142#endif
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000143};
Stéphane Doyonf6b404b2007-11-03 03:38:54 +0000144enum infoscreenorder
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000145{
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000146 INFO_BATTERY = 0,
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000147 INFO_DISK1, /* capacity or internal capacity/free on hotswap */
148 INFO_DISK2, /* free space or external capacity/free on hotswap */
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000149 INFO_BUFFER,
Solomon Peachy4beafe12019-02-08 19:59:57 -0500150#ifdef HAVE_RECORDING
151 INFO_REC_DIR,
152#endif
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000153 INFO_VERSION,
Solomon Peachy4beafe12019-02-08 19:59:57 -0500154#if CONFIG_RTC
155 INFO_DATE,
156 INFO_TIME,
157#endif
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000158 INFO_COUNT
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000159};
160
Nils Wallménius3200d042009-08-20 16:47:44 +0000161static const char* info_getname(int selected_item, void *data,
162 char *buffer, size_t buffer_len)
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000163{
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000164 struct info_data *info = (struct info_data*)data;
Solomon Peachy4beafe12019-02-08 19:59:57 -0500165#if CONFIG_RTC
166 struct tm *tm;
167#endif
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000168 char s1[32];
Jonathan Gordon9e07ef22011-11-15 14:11:08 +0000169#if defined(HAVE_MULTIVOLUME)
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000170 char s2[32];
Jonathan Gordon97857322010-11-04 10:15:33 +0000171#endif
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000172 if (info->new_data)
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000173 {
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400174 volume_size(IF_MV(0,) &info->size, &info->free);
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000175#ifdef HAVE_MULTIVOLUME
Thomas Martitzcbc57af2014-02-07 18:18:16 +0100176#ifndef APPLICATION
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400177 volume_size(1, &info->size2, &info->free2);
178#else
179 info->size2 = 0;
Thomas Martitzcbc57af2014-02-07 18:18:16 +0100180#endif
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400181
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000182#endif
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000183 info->new_data = false;
184 }
185 switch (selected_item)
186 {
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000187 case INFO_VERSION:
Nils Wallménius68489612008-04-09 15:25:17 +0000188 snprintf(buffer, buffer_len, "%s: %s",
Rafaël Carré5d236b22010-05-27 09:41:46 +0000189 str(LANG_VERSION), rbversion);
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000190 break;
Jonathan Gordonc7fec132008-12-01 09:28:14 +0000191
Solomon Peachy4beafe12019-02-08 19:59:57 -0500192#if CONFIG_RTC
193 case INFO_TIME:
194 tm = get_time();
195 if (valid_time(tm))
196 {
197 snprintf(buffer, buffer_len, "%02d:%02d:%02d %s",
198 global_settings.timeformat == 0 ? tm->tm_hour :
199 ((tm->tm_hour + 11) % 12) + 1,
200 tm->tm_min,
201 tm->tm_sec,
202 global_settings.timeformat == 0 ? "" :
203 tm->tm_hour>11 ? "P" : "A");
204 }
205 else
206 {
207 snprintf(buffer, buffer_len, "%s", "--:--:--");
208 }
209 break;
210 case INFO_DATE:
211 tm = get_time();
212 if (valid_time(tm))
213 {
214 snprintf(buffer, buffer_len, "%s %d %d",
215 str(LANG_MONTH_JANUARY + tm->tm_mon),
216 tm->tm_mday,
217 tm->tm_year+1900);
218 }
219 else
220 {
221 snprintf(buffer, buffer_len, "%s", str(LANG_UNKNOWN));
222 }
223 break;
224#endif
225
226#ifdef HAVE_RECORDING
227 case INFO_REC_DIR:
228 snprintf(buffer, buffer_len, "%s %s", str(LANG_REC_DIR), global_settings.rec_directory);
229 break;
230#endif
231
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000232 case INFO_BUFFER: /* buffer */
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000233 {
William Wilgus62a5ed42018-12-09 12:09:40 -0600234 long kib = audio_buffer_size() >> 10; /* to KiB */
235 output_dyn_value(s1, sizeof(s1), kib, kibyte_units, 3, true);
Bertrik Sikkend86255b2008-08-03 22:02:11 +0000236 snprintf(buffer, buffer_len, "%s %s", str(LANG_BUFFER_STAT), s1);
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000237 }
238 break;
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000239 case INFO_BATTERY: /* battery */
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000240#if CONFIG_CHARGING == CHARGING_SIMPLE
Michael Sevakis4118de42009-01-28 20:53:50 +0000241 /* Only know if plugged */
242 if (charger_inserted())
Nils Wallménius3200d042009-08-20 16:47:44 +0000243 return str(LANG_BATTERY_CHARGE);
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000244 else
245#elif CONFIG_CHARGING >= CHARGING_MONITOR
Michael Sevakis4118de42009-01-28 20:53:50 +0000246#ifdef ARCHOS_RECORDER
247 /* Report the particular algorithm state */
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000248 if (charge_state == CHARGING)
Nils Wallménius3200d042009-08-20 16:47:44 +0000249 return str(LANG_BATTERY_CHARGE);
Michael Sevakis4118de42009-01-28 20:53:50 +0000250 else if (charge_state == TOPOFF)
Nils Wallménius3200d042009-08-20 16:47:44 +0000251 return str(LANG_BATTERY_TOPOFF_CHARGE);
Michael Sevakis3157e132008-12-24 16:58:41 +0000252 else if (charge_state == TRICKLE)
Nils Wallménius3200d042009-08-20 16:47:44 +0000253 return str(LANG_BATTERY_TRICKLE_CHARGE);
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000254 else
Michael Sevakis4118de42009-01-28 20:53:50 +0000255#else /* !ARCHOS_RECORDER */
256 /* Go by what power management reports */
257 if (charging_state())
Nils Wallménius3200d042009-08-20 16:47:44 +0000258 return str(LANG_BATTERY_CHARGE);
Michael Sevakis4118de42009-01-28 20:53:50 +0000259 else
Michael Sevakis3157e132008-12-24 16:58:41 +0000260#endif /* ARCHOS_RECORDER */
261#endif /* CONFIG_CHARGING = */
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000262 if (battery_level() >= 0)
Nils Wallménius3200d042009-08-20 16:47:44 +0000263 snprintf(buffer, buffer_len, str(LANG_BATTERY_TIME),
Nils Wallménius68489612008-04-09 15:25:17 +0000264 battery_level(), battery_time() / 60, battery_time() % 60);
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000265 else
Thomas Martitzc1bd9b02012-01-03 23:44:38 +0000266 return "Battery n/a"; /* translating worth it? */
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000267 break;
Steve Bavinb76b5b92007-10-24 14:16:02 +0000268 case INFO_DISK1: /* disk usage 1 */
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000269#ifdef HAVE_MULTIVOLUME
William Wilgus62a5ed42018-12-09 12:09:40 -0600270 output_dyn_value(s1, sizeof s1, info->free, kibyte_units, 3, true);
271 output_dyn_value(s2, sizeof s2, info->size, kibyte_units, 3, true);
Nils Wallménius68489612008-04-09 15:25:17 +0000272 snprintf(buffer, buffer_len, "%s %s/%s", str(LANG_DISK_NAME_INTERNAL),
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000273 s1, s2);
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000274#else
William Wilgus62a5ed42018-12-09 12:09:40 -0600275 output_dyn_value(s1, sizeof s1, info->free, kibyte_units, 3, true);
Nils Wallménius68489612008-04-09 15:25:17 +0000276 snprintf(buffer, buffer_len, SIZE_FMT, str(LANG_DISK_FREE_INFO), s1);
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000277#endif
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000278 break;
Steve Bavinb76b5b92007-10-24 14:16:02 +0000279 case INFO_DISK2: /* disk usage 2 */
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000280#ifdef HAVE_MULTIVOLUME
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000281 if (info->size2)
282 {
William Wilgus62a5ed42018-12-09 12:09:40 -0600283 output_dyn_value(s1, sizeof s1, info->free2, kibyte_units, 3, true);
284 output_dyn_value(s2, sizeof s2, info->size2, kibyte_units, 3, true);
Nils Wallménius68489612008-04-09 15:25:17 +0000285 snprintf(buffer, buffer_len, "%s %s/%s", str(LANG_DISK_NAME_MMC),
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000286 s1, s2);
287 }
288 else
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000289 {
Nils Wallménius68489612008-04-09 15:25:17 +0000290 snprintf(buffer, buffer_len, "%s %s", str(LANG_DISK_NAME_MMC),
Stéphane Doyonf6b404b2007-11-03 03:38:54 +0000291 str(LANG_NOT_PRESENT));
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000292 }
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000293#else
William Wilgus62a5ed42018-12-09 12:09:40 -0600294 output_dyn_value(s1, sizeof s1, info->size, kibyte_units, 3, true);
Nils Wallménius68489612008-04-09 15:25:17 +0000295 snprintf(buffer, buffer_len, SIZE_FMT, str(LANG_DISK_SIZE_INFO), s1);
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000296#endif
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000297 break;
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000298 }
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000299 return buffer;
300}
Stéphane Doyonf6b404b2007-11-03 03:38:54 +0000301
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000302static int info_speak_item(int selected_item, void * data)
303{
304 struct info_data *info = (struct info_data*)data;
Nils Wallménius8dca9302008-04-09 16:01:40 +0000305
Solomon Peachy4beafe12019-02-08 19:59:57 -0500306#if CONFIG_RTC
307 struct tm *tm;
308#endif
309
310 if (info->new_data)
311 {
312 volume_size(IF_MV(0,) &info->size, &info->free);
313#ifdef HAVE_MULTIVOLUME
314 if (volume_ismounted(1))
315 volume_size(1, &info->size2, &info->free2);
316 else
317 info->size2 = 0;
318#endif
319 info->new_data = false;
320 }
321
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000322 switch (selected_item)
323 {
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000324 case INFO_VERSION: /* version */
Steve Bavin072a3c52007-10-24 12:32:12 +0000325 talk_id(LANG_VERSION, false);
Rafaël Carré5d236b22010-05-27 09:41:46 +0000326 talk_spell(rbversion, true);
Steve Bavin072a3c52007-10-24 12:32:12 +0000327 break;
Jonathan Gordonc7fec132008-12-01 09:28:14 +0000328
Solomon Peachy4beafe12019-02-08 19:59:57 -0500329#if CONFIG_RTC
330 case INFO_TIME:
331 tm = get_time();
332 talk_id(VOICE_CURRENT_TIME, false);
333 if (valid_time(tm))
334 {
335 talk_time(tm, true);
336 }
337 else
338 {
339 talk_id(LANG_UNKNOWN, true);
340 }
341 break;
342 case INFO_DATE:
343 tm = get_time();
344 if (valid_time(tm))
345 {
346 talk_date(get_time(), true);
347 }
348 else
349 {
350 talk_id(LANG_UNKNOWN, true);
351 }
352 break;
353#endif
354
355#ifdef HAVE_RECORDING
356 case INFO_REC_DIR:
357 talk_id(LANG_REC_DIR, false);
358 if (global_settings.rec_directory && global_settings.rec_directory[0])
359 {
360 long *pathsep = NULL;
361 char rec_directory[MAX_PATHNAME+1];
362 char *s;
363 strcpy(rec_directory, global_settings.rec_directory);
364 s = rec_directory;
365 if ((strlen(s) > 1) && (s[strlen(s) - 1] == '/'))
366 s[strlen(s) - 1] = 0;
367 while (s)
368 {
369 s = strchr(s + 1, '/');
370 if (s)
371 s[0] = 0;
372 talk_dir_or_spell(rec_directory, pathsep, true);
373 if (s)
374 s[0] = '/';
375 pathsep = TALK_IDARRAY(VOICE_CHAR_SLASH);
376 }
377 }
378 break;
379#endif
380
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000381 case INFO_BUFFER: /* buffer */
Steve Bavin072a3c52007-10-24 12:32:12 +0000382 {
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000383 talk_id(LANG_BUFFER_STAT, false);
William Wilgus62a5ed42018-12-09 12:09:40 -0600384 long kib = audio_buffer_size() >> 10; /* to KiB */
385 output_dyn_value(NULL, 0, kib, kibyte_units, 3, true);
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000386 break;
Steve Bavin072a3c52007-10-24 12:32:12 +0000387 }
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000388 case INFO_BATTERY: /* battery */
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000389#if CONFIG_CHARGING == CHARGING_SIMPLE
Michael Sevakis4118de42009-01-28 20:53:50 +0000390 /* Only know if plugged */
Michael Sevakis3157e132008-12-24 16:58:41 +0000391 if (charger_inserted())
Solomon Peachy4beafe12019-02-08 19:59:57 -0500392 {
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000393 talk_id(LANG_BATTERY_CHARGE, true);
Solomon Peachy4beafe12019-02-08 19:59:57 -0500394 if (battery_level() >= 0)
395 talk_value(battery_level(), UNIT_PERCENT, true);
396 }
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000397 else
398#elif CONFIG_CHARGING >= CHARGING_MONITOR
Michael Sevakis4118de42009-01-28 20:53:50 +0000399#ifdef ARCHOS_RECORDER
400 /* Report the particular algorithm state */
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000401 if (charge_state == CHARGING)
Solomon Peachy4beafe12019-02-08 19:59:57 -0500402 {
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000403 talk_id(LANG_BATTERY_CHARGE, true);
Solomon Peachy4beafe12019-02-08 19:59:57 -0500404 if (battery_level() >= 0)
405 talk_value(battery_level(), UNIT_PERCENT, true);
406 }
Michael Sevakis4118de42009-01-28 20:53:50 +0000407 else if (charge_state == TOPOFF)
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000408 talk_id(LANG_BATTERY_TOPOFF_CHARGE, true);
Michael Sevakis3157e132008-12-24 16:58:41 +0000409 else if (charge_state == TRICKLE)
Solomon Peachy4beafe12019-02-08 19:59:57 -0500410 {
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000411 talk_id(LANG_BATTERY_TRICKLE_CHARGE, true);
Solomon Peachy4beafe12019-02-08 19:59:57 -0500412 if (battery_level() >= 0)
413 talk_value(battery_level(), UNIT_PERCENT, true);
414 }
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000415 else
Michael Sevakis4118de42009-01-28 20:53:50 +0000416#else /* !ARCHOS_RECORDER */
417 /* Go by what power management reports */
418 if (charging_state())
Solomon Peachy4beafe12019-02-08 19:59:57 -0500419 {
Michael Sevakis4118de42009-01-28 20:53:50 +0000420 talk_id(LANG_BATTERY_CHARGE, true);
Solomon Peachy4beafe12019-02-08 19:59:57 -0500421 if (battery_level() >= 0)
422 talk_value(battery_level(), UNIT_PERCENT, true);
423 }
Michael Sevakis4118de42009-01-28 20:53:50 +0000424 else
Michael Sevakis3157e132008-12-24 16:58:41 +0000425#endif /* ARCHOS_RECORDER */
426#endif /* CONFIG_CHARGING = */
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000427 if (battery_level() >= 0)
428 {
Thomas Martitzc1bd9b02012-01-03 23:44:38 +0000429 int time_left = battery_time();
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000430 talk_id(LANG_BATTERY_TIME, false);
431 talk_value(battery_level(), UNIT_PERCENT, true);
Thomas Martitzc1bd9b02012-01-03 23:44:38 +0000432 if (time_left >= 0)
433 talk_value(time_left * 60, UNIT_TIME, true);
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000434 }
Stéphane Doyon69f88a52007-11-03 04:13:25 +0000435 else talk_id(VOICE_BLANK, false);
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000436 break;
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000437 case INFO_DISK1: /* disk 1 */
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000438#ifdef HAVE_MULTIVOLUME
Nils Wallménius79f19b92009-10-17 13:40:42 +0000439 talk_ids(false, LANG_DISK_NAME_INTERNAL, LANG_DISK_FREE_INFO);
William Wilgus62a5ed42018-12-09 12:09:40 -0600440 output_dyn_value(NULL, 0, info->free, kibyte_units, 3, true);
Stéphane Doyonf6b404b2007-11-03 03:38:54 +0000441 talk_id(LANG_DISK_SIZE_INFO, true);
William Wilgus62a5ed42018-12-09 12:09:40 -0600442 output_dyn_value(NULL, 0, info->size, kibyte_units, 3, true);
Stéphane Doyonf6b404b2007-11-03 03:38:54 +0000443#else
444 talk_id(LANG_DISK_FREE_INFO, false);
William Wilgus62a5ed42018-12-09 12:09:40 -0600445 output_dyn_value(NULL, 0, info->free, kibyte_units, 3, true);
Stéphane Doyonf6b404b2007-11-03 03:38:54 +0000446#endif
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000447 break;
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000448 case INFO_DISK2: /* disk 2 */
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000449#ifdef HAVE_MULTIVOLUME
Stéphane Doyonf6b404b2007-11-03 03:38:54 +0000450 talk_id(LANG_DISK_NAME_MMC, false);
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000451 if (info->size2)
452 {
Stéphane Doyonf6b404b2007-11-03 03:38:54 +0000453 talk_id(LANG_DISK_FREE_INFO, true);
William Wilgus62a5ed42018-12-09 12:09:40 -0600454 output_dyn_value(NULL, 0, info->free2, kibyte_units, 3, true);
Stéphane Doyonf6b404b2007-11-03 03:38:54 +0000455 talk_id(LANG_DISK_SIZE_INFO, true);
William Wilgus62a5ed42018-12-09 12:09:40 -0600456 output_dyn_value(NULL, 0, info->size2, kibyte_units, 3, true);
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000457 }
Stéphane Doyonf6b404b2007-11-03 03:38:54 +0000458 else talk_id(LANG_NOT_PRESENT, true);
Steve Bavin072a3c52007-10-24 12:32:12 +0000459#else
Alessio Lenzi6c2a9042007-10-30 21:41:03 +0000460 talk_id(LANG_DISK_SIZE_INFO, false);
William Wilgus62a5ed42018-12-09 12:09:40 -0600461 output_dyn_value(NULL, 0, info->size, kibyte_units, 3, true);
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000462#endif
463 break;
Jonathan Gordonc0897a82009-08-16 22:00:38 +0000464
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000465 }
466 return 0;
467}
468
469static int info_action_callback(int action, struct gui_synclist *lists)
470{
Steve Bavin072a3c52007-10-24 12:32:12 +0000471 if (action == ACTION_STD_CANCEL)
472 return action;
Rafaël Carré65bb8e42012-05-06 23:10:19 -0400473 else if (action == ACTION_STD_OK
Thomas Martitz43203102010-06-06 12:56:23 +0000474#ifdef HAVE_HOTSWAP
475 || action == SYS_FS_CHANGED
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000476#endif
477 )
478 {
Thomas Martitz35e8b142010-06-21 16:53:00 +0000479#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
Jonathan Gordonf5ec3e42007-12-17 02:37:21 +0000480 struct info_data *info = (struct info_data *)lists->data;
Thomas Martitz43203102010-06-06 12:56:23 +0000481 int i;
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000482 info->new_data = true;
Nils Wallménius01729e72008-08-15 08:27:39 +0000483 splash(0, ID2P(LANG_SCANNING_DISK));
Thomas Martitz43203102010-06-06 12:56:23 +0000484 for (i = 0; i < NUM_VOLUMES; i++)
Michael Sevakis7d1a47c2013-08-05 22:02:45 -0400485 volume_recalc_free(IF_MV(i));
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000486#endif
Stéphane Doyon50512d62008-08-18 00:58:47 +0000487 gui_synclist_speak_item(lists);
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000488 return ACTION_REDRAW;
489 }
Solomon Peachy4beafe12019-02-08 19:59:57 -0500490#if CONFIG_RTC
491 else if (action == ACTION_NONE)
492 {
493 static int last_redraw = 0;
494 if (gui_synclist_item_is_onscreen(lists, 0, INFO_TIME)
495 && TIME_AFTER(current_tick, last_redraw + HZ*5))
496 {
497 last_redraw = current_tick;
498 return ACTION_REDRAW;
499 }
500 }
501#endif
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000502 return action;
503}
William Wilgusdd40c462018-10-15 23:04:04 -0400504static int show_info(void)
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000505{
Steve Bavin072a3c52007-10-24 12:32:12 +0000506 struct info_data data = {.new_data = true };
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000507 struct simplelist_info info;
Steve Bavin7c95e5e2007-10-24 13:54:04 +0000508 simplelist_info_init(&info, str(LANG_ROCKBOX_INFO), INFO_COUNT, (void*)&data);
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000509 info.hide_selection = !global_settings.talk_menu;
Jonathan Gordon82c1aa82008-05-05 07:11:27 +0000510 if (info.hide_selection)
511 info.scroll_all = true;
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000512 info.get_name = info_getname;
Stéphane Doyona82a8602007-10-23 05:19:03 +0000513 if(global_settings.talk_menu)
514 info.get_talk = info_speak_item;
Jonathan Gordon7c594d62007-10-21 09:33:42 +0000515 info.action_callback = info_action_callback;
William Wilgusdd40c462018-10-15 23:04:04 -0400516 return (simplelist_show_list(&info)) ? 1 : 0;
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000517}
William Wilgusdd40c462018-10-15 23:04:04 -0400518
519
Nils Wallméniusb3113672007-08-05 19:19:39 +0000520MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO),
William Wilgusdd40c462018-10-15 23:04:04 -0400521 show_info, NULL, NULL, Icon_NOICON);
Dave Chapmanfdaacd52007-03-02 13:58:56 +0000522
Jonathan Gordonc7fec132008-12-01 09:28:14 +0000523#if CONFIG_RTC
524int time_screen(void* ignored);
Teruaki Kawashima93f9e7c2010-02-11 10:41:06 +0000525MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU),
526 time_screen, NULL, NULL, Icon_Menu_setting );
Jonathan Gordonc7fec132008-12-01 09:28:14 +0000527#endif
Jonathan Gordonc7fec132008-12-01 09:28:14 +0000528
Alessio Lenzia1a28792009-01-06 16:53:44 +0000529MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_CREDITS),
William Wilgusdd40c462018-10-15 23:04:04 -0400530 show_credits, NULL, NULL, Icon_NOICON);
531
Jonathan Gordondaf66942007-03-17 12:33:34 +0000532MENUITEM_FUNCTION(show_runtime_item, 0, ID2P(LANG_RUNNING_TIME),
William Wilgusdd40c462018-10-15 23:04:04 -0400533 view_runtime, NULL, NULL, Icon_NOICON);
534
Jonathan Gordondaf66942007-03-17 12:33:34 +0000535MENUITEM_FUNCTION(debug_menu_item, 0, ID2P(LANG_DEBUG),
William Wilgusdd40c462018-10-15 23:04:04 -0400536 debug_menu, NULL, NULL, Icon_NOICON);
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000537
Torne Wuffaf8cc7d2009-10-16 16:42:44 +0000538MAKE_MENU(info_menu, ID2P(LANG_SYSTEM), 0, Icon_System_menu,
Thomas Martitze44af442011-10-17 18:57:34 +0000539 &show_info_item, &show_credits_item,
540 &show_runtime_item, &debug_menu_item);
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000541/* INFO MENU */
542/***********************************/
543
544/***********************************/
545/* MAIN MENU */
546
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000547
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000548#ifdef HAVE_LCD_CHARCELLS
Bertrik Sikken56e27642008-09-12 21:11:06 +0000549static int mainmenu_callback(int action,const struct menu_item_ex *this_item)
Jonathan Gordone56f8e92007-02-15 04:41:37 +0000550{
551 (void)this_item;
552 switch (action)
553 {
554 case ACTION_ENTER_MENUITEM:
555 status_set_param(true);
556 break;
557 case ACTION_EXIT_MENUITEM:
558 status_set_param(false);
559 break;
560 }
561 return action;
562}
563#else
564#define mainmenu_callback NULL
565#endif
Nils Wallméniusb3113672007-08-05 19:19:39 +0000566MAKE_MENU(main_menu_, ID2P(LANG_SETTINGS), mainmenu_callback,
Jonathan Gordon02a87172007-03-03 13:52:14 +0000567 Icon_Submenu_Entered,
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000568 &sound_settings,
Nils Wallménius5aa06652008-10-13 15:11:11 +0000569 &playback_settings,
Jonathan Gordon4443fcb2007-10-06 11:47:41 +0000570 &settings_menu_item, &theme_menu,
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000571#ifdef HAVE_RECORDING
Jonathan Gordon91cb68a2007-03-01 11:14:46 +0000572 &recording_settings,
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000573#endif
Thomas Martitze44af442011-10-17 18:57:34 +0000574#if CONFIG_RTC
575 &timedate_item,
Thomas Martitze44af442011-10-17 18:57:34 +0000576#endif
Jonathan Gordon4443fcb2007-10-06 11:47:41 +0000577 &manage_settings,
Jonathan Gordon4718a1e2007-02-08 04:33:41 +0000578 );
579/* MAIN MENU */
580/***********************************/