summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/lang/deutsch.lang15
-rw-r--r--apps/lang/english.lang15
-rw-r--r--apps/settings.c377
-rw-r--r--apps/settings.h1
-rw-r--r--apps/settings_menu.c5
5 files changed, 411 insertions, 2 deletions
diff --git a/apps/lang/deutsch.lang b/apps/lang/deutsch.lang
index f8608a6373..75bff3ca59 100644
--- a/apps/lang/deutsch.lang
+++ b/apps/lang/deutsch.lang
@@ -1526,3 +1526,18 @@ id: LANG_SOKOBAN_ON
1526desc: how to undo move 1526desc: how to undo move
1527eng: "[ON] To Undo" 1527eng: "[ON] To Undo"
1528new: "[ON] = Rückgängig" 1528new: "[ON] = Rückgängig"
1529
1530id: LANG_SAVE_SETTINGS
1531desc: in system_settings_menu()
1532eng: "Einstellungen speichern"
1533new:
1534
1535id: LANG_SETTINGS_SAVED1
1536desc: Feedback shown when a .cfg file is saved
1537eng: "Settings"
1538new: "Einstellungen"
1539
1540id: LANG_SETTINGS_SAVED2
1541desc: Feedback shown when a .cfg file is saved
1542eng: "Saved"
1543new: "gespeichert"
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 8018947561..35f71b903c 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1429,3 +1429,18 @@ id: LANG_CHANNEL_KARAOKE
1429desc: in sound_settings 1429desc: in sound_settings
1430eng: "Karaoke" 1430eng: "Karaoke"
1431new: 1431new:
1432
1433id: LANG_SAVE_SETTINGS
1434desc: in system_settings_menu()
1435eng: "Write .cfg file"
1436new:
1437
1438id: LANG_SETTINGS_SAVED1
1439desc: Feedback shown when a .cfg file is saved
1440eng: "Settings"
1441new:
1442
1443id: LANG_SETTINGS_SAVED2
1444desc: Feedback shown when a .cfg file is saved
1445eng: "Saved"
1446new:
diff --git a/apps/settings.c b/apps/settings.c
index 39ec4086dc..a2ef3f8b15 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -54,6 +54,7 @@
54#include "wps-display.h" 54#include "wps-display.h"
55#include "powermgmt.h" 55#include "powermgmt.h"
56#include "sprintf.h" 56#include "sprintf.h"
57#include "keyboard.h"
57 58
58struct user_settings global_settings; 59struct user_settings global_settings;
59char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */ 60char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */
@@ -1052,6 +1053,382 @@ bool settings_load_config(char* file)
1052 return true; 1053 return true;
1053} 1054}
1054 1055
1056
1057bool settings_save_config(void)
1058{
1059 bool done = false;
1060 int fd, i, value;
1061 char buf[MAX_PATH + 32];
1062 char filename[MAX_PATH];
1063
1064 /* find unused filename */
1065 for (i=0; ; i++) {
1066 snprintf(filename, sizeof filename, "/.rockbox/config%02d.cfg", i);
1067 fd = open(filename, O_RDONLY);
1068 if (fd < 0)
1069 break;
1070 close(fd);
1071 }
1072
1073 /* allow user to modify filename */
1074 while (!done) {
1075 if (!kbd_input(filename, sizeof filename)) {
1076 fd = creat(filename,0);
1077 if (fd < 0) {
1078 lcd_clear_display();
1079 lcd_puts(0,0,str(LANG_FAILED));
1080 lcd_update();
1081 sleep(HZ);
1082 }
1083 else
1084 done = true;
1085 }
1086 else
1087 break;
1088 }
1089
1090 /* abort if file couldn't be created */
1091 if (!done) {
1092 lcd_clear_display();
1093 lcd_puts(0,0,str(LANG_RESET_DONE_CANCEL));
1094 lcd_update();
1095 sleep(HZ);
1096 return false;
1097 }
1098
1099 strncpy(buf, "# >>> .cfg file created by rockbox <<<\r\n", sizeof(buf));
1100 write(fd, buf, strlen(buf));
1101
1102 strncpy(buf, "# >>> http://rockbox.haxx.se <<<\r\n\r\n", sizeof(buf));
1103 write(fd, buf, strlen(buf));
1104
1105 snprintf(buf, sizeof(buf), "#\r\n# wps / language / font \r\n#\r\n");
1106 write(fd, buf, strlen(buf));
1107
1108 if (global_settings.wps_file[0] != 0) {
1109 snprintf(buf, sizeof(buf),
1110 "wps: /.rockbox/%s.wps\r\n", global_settings.wps_file);
1111 write(fd, buf, strlen(buf));
1112 }
1113
1114 if (global_settings.lang_file[0] != 0) {
1115 snprintf(buf, sizeof(buf), "lang: /.rockbox/%s.lng\r\n",
1116 global_settings.lang_file);
1117 write(fd, buf, strlen(buf));
1118 }
1119
1120#ifdef HAVE_LCD_BITMAP
1121 if (global_settings.font_file[0] != 0) {
1122 snprintf(buf, sizeof(buf), "font: /.rockbox/%s.fnt\r\n",
1123 global_settings.font_file);
1124 write(fd, buf, strlen(buf));
1125 }
1126#endif
1127
1128 snprintf(buf, sizeof(buf), "#\r\n# Sound settings\r\n#\r\n");
1129 write(fd, buf, strlen(buf));
1130
1131 value = mpeg_val2phys(SOUND_VOLUME, global_settings.volume);
1132 snprintf(buf, sizeof(buf), "volume: %d\r\n", value);
1133 write(fd, buf, strlen(buf));
1134
1135 value = mpeg_val2phys(SOUND_BASS, global_settings.bass);
1136 snprintf(buf, sizeof(buf), "bass: %d\r\n", value);
1137 write(fd, buf, strlen(buf));
1138
1139 value = mpeg_val2phys(SOUND_TREBLE, global_settings.treble);
1140 snprintf(buf, sizeof(buf), "treble: %d\r\n", value);
1141 write(fd, buf, strlen(buf));
1142
1143 value = mpeg_val2phys(SOUND_BALANCE, global_settings.balance);
1144 snprintf(buf, sizeof(buf), "balance: %d\r\n", value);
1145 write(fd, buf, strlen(buf));
1146
1147 {
1148 static char* options[] =
1149 {"stereo","stereo narrow","mono","mono left",
1150 "mono right","karaoke","stereo wide"};
1151 snprintf(buf, sizeof(buf), "channels: %s\r\n",
1152 options[global_settings.channel_config]);
1153 write(fd, buf, strlen(buf));
1154 }
1155
1156#ifdef HAVE_MAS3587F
1157 value = mpeg_val2phys(SOUND_LOUDNESS, global_settings.loudness);
1158 snprintf(buf, sizeof(buf), "loudness: %d\r\n", value);
1159 write(fd, buf, strlen(buf));
1160
1161 value = mpeg_val2phys(SOUND_SUPERBASS, global_settings.bass_boost);
1162 snprintf(buf, sizeof(buf), "bass boost: %d\r\n", value);
1163 write(fd, buf, strlen(buf));
1164
1165 snprintf(buf, sizeof(buf), "auto volume: %d\r\n", global_settings.avc);
1166 write(fd, buf, strlen(buf));
1167#endif
1168
1169 snprintf(buf, sizeof(buf), "#\r\n# Playback\r\n#\r\n");
1170 write(fd, buf, strlen(buf));
1171
1172 {
1173 static char* options[] = {"off","on"};
1174 snprintf(buf, sizeof(buf), "shuffle: %s\r\n",
1175 options[global_settings.playlist_shuffle]);
1176 write(fd, buf, strlen(buf));
1177 }
1178
1179 {
1180 static char* options[] = {"off", "all", "one"};
1181 snprintf(buf, sizeof(buf), "repeat: %s\r\n",
1182 options[global_settings.repeat_mode]);
1183 write(fd, buf, strlen(buf));
1184 }
1185
1186 {
1187 static char* options[] = {"off","on"};
1188 snprintf(buf, sizeof(buf), "play selected: %s\r\n",
1189 options[global_settings.play_selected]);
1190 write(fd, buf, strlen(buf));
1191 }
1192
1193 {
1194 static char* options[] = {"off", "ask", "ask once", "on"};
1195 snprintf(buf, sizeof(buf), "resume: %s\r\n",
1196 options[global_settings.resume]);
1197 write(fd, buf, strlen(buf));
1198 }
1199
1200 {
1201 static char* options[] =
1202 {"1","2","3","4","5","6","8","10",
1203 "15","20","25","30","45","60"};
1204 snprintf(buf, sizeof(buf), "scan min step: %s\r\n",
1205 options[global_settings.ff_rewind_min_step]);
1206 write(fd, buf, strlen(buf));
1207 }
1208
1209 snprintf(buf, sizeof(buf), "scan accel: %d\r\nantiskip: %d\r\n",
1210 global_settings.ff_rewind_accel,
1211 global_settings.buffer_margin);
1212 write(fd, buf, strlen(buf));
1213
1214 {
1215 static char* options[] = {"off","on"};
1216 snprintf(buf, sizeof(buf), "volume fade: %s\r\n",
1217 options[global_settings.fade_on_stop]);
1218 write(fd, buf, strlen(buf));
1219 }
1220
1221 snprintf(buf, sizeof(buf), "#\r\n# File View\r\n#\r\n");
1222 write(fd, buf, strlen(buf));
1223
1224 {
1225 static char* options[] = {"off","on"};
1226 snprintf(buf, sizeof(buf), "sort case: %s\r\n",
1227 options[global_settings.sort_case]);
1228 write(fd, buf, strlen(buf));
1229 }
1230
1231 {
1232 static char* options[] =
1233 {"all", "supported","music", "playlists"};
1234 snprintf(buf, sizeof(buf), "show files: %s\r\n",
1235 options[global_settings.dirfilter]);
1236 write(fd, buf, strlen(buf));
1237 }
1238
1239 {
1240 static char* options[] = {"off","on"};
1241 snprintf(buf, sizeof(buf), "follow playlist: %s\r\n",
1242 options[global_settings.browse_current]);
1243 write(fd, buf, strlen(buf));
1244 }
1245
1246 snprintf(buf, sizeof(buf), "#\r\n# Display\r\n#\r\n");
1247 write(fd, buf, strlen(buf));
1248
1249#ifdef HAVE_LCD_BITMAP
1250 {
1251 static char* options[] = {"off","on"};
1252 snprintf(buf, sizeof(buf), "statusbar: %s\r\nscrollbar: %s\r\n",
1253 options[global_settings.statusbar],
1254 options[global_settings.scrollbar]);
1255 write(fd, buf, strlen(buf));
1256 }
1257
1258 {
1259 static char* options[] = {"graphic", "numeric"};
1260 snprintf(buf, sizeof(buf),
1261 "volume display: %s\r\nbattery display: %s\r\n",
1262 options[global_settings.volume_type],
1263 options[global_settings.battery_type]);
1264 write(fd, buf, strlen(buf));
1265 }
1266#endif
1267
1268 snprintf(buf, sizeof(buf), "scroll speed: %d\r\nscroll delay: %d\r\n",
1269 global_settings.scroll_speed,
1270 global_settings.scroll_delay);
1271 write(fd, buf, strlen(buf));
1272
1273#ifdef HAVE_LCD_BITMAP
1274 snprintf(buf, sizeof(buf), "scroll step: %d\r\n",
1275 global_settings.scroll_step);
1276 write(fd, buf, strlen(buf));
1277#endif
1278
1279 snprintf(buf, sizeof(buf), "bidir limit: %d\r\n",
1280 global_settings.bidir_limit);
1281 write(fd, buf, strlen(buf));
1282
1283 {
1284 static char* options[] =
1285 {"off","on","1","2","3","4","5","6","7","8","9",
1286 "10","15","20","25","30","45","60","90"};
1287 snprintf(buf, sizeof(buf), "backlight timeout: %s\r\n",
1288 options[global_settings.backlight_timeout]);
1289 write(fd, buf, strlen(buf));
1290 }
1291
1292 {
1293 static char* options[] = {"off","on"};
1294 snprintf(buf, sizeof(buf), "backlight when plugged: %s\r\n",
1295 options[global_settings.backlight_on_when_charging]);
1296 write(fd, buf, strlen(buf));
1297 }
1298
1299 snprintf(buf, sizeof(buf), "contrast: %d\r\n", global_settings.contrast);
1300 write(fd, buf, strlen(buf));
1301
1302#ifdef HAVE_LCD_BITMAP
1303 snprintf(buf, sizeof(buf), "peak meter release: %d\r\n",
1304 global_settings.peak_meter_release);
1305 write(fd, buf, strlen(buf));
1306
1307 {
1308 static char* options[] =
1309 {"off","200ms","300ms","500ms","1","2","3","4","5",
1310 "6","7","8","9","10","15","20","30","1min"};
1311 snprintf(buf, sizeof(buf), "peak meter hold: %s\r\n",
1312 options[global_settings.peak_meter_hold]);
1313 write(fd, buf, strlen(buf));
1314 }
1315
1316 {
1317 static char* options[] =
1318 {"on","1","2","3","4","5","6","7","8","9","10","15","20","25","30",
1319 "45","60","90","2min","3min","5min","10min","20min","45min","90min"};
1320 snprintf(buf, sizeof(buf), "peak meter clip hold: %s\r\n",
1321 options[global_settings.peak_meter_clip_hold]);
1322 write(fd, buf, strlen(buf));
1323 }
1324
1325 {
1326 static char* options[] = {"off","on"};
1327 snprintf(buf, sizeof(buf),
1328 "peak meter busy: %s\r\npeak meter dbfs: %s\r\n",
1329 options[global_settings.peak_meter_performance],
1330 options[global_settings.peak_meter_dbfs]);
1331 write(fd, buf, strlen(buf));
1332 }
1333
1334 snprintf(buf, sizeof(buf), "peak meter min: %d\r\npeak meter max: %d\r\n",
1335 global_settings.peak_meter_min,
1336 global_settings.peak_meter_max);
1337 write(fd, buf, strlen(buf));
1338#endif
1339
1340 snprintf(buf, sizeof(buf), "#\r\n# System\r\n#\r\ndisk spindown: %d\r\n",
1341 global_settings.disk_spindown);
1342 write(fd, buf, strlen(buf));
1343
1344#ifdef HAVE_ATA_POWER_OFF
1345 {
1346 static char* options[] = {"off","on"};
1347 snprintf(buf, sizeof(buf), "disk poweroff: %s\r\n",
1348 options[global_settings.disk_poweroff]);
1349 write(fd, buf, strlen(buf));
1350 }
1351#endif
1352
1353 snprintf(buf, sizeof(buf), "battery capacity: %d\r\n",
1354 global_settings.battery_capacity);
1355 write(fd, buf, strlen(buf));
1356
1357#ifdef HAVE_CHARGE_CTRL
1358 {
1359 static char* options[] = {"off","on"};
1360 snprintf(buf, sizeof(buf),
1361 "deep discharge: %s\r\ntrickle charge: %s\r\n",
1362 options[global_settings.discharge],
1363 options[global_settings.trickle_charge]);
1364 write(fd, buf, strlen(buf));
1365 }
1366#endif
1367
1368#ifdef HAVE_LCD_BITMAP
1369 {
1370 static char* options[] = {"24hour", "12hour"};
1371 snprintf(buf, sizeof(buf), "time format: %s\r\n",
1372 options[global_settings.timeformat]);
1373 write(fd, buf, strlen(buf));
1374 }
1375#endif
1376
1377 {
1378 static char* options[] =
1379 {"off","1","2","3","4","5","6","7","8",
1380 "9","10","15","30","45","60"};
1381 snprintf(buf, sizeof(buf), "idle poweroff: %s\r\n",
1382 options[global_settings.poweroff]);
1383 write(fd, buf, strlen(buf));
1384 }
1385
1386#ifdef HAVE_MAS3587F
1387 snprintf(buf, sizeof(buf), "#\r\n# Recording\r\n#\r\n");
1388 write(fd, buf, strlen(buf));
1389
1390 snprintf(buf, sizeof(buf), "rec quality: %d\r\n",
1391 global_settings.rec_quality);
1392 write(fd, buf, strlen(buf));
1393
1394 {
1395 static char* options[] = {"44", "48", "32", "22", "24", "16"};
1396 snprintf(buf, sizeof(buf), "rec frequency: %s\r\n",
1397 options[global_settings.rec_frequency]);
1398 write(fd, buf, strlen(buf));
1399 }
1400
1401 {
1402 static char* options[] = {"mic", "line", "spdif"};
1403 snprintf(buf, sizeof(buf), "rec source: %s\r\n",
1404 options[global_settings.rec_source]);
1405 write(fd, buf, strlen(buf));
1406 }
1407
1408 {
1409 static char* options[] = {"stereo", "mono"};
1410 snprintf(buf, sizeof(buf), "rec channels: %s\r\n",
1411 options[global_settings.rec_channels]);
1412 write(fd, buf, strlen(buf));
1413 }
1414
1415 snprintf(buf, sizeof(buf),
1416 "rec mic gain: %d\r\nrec left gain: %d\r\nrec right gain: %d\r\n",
1417 global_settings.rec_mic_gain,
1418 global_settings.rec_left_gain,
1419 global_settings.rec_right_gain);
1420 write(fd, buf, strlen(buf));
1421#endif
1422 close(fd);
1423
1424 lcd_clear_display();
1425 lcd_puts(0,0,str(LANG_SETTINGS_SAVED1));
1426 lcd_puts(0,1,str(LANG_SETTINGS_SAVED2));
1427 lcd_update();
1428 sleep(HZ);
1429 return true;
1430}
1431
1055/* 1432/*
1056 * reset all settings to their default value 1433 * reset all settings to their default value
1057 */ 1434 */
diff --git a/apps/settings.h b/apps/settings.h
index 6c383f9976..afc4794e7f 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -163,6 +163,7 @@ void settings_apply_pm_range(void);
163void settings_display(void); 163void settings_display(void);
164 164
165bool settings_load_config(char* file); 165bool settings_load_config(char* file);
166bool settings_save_config(void);
166bool set_bool_options(char* string, bool* variable, 167bool set_bool_options(char* string, bool* variable,
167 char* yes_str, char* no_str ); 168 char* yes_str, char* no_str );
168 169
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index f210d79a96..a8487c5c54 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -767,8 +767,8 @@ static bool system_settings_menu(void)
767 { str(LANG_TIME), timedate_set }, 767 { str(LANG_TIME), timedate_set },
768 { str(LANG_TIMEFORMAT), timeformat_set }, 768 { str(LANG_TIMEFORMAT), timeformat_set },
769#endif 769#endif
770 { str(LANG_POWEROFF_IDLE), poweroff_idle_timer }, 770 { str(LANG_POWEROFF_IDLE), poweroff_idle_timer },
771 { str(LANG_RESET), reset_settings }, 771 { str(LANG_RESET), reset_settings },
772 }; 772 };
773 773
774 m=menu_init( items, sizeof items / sizeof(struct menu_items) ); 774 m=menu_init( items, sizeof items / sizeof(struct menu_items) );
@@ -787,6 +787,7 @@ bool settings_menu(void)
787 { str(LANG_FILE), fileview_settings_menu }, 787 { str(LANG_FILE), fileview_settings_menu },
788 { str(LANG_DISPLAY), display_settings_menu }, 788 { str(LANG_DISPLAY), display_settings_menu },
789 { str(LANG_SYSTEM), system_settings_menu }, 789 { str(LANG_SYSTEM), system_settings_menu },
790 { str(LANG_SAVE_SETTINGS), settings_save_config },
790 }; 791 };
791 792
792 m = menu_init( items, sizeof items / sizeof(struct menu_items) ); 793 m = menu_init( items, sizeof items / sizeof(struct menu_items) );