summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c86
1 files changed, 73 insertions, 13 deletions
diff --git a/apps/settings.c b/apps/settings.c
index cee7a286f6..c17f42fd52 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -44,6 +44,7 @@
44#ifdef HAVE_LCD_BITMAP 44#ifdef HAVE_LCD_BITMAP
45#include "icons.h" 45#include "icons.h"
46#include "font.h" 46#include "font.h"
47#include "peakmeter.h"
47#endif 48#endif
48#include "lang.h" 49#include "lang.h"
49#include "language.h" 50#include "language.h"
@@ -52,7 +53,7 @@
52struct user_settings global_settings; 53struct user_settings global_settings;
53char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */ 54char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */
54 55
55#define CONFIG_BLOCK_VERSION 2 56#define CONFIG_BLOCK_VERSION 3
56#define CONFIG_BLOCK_SIZE 512 57#define CONFIG_BLOCK_SIZE 512
57#define RTC_BLOCK_SIZE 44 58#define RTC_BLOCK_SIZE 44
58 59
@@ -89,10 +90,14 @@ offset abs
890x16 0x2a <(int) Byte offset into resume file> 900x16 0x2a <(int) Byte offset into resume file>
900x1a 0x2e <time until disk spindown> 910x1a 0x2e <time until disk spindown>
910x1b 0x2f <browse current, play selected> 920x1b 0x2f <browse current, play selected>
920x1c 0x30 <peak meter hold timeout (bit 0-4)> 930x1c 0x30 <peak meter hold timeout (bit 0-4)>,
930x1d 0x31 <peak meter clip hold timeout (bit 0-4)> 94 peak_meter_performance (bit 7)
940x1e 0x32 <peak meter release step size> 950x1d 0x31 <peak meter clip hold timeout (bit 0-4)
950x1f 0x33 <repeat mode> 960x1e 0x32 <peak meter release step size,
97 peak_meter_dbfs (bit 7)
980x1f 0x33 <peak meter min either in -db or in percent>
990x20 0x34 <peak meter max either in -db or in percent>
1000x21 0x35 <repeat mode>
96 101
97 <all unused space filled with 0xff> 102 <all unused space filled with 0xff>
98 103
@@ -316,9 +321,13 @@ int settings_save( void )
316 ((global_settings.play_selected & 1) << 1)); 321 ((global_settings.play_selected & 1) << 1));
317 322
318 config_block[0x1c] = (unsigned char)global_settings.peak_meter_hold; 323 config_block[0x1c] = (unsigned char)global_settings.peak_meter_hold;
319 config_block[0x1d] = (unsigned char)global_settings.peak_meter_clip_hold; 324 config_block[0x1d] = (unsigned char)global_settings.peak_meter_clip_hold |
320 config_block[0x1e] = (unsigned char)global_settings.peak_meter_release; 325 (global_settings.peak_meter_performance ? 0x80 : 0);
321 config_block[0x1f] = (unsigned char)global_settings.repeat_mode; 326 config_block[0x1e] = global_settings.peak_meter_release |
327 (global_settings.peak_meter_dbfs ? 0x80 : 0);
328 config_block[0x1f] = (unsigned char)global_settings.peak_meter_min;
329 config_block[0x20] = (unsigned char)global_settings.peak_meter_max;
330 config_block[0x21] = (unsigned char)global_settings.repeat_mode;
322 331
323 memcpy(&config_block[0x24], &global_settings.total_uptime, 4); 332 memcpy(&config_block[0x24], &global_settings.total_uptime, 4);
324 333
@@ -355,6 +364,35 @@ int settings_save( void )
355 return 0; 364 return 0;
356} 365}
357 366
367#ifdef HAVE_LCD_BITMAP
368/**
369 * Applies the range infos stored in global_settings to
370 * the peak meter.
371 */
372void settings_apply_pm_range(void)
373{
374 int pm_min, pm_max;
375
376 /* depending on the scale mode (dBfs or percent) the values
377 of global_settings.peak_meter_dbfs have different meanings */
378 if (global_settings.peak_meter_dbfs)
379 {
380 /* convert to dBfs * 100 */
381 pm_min = -(((int)global_settings.peak_meter_min) * 100);
382 pm_max = -(((int)global_settings.peak_meter_max) * 100);
383 }
384 else
385 {
386 /* percent is stored directly -> no conversion */
387 pm_min = global_settings.peak_meter_min;
388 pm_max = global_settings.peak_meter_max;
389 }
390
391 /* apply the range */
392 peak_meter_init_range(global_settings.peak_meter_dbfs, pm_min, pm_max);
393}
394#endif /* HAVE_LCD_BITMAP */
395
358void settings_apply(void) 396void settings_apply(void)
359{ 397{
360 char buf[64]; 398 char buf[64];
@@ -381,6 +419,13 @@ void settings_apply(void)
381 CHARGE_RESTART_LO : CHARGE_RESTART_HI; 419 CHARGE_RESTART_LO : CHARGE_RESTART_HI;
382#endif 420#endif
383 421
422#ifdef HAVE_LCD_BITMAP
423 settings_apply_pm_range();
424 peak_meter_init_times(
425 global_settings.peak_meter_release, global_settings.peak_meter_hold,
426 global_settings.peak_meter_clip_hold);
427#endif
428
384 if ( global_settings.wps_file[0] && 429 if ( global_settings.wps_file[0] &&
385 global_settings.wps_file[0] != 0xff ) { 430 global_settings.wps_file[0] != 0xff ) {
386 snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.wps", 431 snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.wps",
@@ -500,14 +545,25 @@ void settings_load(void)
500 if (config_block[0x1c] != 0xFF) 545 if (config_block[0x1c] != 0xFF)
501 global_settings.peak_meter_hold = (config_block[0x1c]) & 0x1f; 546 global_settings.peak_meter_hold = (config_block[0x1c]) & 0x1f;
502 547
503 if (config_block[0x1d] != 0xFF) 548 if (config_block[0x1d] != 0xFF) {
504 global_settings.peak_meter_clip_hold = (config_block[0x1d]) & 0x1f; 549 global_settings.peak_meter_clip_hold = (config_block[0x1d]) & 0x1f;
550 global_settings.peak_meter_performance =
551 (config_block[0x1d] & 0x80) != 0;
552 }
505 553
506 if (config_block[0x1e] != 0xFF) 554 if (config_block[0x1e] != 0xFF) {
507 global_settings.peak_meter_release = config_block[0x1e]; 555 global_settings.peak_meter_release = config_block[0x1e] & 0x7f;
556 global_settings.peak_meter_dbfs = (config_block[0x1e] & 0x80) != 0;
557 }
508 558
509 if (config_block[0x1f] != 0xFF) 559 if (config_block[0x1f] != 0xFF)
510 global_settings.repeat_mode = config_block[0x1f]; 560 global_settings.peak_meter_min = config_block[0x1f];
561
562 if (config_block[0x20] != 0xFF)
563 global_settings.peak_meter_max = config_block[0x20];
564
565 if (config_block[0x21] != 0xFF)
566 global_settings.repeat_mode = config_block[0x21];
511 567
512 if (config_block[0x24] != 0xFF) 568 if (config_block[0x24] != 0xFF)
513 memcpy(&global_settings.total_uptime, &config_block[0x24], 4); 569 memcpy(&global_settings.total_uptime, &config_block[0x24], 4);
@@ -685,8 +741,12 @@ void settings_reset(void) {
685 global_settings.browse_current = false; 741 global_settings.browse_current = false;
686 global_settings.play_selected = true; 742 global_settings.play_selected = true;
687 global_settings.peak_meter_release = 8; 743 global_settings.peak_meter_release = 8;
688 global_settings.peak_meter_hold = 1; 744 global_settings.peak_meter_hold = 3;
689 global_settings.peak_meter_clip_hold = 16; 745 global_settings.peak_meter_clip_hold = 16;
746 global_settings.peak_meter_dbfs = true;
747 global_settings.peak_meter_min = 60;
748 global_settings.peak_meter_max = 0;
749 global_settings.peak_meter_performance = false;
690 global_settings.wps_file[0] = 0; 750 global_settings.wps_file[0] = 0;
691 global_settings.font_file[0] = 0; 751 global_settings.font_file[0] = 0;
692 global_settings.lang_file[0] = 0; 752 global_settings.lang_file[0] = 0;