Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
Jonathan Gordon | 4e73b53 | 2007-02-13 00:32:17 +0000 | [diff] [blame] | 8 | * $Id$ |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 9 | * |
| 10 | * Copyright (C) 2007 Jonathan Gordon |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 12 | * 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 Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 16 | * |
| 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 Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 26 | #include "string.h" |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 27 | #include "lang.h" |
| 28 | #include "action.h" |
| 29 | #include "settings.h" |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 30 | #include "power.h" |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 31 | #include "powermgmt.h" |
| 32 | #include "menu.h" |
Jonathan Gordon | c939774 | 2007-04-12 12:14:54 +0000 | [diff] [blame] | 33 | #include "misc.h" |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 34 | #include "exported_menus.h" |
| 35 | #include "tree.h" |
Thomas Martitz | 4320310 | 2010-06-06 12:56:23 +0000 | [diff] [blame] | 36 | #include "storage.h" |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 37 | #ifdef HAVE_RECORDING |
| 38 | #include "recording.h" |
| 39 | #endif |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 40 | #include "yesno.h" |
| 41 | #include "keyboard.h" |
| 42 | #include "screens.h" |
| 43 | #include "plugin.h" |
| 44 | #include "talk.h" |
Jonathan Gordon | 75bf31f | 2007-02-15 04:49:11 +0000 | [diff] [blame] | 45 | #include "splash.h" |
| 46 | #include "debug_menu.h" |
Jonathan Gordon | 66f42ac | 2007-06-07 06:05:08 +0000 | [diff] [blame] | 47 | #include "version.h" |
Jonathan Gordon | d7d6b78 | 2007-10-07 08:12:01 +0000 | [diff] [blame] | 48 | #include "time.h" |
Thomas Martitz | 3b75c86 | 2009-08-03 15:06:30 +0000 | [diff] [blame] | 49 | #include "wps.h" |
Jonathan Gordon | 2d31d77 | 2010-07-29 12:37:48 +0000 | [diff] [blame] | 50 | #include "skin_buffer.h" |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 51 | #include "disk.h" |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 52 | |
Steve Bavin | b76b5b9 | 2007-10-24 14:16:02 +0000 | [diff] [blame] | 53 | static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG}; |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 54 | |
| 55 | /***********************************/ |
| 56 | /* MANAGE SETTINGS MENU */ |
| 57 | |
| 58 | static int reset_settings(void) |
| 59 | { |
Nils Wallménius | 33c4446 | 2008-04-26 09:30:24 +0000 | [diff] [blame] | 60 | static const char *lines[]={ID2P(LANG_RESET_ASK)}; |
| 61 | static const char *yes_lines[]={ |
| 62 | ID2P(LANG_SETTINGS), |
Nils Wallménius | 5b76936 | 2007-08-06 13:08:36 +0000 | [diff] [blame] | 63 | ID2P(LANG_RESET_DONE_CLEAR) |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 64 | }; |
Nils Wallménius | 33c4446 | 2008-04-26 09:30:24 +0000 | [diff] [blame] | 65 | 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 Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 72 | |
| 73 | switch(gui_syncyesno_run(&message, &yes_message, &no_message)) |
| 74 | { |
| 75 | case YESNO_YES: |
| 76 | settings_reset(); |
Jonathan Gordon | 8a4549d | 2007-02-21 13:37:36 +0000 | [diff] [blame] | 77 | settings_save(); |
Magnus Holmgren | a14f4ac | 2010-03-06 12:14:12 +0000 | [diff] [blame] | 78 | settings_apply(true); |
Jonathan Gordon | 4c6b355 | 2010-02-26 08:01:41 +0000 | [diff] [blame] | 79 | settings_apply_skins(); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 80 | break; |
| 81 | case YESNO_NO: |
| 82 | break; |
| 83 | case YESNO_USB: |
| 84 | return 1; |
| 85 | } |
| 86 | return 0; |
| 87 | } |
| 88 | static int write_settings_file(void* param) |
| 89 | { |
Jens Arnold | 1f1da8e | 2007-02-15 21:07:10 +0000 | [diff] [blame] | 90 | return settings_save_config((intptr_t)param); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 91 | } |
| 92 | |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 93 | MENUITEM_FUNCTION(browse_configs, MENU_FUNC_USEPARAM, ID2P(LANG_CUSTOM_CFG), |
Jonathan Gordon | e54d8e1 | 2007-03-18 07:03:43 +0000 | [diff] [blame] | 94 | browse_folder, (void*)&config, NULL, Icon_NOICON); |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 95 | MENUITEM_FUNCTION(save_settings_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_SETTINGS), |
Jonathan Gordon | e54d8e1 | 2007-03-18 07:03:43 +0000 | [diff] [blame] | 96 | write_settings_file, (void*)SETTINGS_SAVE_ALL, NULL, Icon_NOICON); |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 97 | MENUITEM_FUNCTION(save_theme_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_THEME), |
Jonathan Gordon | e54d8e1 | 2007-03-18 07:03:43 +0000 | [diff] [blame] | 98 | write_settings_file, (void*)SETTINGS_SAVE_THEME, NULL, Icon_NOICON); |
Jonathan Gordon | b8bc45d | 2007-12-24 22:35:31 +0000 | [diff] [blame] | 99 | MENUITEM_FUNCTION(save_sound_item, MENU_FUNC_USEPARAM, ID2P(LANG_SAVE_SOUND), |
| 100 | write_settings_file, (void*)SETTINGS_SAVE_SOUND, NULL, Icon_NOICON); |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 101 | MENUITEM_FUNCTION(reset_settings_item, 0, ID2P(LANG_RESET), |
Jonathan Gordon | e54d8e1 | 2007-03-18 07:03:43 +0000 | [diff] [blame] | 102 | reset_settings, NULL, NULL, Icon_NOICON); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 103 | |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 104 | MAKE_MENU(manage_settings, ID2P(LANG_MANAGE_MENU), NULL, Icon_Config, |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 105 | &browse_configs, &reset_settings_item, |
Jonathan Gordon | b8bc45d | 2007-12-24 22:35:31 +0000 | [diff] [blame] | 106 | &save_settings_item, &save_sound_item, &save_theme_item); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 107 | /* MANAGE SETTINGS MENU */ |
| 108 | /**********************************/ |
| 109 | |
| 110 | /***********************************/ |
| 111 | /* INFO MENU */ |
| 112 | |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 113 | |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 114 | static int show_credits(void) |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 115 | { |
Thomas Martitz | 9c0b247 | 2010-08-01 16:15:27 +0000 | [diff] [blame] | 116 | char credits[MAX_PATH] = { '\0' }; |
| 117 | snprintf(credits, MAX_PATH, "%s/credits.rock", VIEWERS_DIR); |
| 118 | if (plugin_load(credits, NULL) != PLUGIN_OK) |
Jonathan Gordon | c939774 | 2007-04-12 12:14:54 +0000 | [diff] [blame] | 119 | { |
| 120 | /* show the rockbox logo and version untill a button is pressed */ |
Jonathan Gordon | c939774 | 2007-04-12 12:14:54 +0000 | [diff] [blame] | 121 | show_logo(); |
Jonathan Gordon | e385ee1 | 2008-12-31 05:59:26 +0000 | [diff] [blame] | 122 | while (IS_SYSEVENT(get_action(CONTEXT_STD, TIMEOUT_BLOCK))) |
| 123 | ; |
Jonathan Gordon | c939774 | 2007-04-12 12:14:54 +0000 | [diff] [blame] | 124 | } |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 125 | return 0; |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 128 | #ifdef HAVE_LCD_CHARCELLS |
| 129 | #define SIZE_FMT "%s%s" |
| 130 | #else |
| 131 | #define SIZE_FMT "%s %s" |
| 132 | #endif |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 133 | struct info_data |
| 134 | |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 135 | { |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 136 | bool new_data; |
| 137 | unsigned long size; |
| 138 | unsigned long free; |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 139 | #ifdef HAVE_MULTIVOLUME |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 140 | unsigned long size2; |
| 141 | unsigned long free2; |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 142 | #endif |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 143 | }; |
Stéphane Doyon | f6b404b | 2007-11-03 03:38:54 +0000 | [diff] [blame] | 144 | enum infoscreenorder |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 145 | { |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 146 | INFO_BATTERY = 0, |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 147 | INFO_DISK1, /* capacity or internal capacity/free on hotswap */ |
| 148 | INFO_DISK2, /* free space or external capacity/free on hotswap */ |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 149 | INFO_BUFFER, |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 150 | #ifdef HAVE_RECORDING |
| 151 | INFO_REC_DIR, |
| 152 | #endif |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 153 | INFO_VERSION, |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 154 | #if CONFIG_RTC |
| 155 | INFO_DATE, |
| 156 | INFO_TIME, |
| 157 | #endif |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 158 | INFO_COUNT |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 161 | static const char* info_getname(int selected_item, void *data, |
| 162 | char *buffer, size_t buffer_len) |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 163 | { |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 164 | struct info_data *info = (struct info_data*)data; |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 165 | #if CONFIG_RTC |
| 166 | struct tm *tm; |
| 167 | #endif |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 168 | char s1[32]; |
Jonathan Gordon | 9e07ef2 | 2011-11-15 14:11:08 +0000 | [diff] [blame] | 169 | #if defined(HAVE_MULTIVOLUME) |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 170 | char s2[32]; |
Jonathan Gordon | 9785732 | 2010-11-04 10:15:33 +0000 | [diff] [blame] | 171 | #endif |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 172 | if (info->new_data) |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 173 | { |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 174 | volume_size(IF_MV(0,) &info->size, &info->free); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 175 | #ifdef HAVE_MULTIVOLUME |
Thomas Martitz | cbc57af | 2014-02-07 18:18:16 +0100 | [diff] [blame] | 176 | #ifndef APPLICATION |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 177 | volume_size(1, &info->size2, &info->free2); |
| 178 | #else |
| 179 | info->size2 = 0; |
Thomas Martitz | cbc57af | 2014-02-07 18:18:16 +0100 | [diff] [blame] | 180 | #endif |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 181 | |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 182 | #endif |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 183 | info->new_data = false; |
| 184 | } |
| 185 | switch (selected_item) |
| 186 | { |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 187 | case INFO_VERSION: |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 188 | snprintf(buffer, buffer_len, "%s: %s", |
Rafaël Carré | 5d236b2 | 2010-05-27 09:41:46 +0000 | [diff] [blame] | 189 | str(LANG_VERSION), rbversion); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 190 | break; |
Jonathan Gordon | c7fec13 | 2008-12-01 09:28:14 +0000 | [diff] [blame] | 191 | |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 192 | #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 Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 232 | case INFO_BUFFER: /* buffer */ |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 233 | { |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 234 | long kib = audio_buffer_size() >> 10; /* to KiB */ |
| 235 | output_dyn_value(s1, sizeof(s1), kib, kibyte_units, 3, true); |
Bertrik Sikken | d86255b | 2008-08-03 22:02:11 +0000 | [diff] [blame] | 236 | snprintf(buffer, buffer_len, "%s %s", str(LANG_BUFFER_STAT), s1); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 237 | } |
| 238 | break; |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 239 | case INFO_BATTERY: /* battery */ |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 240 | #if CONFIG_CHARGING == CHARGING_SIMPLE |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 241 | /* Only know if plugged */ |
| 242 | if (charger_inserted()) |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 243 | return str(LANG_BATTERY_CHARGE); |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 244 | else |
| 245 | #elif CONFIG_CHARGING >= CHARGING_MONITOR |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 246 | #ifdef ARCHOS_RECORDER |
| 247 | /* Report the particular algorithm state */ |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 248 | if (charge_state == CHARGING) |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 249 | return str(LANG_BATTERY_CHARGE); |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 250 | else if (charge_state == TOPOFF) |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 251 | return str(LANG_BATTERY_TOPOFF_CHARGE); |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 252 | else if (charge_state == TRICKLE) |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 253 | return str(LANG_BATTERY_TRICKLE_CHARGE); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 254 | else |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 255 | #else /* !ARCHOS_RECORDER */ |
| 256 | /* Go by what power management reports */ |
| 257 | if (charging_state()) |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 258 | return str(LANG_BATTERY_CHARGE); |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 259 | else |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 260 | #endif /* ARCHOS_RECORDER */ |
| 261 | #endif /* CONFIG_CHARGING = */ |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 262 | if (battery_level() >= 0) |
Nils Wallménius | 3200d04 | 2009-08-20 16:47:44 +0000 | [diff] [blame] | 263 | snprintf(buffer, buffer_len, str(LANG_BATTERY_TIME), |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 264 | battery_level(), battery_time() / 60, battery_time() % 60); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 265 | else |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 266 | return "Battery n/a"; /* translating worth it? */ |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 267 | break; |
Steve Bavin | b76b5b9 | 2007-10-24 14:16:02 +0000 | [diff] [blame] | 268 | case INFO_DISK1: /* disk usage 1 */ |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 269 | #ifdef HAVE_MULTIVOLUME |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 270 | 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énius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 272 | snprintf(buffer, buffer_len, "%s %s/%s", str(LANG_DISK_NAME_INTERNAL), |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 273 | s1, s2); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 274 | #else |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 275 | output_dyn_value(s1, sizeof s1, info->free, kibyte_units, 3, true); |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 276 | snprintf(buffer, buffer_len, SIZE_FMT, str(LANG_DISK_FREE_INFO), s1); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 277 | #endif |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 278 | break; |
Steve Bavin | b76b5b9 | 2007-10-24 14:16:02 +0000 | [diff] [blame] | 279 | case INFO_DISK2: /* disk usage 2 */ |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 280 | #ifdef HAVE_MULTIVOLUME |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 281 | if (info->size2) |
| 282 | { |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 283 | 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énius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 285 | snprintf(buffer, buffer_len, "%s %s/%s", str(LANG_DISK_NAME_MMC), |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 286 | s1, s2); |
| 287 | } |
| 288 | else |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 289 | { |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 290 | snprintf(buffer, buffer_len, "%s %s", str(LANG_DISK_NAME_MMC), |
Stéphane Doyon | f6b404b | 2007-11-03 03:38:54 +0000 | [diff] [blame] | 291 | str(LANG_NOT_PRESENT)); |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 292 | } |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 293 | #else |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 294 | output_dyn_value(s1, sizeof s1, info->size, kibyte_units, 3, true); |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 295 | snprintf(buffer, buffer_len, SIZE_FMT, str(LANG_DISK_SIZE_INFO), s1); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 296 | #endif |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 297 | break; |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 298 | } |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 299 | return buffer; |
| 300 | } |
Stéphane Doyon | f6b404b | 2007-11-03 03:38:54 +0000 | [diff] [blame] | 301 | |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 302 | static int info_speak_item(int selected_item, void * data) |
| 303 | { |
| 304 | struct info_data *info = (struct info_data*)data; |
Nils Wallménius | 8dca930 | 2008-04-09 16:01:40 +0000 | [diff] [blame] | 305 | |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 306 | #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); |
Solomon Peachy | 51fe1b6 | 2019-07-28 09:24:40 -0400 | [diff] [blame^] | 313 | #ifdef HAVE_DIRCACHE |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 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 Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 322 | switch (selected_item) |
| 323 | { |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 324 | case INFO_VERSION: /* version */ |
Steve Bavin | 072a3c5 | 2007-10-24 12:32:12 +0000 | [diff] [blame] | 325 | talk_id(LANG_VERSION, false); |
Rafaël Carré | 5d236b2 | 2010-05-27 09:41:46 +0000 | [diff] [blame] | 326 | talk_spell(rbversion, true); |
Steve Bavin | 072a3c5 | 2007-10-24 12:32:12 +0000 | [diff] [blame] | 327 | break; |
Jonathan Gordon | c7fec13 | 2008-12-01 09:28:14 +0000 | [diff] [blame] | 328 | |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 329 | #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 Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 381 | case INFO_BUFFER: /* buffer */ |
Steve Bavin | 072a3c5 | 2007-10-24 12:32:12 +0000 | [diff] [blame] | 382 | { |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 383 | talk_id(LANG_BUFFER_STAT, false); |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 384 | long kib = audio_buffer_size() >> 10; /* to KiB */ |
| 385 | output_dyn_value(NULL, 0, kib, kibyte_units, 3, true); |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 386 | break; |
Steve Bavin | 072a3c5 | 2007-10-24 12:32:12 +0000 | [diff] [blame] | 387 | } |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 388 | case INFO_BATTERY: /* battery */ |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 389 | #if CONFIG_CHARGING == CHARGING_SIMPLE |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 390 | /* Only know if plugged */ |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 391 | if (charger_inserted()) |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 392 | { |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 393 | talk_id(LANG_BATTERY_CHARGE, true); |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 394 | if (battery_level() >= 0) |
| 395 | talk_value(battery_level(), UNIT_PERCENT, true); |
| 396 | } |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 397 | else |
| 398 | #elif CONFIG_CHARGING >= CHARGING_MONITOR |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 399 | #ifdef ARCHOS_RECORDER |
| 400 | /* Report the particular algorithm state */ |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 401 | if (charge_state == CHARGING) |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 402 | { |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 403 | talk_id(LANG_BATTERY_CHARGE, true); |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 404 | if (battery_level() >= 0) |
| 405 | talk_value(battery_level(), UNIT_PERCENT, true); |
| 406 | } |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 407 | else if (charge_state == TOPOFF) |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 408 | talk_id(LANG_BATTERY_TOPOFF_CHARGE, true); |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 409 | else if (charge_state == TRICKLE) |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 410 | { |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 411 | talk_id(LANG_BATTERY_TRICKLE_CHARGE, true); |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 412 | if (battery_level() >= 0) |
| 413 | talk_value(battery_level(), UNIT_PERCENT, true); |
| 414 | } |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 415 | else |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 416 | #else /* !ARCHOS_RECORDER */ |
| 417 | /* Go by what power management reports */ |
| 418 | if (charging_state()) |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 419 | { |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 420 | talk_id(LANG_BATTERY_CHARGE, true); |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 421 | if (battery_level() >= 0) |
| 422 | talk_value(battery_level(), UNIT_PERCENT, true); |
| 423 | } |
Michael Sevakis | 4118de4 | 2009-01-28 20:53:50 +0000 | [diff] [blame] | 424 | else |
Michael Sevakis | 3157e13 | 2008-12-24 16:58:41 +0000 | [diff] [blame] | 425 | #endif /* ARCHOS_RECORDER */ |
| 426 | #endif /* CONFIG_CHARGING = */ |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 427 | if (battery_level() >= 0) |
| 428 | { |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 429 | int time_left = battery_time(); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 430 | talk_id(LANG_BATTERY_TIME, false); |
| 431 | talk_value(battery_level(), UNIT_PERCENT, true); |
Thomas Martitz | c1bd9b0 | 2012-01-03 23:44:38 +0000 | [diff] [blame] | 432 | if (time_left >= 0) |
| 433 | talk_value(time_left * 60, UNIT_TIME, true); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 434 | } |
Stéphane Doyon | 69f88a5 | 2007-11-03 04:13:25 +0000 | [diff] [blame] | 435 | else talk_id(VOICE_BLANK, false); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 436 | break; |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 437 | case INFO_DISK1: /* disk 1 */ |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 438 | #ifdef HAVE_MULTIVOLUME |
Nils Wallménius | 79f19b9 | 2009-10-17 13:40:42 +0000 | [diff] [blame] | 439 | talk_ids(false, LANG_DISK_NAME_INTERNAL, LANG_DISK_FREE_INFO); |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 440 | output_dyn_value(NULL, 0, info->free, kibyte_units, 3, true); |
Stéphane Doyon | f6b404b | 2007-11-03 03:38:54 +0000 | [diff] [blame] | 441 | talk_id(LANG_DISK_SIZE_INFO, true); |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 442 | output_dyn_value(NULL, 0, info->size, kibyte_units, 3, true); |
Stéphane Doyon | f6b404b | 2007-11-03 03:38:54 +0000 | [diff] [blame] | 443 | #else |
| 444 | talk_id(LANG_DISK_FREE_INFO, false); |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 445 | output_dyn_value(NULL, 0, info->free, kibyte_units, 3, true); |
Stéphane Doyon | f6b404b | 2007-11-03 03:38:54 +0000 | [diff] [blame] | 446 | #endif |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 447 | break; |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 448 | case INFO_DISK2: /* disk 2 */ |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 449 | #ifdef HAVE_MULTIVOLUME |
Stéphane Doyon | f6b404b | 2007-11-03 03:38:54 +0000 | [diff] [blame] | 450 | talk_id(LANG_DISK_NAME_MMC, false); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 451 | if (info->size2) |
| 452 | { |
Stéphane Doyon | f6b404b | 2007-11-03 03:38:54 +0000 | [diff] [blame] | 453 | talk_id(LANG_DISK_FREE_INFO, true); |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 454 | output_dyn_value(NULL, 0, info->free2, kibyte_units, 3, true); |
Stéphane Doyon | f6b404b | 2007-11-03 03:38:54 +0000 | [diff] [blame] | 455 | talk_id(LANG_DISK_SIZE_INFO, true); |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 456 | output_dyn_value(NULL, 0, info->size2, kibyte_units, 3, true); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 457 | } |
Stéphane Doyon | f6b404b | 2007-11-03 03:38:54 +0000 | [diff] [blame] | 458 | else talk_id(LANG_NOT_PRESENT, true); |
Steve Bavin | 072a3c5 | 2007-10-24 12:32:12 +0000 | [diff] [blame] | 459 | #else |
Alessio Lenzi | 6c2a904 | 2007-10-30 21:41:03 +0000 | [diff] [blame] | 460 | talk_id(LANG_DISK_SIZE_INFO, false); |
William Wilgus | 62a5ed4 | 2018-12-09 12:09:40 -0600 | [diff] [blame] | 461 | output_dyn_value(NULL, 0, info->size, kibyte_units, 3, true); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 462 | #endif |
| 463 | break; |
Jonathan Gordon | c0897a8 | 2009-08-16 22:00:38 +0000 | [diff] [blame] | 464 | |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 465 | } |
| 466 | return 0; |
| 467 | } |
| 468 | |
| 469 | static int info_action_callback(int action, struct gui_synclist *lists) |
| 470 | { |
Steve Bavin | 072a3c5 | 2007-10-24 12:32:12 +0000 | [diff] [blame] | 471 | if (action == ACTION_STD_CANCEL) |
| 472 | return action; |
Rafaël Carré | 65bb8e4 | 2012-05-06 23:10:19 -0400 | [diff] [blame] | 473 | else if (action == ACTION_STD_OK |
Thomas Martitz | 4320310 | 2010-06-06 12:56:23 +0000 | [diff] [blame] | 474 | #ifdef HAVE_HOTSWAP |
| 475 | || action == SYS_FS_CHANGED |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 476 | #endif |
| 477 | ) |
| 478 | { |
Thomas Martitz | 35e8b14 | 2010-06-21 16:53:00 +0000 | [diff] [blame] | 479 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
Jonathan Gordon | f5ec3e4 | 2007-12-17 02:37:21 +0000 | [diff] [blame] | 480 | struct info_data *info = (struct info_data *)lists->data; |
Thomas Martitz | 4320310 | 2010-06-06 12:56:23 +0000 | [diff] [blame] | 481 | int i; |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 482 | info->new_data = true; |
Nils Wallménius | 01729e7 | 2008-08-15 08:27:39 +0000 | [diff] [blame] | 483 | splash(0, ID2P(LANG_SCANNING_DISK)); |
Thomas Martitz | 4320310 | 2010-06-06 12:56:23 +0000 | [diff] [blame] | 484 | for (i = 0; i < NUM_VOLUMES; i++) |
Michael Sevakis | 7d1a47c | 2013-08-05 22:02:45 -0400 | [diff] [blame] | 485 | volume_recalc_free(IF_MV(i)); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 486 | #endif |
Stéphane Doyon | 50512d6 | 2008-08-18 00:58:47 +0000 | [diff] [blame] | 487 | gui_synclist_speak_item(lists); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 488 | return ACTION_REDRAW; |
| 489 | } |
Solomon Peachy | 4beafe1 | 2019-02-08 19:59:57 -0500 | [diff] [blame] | 490 | #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 Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 502 | return action; |
| 503 | } |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 504 | static int show_info(void) |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 505 | { |
Steve Bavin | 072a3c5 | 2007-10-24 12:32:12 +0000 | [diff] [blame] | 506 | struct info_data data = {.new_data = true }; |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 507 | struct simplelist_info info; |
Steve Bavin | 7c95e5e | 2007-10-24 13:54:04 +0000 | [diff] [blame] | 508 | simplelist_info_init(&info, str(LANG_ROCKBOX_INFO), INFO_COUNT, (void*)&data); |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 509 | info.hide_selection = !global_settings.talk_menu; |
Jonathan Gordon | 82c1aa8 | 2008-05-05 07:11:27 +0000 | [diff] [blame] | 510 | if (info.hide_selection) |
| 511 | info.scroll_all = true; |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 512 | info.get_name = info_getname; |
Stéphane Doyon | a82a860 | 2007-10-23 05:19:03 +0000 | [diff] [blame] | 513 | if(global_settings.talk_menu) |
| 514 | info.get_talk = info_speak_item; |
Jonathan Gordon | 7c594d6 | 2007-10-21 09:33:42 +0000 | [diff] [blame] | 515 | info.action_callback = info_action_callback; |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 516 | return (simplelist_show_list(&info)) ? 1 : 0; |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 517 | } |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 518 | |
| 519 | |
Nils Wallménius | b311367 | 2007-08-05 19:19:39 +0000 | [diff] [blame] | 520 | MENUITEM_FUNCTION(show_info_item, 0, ID2P(LANG_ROCKBOX_INFO), |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 521 | show_info, NULL, NULL, Icon_NOICON); |
Dave Chapman | fdaacd5 | 2007-03-02 13:58:56 +0000 | [diff] [blame] | 522 | |
Jonathan Gordon | c7fec13 | 2008-12-01 09:28:14 +0000 | [diff] [blame] | 523 | #if CONFIG_RTC |
| 524 | int time_screen(void* ignored); |
Teruaki Kawashima | 93f9e7c | 2010-02-11 10:41:06 +0000 | [diff] [blame] | 525 | MENUITEM_FUNCTION(timedate_item, MENU_FUNC_CHECK_RETVAL, ID2P(LANG_TIME_MENU), |
| 526 | time_screen, NULL, NULL, Icon_Menu_setting ); |
Jonathan Gordon | c7fec13 | 2008-12-01 09:28:14 +0000 | [diff] [blame] | 527 | #endif |
Jonathan Gordon | c7fec13 | 2008-12-01 09:28:14 +0000 | [diff] [blame] | 528 | |
Alessio Lenzi | a1a2879 | 2009-01-06 16:53:44 +0000 | [diff] [blame] | 529 | MENUITEM_FUNCTION(show_credits_item, 0, ID2P(LANG_CREDITS), |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 530 | show_credits, NULL, NULL, Icon_NOICON); |
| 531 | |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 532 | MENUITEM_FUNCTION(show_runtime_item, 0, ID2P(LANG_RUNNING_TIME), |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 533 | view_runtime, NULL, NULL, Icon_NOICON); |
| 534 | |
Jonathan Gordon | daf6694 | 2007-03-17 12:33:34 +0000 | [diff] [blame] | 535 | MENUITEM_FUNCTION(debug_menu_item, 0, ID2P(LANG_DEBUG), |
William Wilgus | dd40c46 | 2018-10-15 23:04:04 -0400 | [diff] [blame] | 536 | debug_menu, NULL, NULL, Icon_NOICON); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 537 | |
Torne Wuff | af8cc7d | 2009-10-16 16:42:44 +0000 | [diff] [blame] | 538 | MAKE_MENU(info_menu, ID2P(LANG_SYSTEM), 0, Icon_System_menu, |
Thomas Martitz | e44af44 | 2011-10-17 18:57:34 +0000 | [diff] [blame] | 539 | &show_info_item, &show_credits_item, |
| 540 | &show_runtime_item, &debug_menu_item); |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 541 | /* INFO MENU */ |
| 542 | /***********************************/ |
| 543 | |
| 544 | /***********************************/ |
| 545 | /* MAIN MENU */ |
| 546 | |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 547 | |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 548 | #ifdef HAVE_LCD_CHARCELLS |
Bertrik Sikken | 56e2764 | 2008-09-12 21:11:06 +0000 | [diff] [blame] | 549 | static int mainmenu_callback(int action,const struct menu_item_ex *this_item) |
Jonathan Gordon | e56f8e9 | 2007-02-15 04:41:37 +0000 | [diff] [blame] | 550 | { |
| 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énius | b311367 | 2007-08-05 19:19:39 +0000 | [diff] [blame] | 566 | MAKE_MENU(main_menu_, ID2P(LANG_SETTINGS), mainmenu_callback, |
Jonathan Gordon | 02a8717 | 2007-03-03 13:52:14 +0000 | [diff] [blame] | 567 | Icon_Submenu_Entered, |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 568 | &sound_settings, |
Nils Wallménius | 5aa0665 | 2008-10-13 15:11:11 +0000 | [diff] [blame] | 569 | &playback_settings, |
Jonathan Gordon | 4443fcb | 2007-10-06 11:47:41 +0000 | [diff] [blame] | 570 | &settings_menu_item, &theme_menu, |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 571 | #ifdef HAVE_RECORDING |
Jonathan Gordon | 91cb68a | 2007-03-01 11:14:46 +0000 | [diff] [blame] | 572 | &recording_settings, |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 573 | #endif |
Thomas Martitz | e44af44 | 2011-10-17 18:57:34 +0000 | [diff] [blame] | 574 | #if CONFIG_RTC |
| 575 | &timedate_item, |
Thomas Martitz | e44af44 | 2011-10-17 18:57:34 +0000 | [diff] [blame] | 576 | #endif |
Jonathan Gordon | 4443fcb | 2007-10-06 11:47:41 +0000 | [diff] [blame] | 577 | &manage_settings, |
Jonathan Gordon | 4718a1e | 2007-02-08 04:33:41 +0000 | [diff] [blame] | 578 | ); |
| 579 | /* MAIN MENU */ |
| 580 | /***********************************/ |