2002-06-27 00:20:00 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by wavey@wavey.org
|
2002-07-15 11:02:12 +00:00
|
|
|
* RTC config saving code (C) 2002 by hessu@hes.iki.fi
|
2002-06-27 00:20:00 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include <stdio.h>
|
2004-06-18 20:41:59 +00:00
|
|
|
#include <stddef.h>
|
2005-02-15 15:30:19 +00:00
|
|
|
#include <limits.h>
|
2002-06-27 00:20:00 +00:00
|
|
|
#include "config.h"
|
2002-07-28 16:09:44 +00:00
|
|
|
#include "kernel.h"
|
2003-02-14 09:44:34 +00:00
|
|
|
#include "thread.h"
|
2002-06-27 00:20:00 +00:00
|
|
|
#include "settings.h"
|
|
|
|
#include "disk.h"
|
|
|
|
#include "panic.h"
|
|
|
|
#include "debug.h"
|
2002-06-27 01:08:11 +00:00
|
|
|
#include "button.h"
|
2002-08-31 04:58:35 +00:00
|
|
|
#include "usb.h"
|
|
|
|
#include "backlight.h"
|
2002-06-27 01:08:11 +00:00
|
|
|
#include "lcd.h"
|
2005-04-04 12:06:29 +00:00
|
|
|
#include "audio.h"
|
2004-01-05 20:42:51 +00:00
|
|
|
#include "mp3_playback.h"
|
2005-09-11 12:07:13 +00:00
|
|
|
#include "mpeg.h"
|
2004-03-15 08:27:51 +00:00
|
|
|
#include "talk.h"
|
2002-07-15 11:02:12 +00:00
|
|
|
#include "string.h"
|
2002-07-28 16:09:44 +00:00
|
|
|
#include "ata.h"
|
2002-08-13 17:16:09 +00:00
|
|
|
#include "fat.h"
|
2002-07-28 16:09:44 +00:00
|
|
|
#include "power.h"
|
2002-07-30 07:56:16 +00:00
|
|
|
#include "backlight.h"
|
2002-08-06 10:52:51 +00:00
|
|
|
#include "powermgmt.h"
|
2005-08-08 19:23:28 +00:00
|
|
|
#include "bidi.h"
|
2002-08-20 19:37:00 +00:00
|
|
|
#include "status.h"
|
2002-09-05 16:30:07 +00:00
|
|
|
#include "atoi.h"
|
2002-09-24 17:22:12 +00:00
|
|
|
#include "screens.h"
|
2002-10-02 16:33:26 +00:00
|
|
|
#include "ctype.h"
|
|
|
|
#include "file.h"
|
2002-10-29 12:16:36 +00:00
|
|
|
#include "errno.h"
|
|
|
|
#include "system.h"
|
2003-05-04 02:04:31 +00:00
|
|
|
#include "misc.h"
|
2004-04-20 10:23:57 +00:00
|
|
|
#include "timefuncs.h"
|
2002-08-20 19:37:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#include "icons.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
#include "font.h"
|
2002-10-29 12:09:15 +00:00
|
|
|
#include "peakmeter.h"
|
2003-06-25 23:24:47 +00:00
|
|
|
#include "hwcompat.h"
|
2002-08-20 19:37:00 +00:00
|
|
|
#endif
|
2002-09-18 14:08:05 +00:00
|
|
|
#include "lang.h"
|
2002-10-08 15:42:40 +00:00
|
|
|
#include "language.h"
|
|
|
|
#include "wps-display.h"
|
2002-12-02 16:07:56 +00:00
|
|
|
#include "powermgmt.h"
|
2004-01-14 00:13:04 +00:00
|
|
|
#include "bookmark.h"
|
2003-02-15 00:03:23 +00:00
|
|
|
#include "sprintf.h"
|
2003-03-10 16:31:02 +00:00
|
|
|
#include "keyboard.h"
|
2003-04-25 10:33:38 +00:00
|
|
|
#include "version.h"
|
2004-06-18 20:41:59 +00:00
|
|
|
#include "rtc.h"
|
2005-04-01 13:41:03 +00:00
|
|
|
#include "sound.h"
|
2005-10-07 17:38:05 +00:00
|
|
|
#include "dircache.h"
|
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == MAS3507D
|
2003-11-04 00:18:19 +00:00
|
|
|
void dac_line_in(bool enable);
|
2003-11-03 23:36:36 +00:00
|
|
|
#endif
|
2002-06-27 00:20:00 +00:00
|
|
|
struct user_settings global_settings;
|
2005-05-08 13:41:24 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2004-08-01 21:50:57 +00:00
|
|
|
const char rec_base_directory[] = REC_BASE_DIR;
|
2005-05-08 13:41:24 +00:00
|
|
|
#endif
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2005-07-13 12:48:22 +00:00
|
|
|
#include "pcmbuf.h"
|
2005-06-09 09:47:00 +00:00
|
|
|
#include "pcm_playback.h"
|
2005-09-24 15:22:48 +00:00
|
|
|
#include "dsp.h"
|
2005-06-09 09:47:00 +00:00
|
|
|
#endif
|
2004-09-19 21:58:37 +00:00
|
|
|
|
2005-09-24 15:22:48 +00:00
|
|
|
#define CONFIG_BLOCK_VERSION 28
|
2002-08-16 14:41:47 +00:00
|
|
|
#define CONFIG_BLOCK_SIZE 512
|
|
|
|
#define RTC_BLOCK_SIZE 44
|
2002-08-13 17:16:09 +00:00
|
|
|
|
2002-09-27 09:31:31 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#define MAX_LINES 10
|
|
|
|
#else
|
|
|
|
#define MAX_LINES 2
|
|
|
|
#endif
|
|
|
|
|
2005-04-15 12:08:49 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
#include "lcd-remote.h"
|
|
|
|
#endif
|
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
long lasttime = 0;
|
2005-02-11 18:41:40 +00:00
|
|
|
static long config_sector = 0; /* mark uninitialized */
|
2004-06-18 20:41:59 +00:00
|
|
|
static unsigned char config_block[CONFIG_BLOCK_SIZE];
|
|
|
|
|
|
|
|
|
|
|
|
/* descriptor for a configuration value */
|
|
|
|
/* (watch the struct packing and member sizes to keep this small) */
|
|
|
|
struct bit_entry
|
|
|
|
{
|
|
|
|
/* how many bits within the bitfield (1-32), MSB set if value is signed */
|
|
|
|
unsigned char bit_size; /* min 6+1 bit */
|
|
|
|
/* how many bytes in the global_settings struct (1,2,4) */
|
2004-06-19 09:39:25 +00:00
|
|
|
unsigned char byte_size; /* min 3 bits */
|
2004-06-18 20:41:59 +00:00
|
|
|
/* store position in global_settings struct */
|
|
|
|
short settings_offset; /* min 9 bit, better 10 */
|
|
|
|
/* default value */
|
|
|
|
int default_val; /* min 15 bit */
|
2004-06-19 09:39:25 +00:00
|
|
|
/* variable name in a .cfg file, NULL if not to be saved */
|
2004-06-18 20:41:59 +00:00
|
|
|
const char* cfg_name;
|
2004-06-19 09:39:25 +00:00
|
|
|
/* set of values, or NULL for a numerical value */
|
2004-06-18 20:41:59 +00:00
|
|
|
const char* cfg_val;
|
|
|
|
};
|
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
/********************************************
|
|
|
|
|
|
|
|
Config block as saved on the battery-packed RTC user RAM memory block
|
|
|
|
of 44 bytes, starting at offset 0x14 of the RTC memory space.
|
|
|
|
|
|
|
|
offset abs
|
|
|
|
0x00 0x14 "Roc" header signature: 0x52 0x6f 0x63
|
|
|
|
0x03 0x17 <version byte: 0x0>
|
2004-06-18 20:41:59 +00:00
|
|
|
0x04 0x18 start of bit-table
|
|
|
|
...
|
|
|
|
0x28,0x29 unused, not reachable by set_bits() without disturbing the next 2
|
|
|
|
0x2A,0x2B <checksum 2 bytes: xor of 0x00-0x29>
|
2002-07-15 11:02:12 +00:00
|
|
|
|
|
|
|
Config memory is reset to 0xff and initialized with 'factory defaults' if
|
|
|
|
a valid header & checksum is not found. Config version number is only
|
|
|
|
increased when information is _relocated_ or space is _reused_ so that old
|
2004-06-18 20:41:59 +00:00
|
|
|
versions can read and modify configuration changed by new versions.
|
|
|
|
Memory locations not used by a given version should not be
|
2002-07-15 11:02:12 +00:00
|
|
|
modified unless the header & checksum test fails.
|
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
Rest of config block, only saved to disk:
|
2004-06-18 20:41:59 +00:00
|
|
|
0x2C start of 2nd bit-table
|
|
|
|
...
|
2002-10-08 15:42:40 +00:00
|
|
|
0xB8 (char[20]) WPS file
|
|
|
|
0xCC (char[20]) Lang file
|
|
|
|
0xE0 (char[20]) Font file
|
2004-06-18 20:41:59 +00:00
|
|
|
0xF4-0xFF <unused>
|
2002-08-16 14:41:47 +00:00
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
*************************************/
|
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
/* The persistence of the global_settings members is now controlled by
|
|
|
|
the two tables below, rtc_bits and hd_bits.
|
|
|
|
New values can just be added to the end, it will be backwards
|
|
|
|
compatible. If you however change order, bitsize, etc. of existing
|
|
|
|
entries, you need to bump CONFIG_BLOCK_VERSION to break compatibility.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* convenience macro for both size and offset of global_settings member */
|
|
|
|
#define S_O(val) sizeof(global_settings.val), offsetof(struct user_settings, val)
|
|
|
|
#define SIGNED 0x80 /* for bitsize value with signed attribute */
|
|
|
|
|
|
|
|
/* some sets of values which are used more than once, to save memory */
|
|
|
|
static const char off_on[] = "off,on";
|
|
|
|
static const char off_on_ask[] = "off,on,ask";
|
2004-10-06 21:37:46 +00:00
|
|
|
static const char off_number_spell_hover[] = "off,number,spell,hover";
|
2005-05-08 13:41:24 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
static const char graphic_numeric[] = "graphic,numeric";
|
|
|
|
#endif
|
2004-06-18 20:41:59 +00:00
|
|
|
|
2005-04-04 20:16:01 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2005-04-04 09:12:12 +00:00
|
|
|
/* keep synchronous to trig_durations and
|
|
|
|
trigger_times in settings_apply_trigger */
|
|
|
|
static const char trig_durations_conf [] =
|
|
|
|
"0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min";
|
2005-04-04 20:16:01 +00:00
|
|
|
#endif
|
2005-04-04 09:12:12 +00:00
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
/* the part of the settings which ends up in the RTC RAM, where available
|
|
|
|
(those we either need early, save frequently, or without spinup) */
|
2004-07-20 19:13:46 +00:00
|
|
|
static const struct bit_entry rtc_bits[] =
|
2004-06-18 20:41:59 +00:00
|
|
|
{
|
|
|
|
/* placeholder, containing the size information */
|
|
|
|
{9, 0, 0, 0, NULL, NULL }, /* 9 bit to tell how far this is populated */
|
|
|
|
|
|
|
|
/* # of bits, offset+size, default, .cfg name, .cfg values */
|
|
|
|
/* sound */
|
|
|
|
{7, S_O(volume), 70, "volume", NULL }, /* 0...100 */
|
2004-06-21 13:42:37 +00:00
|
|
|
{8 | SIGNED, S_O(balance), 0, "balance", NULL }, /* -100...100 */
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC /* any MAS */
|
2004-06-21 13:42:37 +00:00
|
|
|
{5 | SIGNED, S_O(bass), 0, "bass", NULL }, /* -15..+15 / -12..+12 */
|
|
|
|
{5 | SIGNED, S_O(treble), 0, "treble", NULL }, /* -15..+15 / -12..+12 */
|
2005-06-16 21:20:00 +00:00
|
|
|
#elif defined HAVE_UDA1380
|
|
|
|
{5, S_O(bass), 0, "bass", NULL }, /* 0..+24 */
|
|
|
|
{3, S_O(treble), 0, "treble", NULL }, /* 0..+6 */
|
|
|
|
#endif
|
2005-08-29 21:15:27 +00:00
|
|
|
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
|
2004-06-18 20:41:59 +00:00
|
|
|
{5, S_O(loudness), 0, "loudness", NULL }, /* 0...17 */
|
2004-06-22 12:37:42 +00:00
|
|
|
{3, S_O(avc), 0, "auto volume", "off,20ms,2,4,8" },
|
2004-07-06 12:17:14 +00:00
|
|
|
{1, S_O(superbass), false, "superbass", off_on },
|
2004-06-18 20:41:59 +00:00
|
|
|
#endif
|
2005-01-12 00:24:15 +00:00
|
|
|
{3, S_O(channel_config), 0, "channels",
|
|
|
|
"stereo,mono,custom,mono left,mono right,karaoke" },
|
|
|
|
{8, S_O(stereo_width), 100, "stereo width", NULL},
|
2004-06-18 20:41:59 +00:00
|
|
|
/* playback */
|
2005-07-21 11:44:00 +00:00
|
|
|
{1, S_O(resume), false, "resume", off_on },
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(playlist_shuffle), false, "shuffle", off_on },
|
|
|
|
{16 | SIGNED, S_O(resume_index), -1, NULL, NULL },
|
|
|
|
{16 | SIGNED, S_O(resume_first_index), 0, NULL, NULL },
|
|
|
|
{32 | SIGNED, S_O(resume_offset), -1, NULL, NULL },
|
|
|
|
{32 | SIGNED, S_O(resume_seed), -1, NULL, NULL },
|
2005-08-21 23:01:12 +00:00
|
|
|
{3, S_O(repeat_mode), REPEAT_ALL, "repeat", "off,all,one,shuffle,ab" },
|
2004-06-18 20:41:59 +00:00
|
|
|
/* LCD */
|
|
|
|
{6, S_O(contrast), 40, "contrast", NULL },
|
2004-12-18 10:29:47 +00:00
|
|
|
#ifdef CONFIG_BACKLIGHT
|
|
|
|
#ifdef HAVE_CHARGING
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(backlight_on_when_charging), false,
|
|
|
|
"backlight when plugged", off_on },
|
2004-12-18 10:29:47 +00:00
|
|
|
#endif
|
2004-10-09 19:56:27 +00:00
|
|
|
{5, S_O(backlight_timeout), 5, "backlight timeout",
|
2004-06-18 20:41:59 +00:00
|
|
|
"off,on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90" },
|
2004-12-18 10:29:47 +00:00
|
|
|
#endif /* CONFIG_BACKLIGHT */
|
2004-06-18 20:41:59 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
{1, S_O(invert), false, "invert", off_on },
|
|
|
|
{1, S_O(flip_display), false, "flip display", off_on },
|
|
|
|
/* display */
|
2005-09-01 08:04:37 +00:00
|
|
|
{1, S_O(invert_cursor), false, "invert cursor", off_on },
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(statusbar), true, "statusbar", off_on },
|
|
|
|
{1, S_O(scrollbar), true, "scrollbar", off_on },
|
2004-10-09 20:54:15 +00:00
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(buttonbar), true, "buttonbar", off_on },
|
2004-10-09 20:54:15 +00:00
|
|
|
#endif
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(volume_type), 0, "volume display", graphic_numeric },
|
2005-01-30 13:48:44 +00:00
|
|
|
{1, S_O(battery_display), 0, "battery display", graphic_numeric },
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(timeformat), 0, "time format", "24hour,12hour" },
|
2005-07-28 08:36:24 +00:00
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2004-07-12 22:02:53 +00:00
|
|
|
{1, S_O(show_icons), true, "show icons", off_on },
|
2004-06-18 20:41:59 +00:00
|
|
|
/* system */
|
2005-01-12 00:24:15 +00:00
|
|
|
{4, S_O(poweroff), 10,
|
2004-06-18 20:41:59 +00:00
|
|
|
"idle poweroff", "off,1,2,3,4,5,6,7,8,9,10,15,30,45,60" },
|
|
|
|
{18, S_O(runtime), 0, NULL, NULL },
|
|
|
|
{18, S_O(topruntime), 0, NULL, NULL },
|
|
|
|
{15, S_O(max_files_in_playlist), 10000,
|
|
|
|
"max files in playlist", NULL }, /* 1000...20000 */
|
|
|
|
{14, S_O(max_files_in_dir), 400,
|
|
|
|
"max files in dir", NULL }, /* 50...10000 */
|
|
|
|
/* battery */
|
2004-10-10 10:28:21 +00:00
|
|
|
{12, S_O(battery_capacity), BATTERY_CAPACITY_MIN, "battery capacity",
|
|
|
|
NULL }, /* 1500...3200 for NiMH, 2200...3200 for LiIon,
|
2005-01-12 00:24:15 +00:00
|
|
|
500...1500 for Alkaline */
|
2004-10-10 01:25:32 +00:00
|
|
|
#ifdef HAVE_CHARGING
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(car_adapter_mode), false, "car adapter mode", off_on },
|
2004-10-10 01:25:32 +00:00
|
|
|
#endif
|
2005-01-12 00:24:15 +00:00
|
|
|
/* tuner */
|
2004-09-28 22:13:26 +00:00
|
|
|
#ifdef CONFIG_TUNER
|
2004-07-05 14:27:50 +00:00
|
|
|
{1, S_O(fm_force_mono), false, "force fm mono", off_on },
|
2004-07-12 15:06:48 +00:00
|
|
|
{8, S_O(last_frequency), 0, NULL, NULL }, /* Default: MIN_FREQ */
|
2004-07-05 18:09:00 +00:00
|
|
|
#endif
|
2004-06-18 20:41:59 +00:00
|
|
|
|
2005-01-30 16:25:46 +00:00
|
|
|
#if BATTERY_TYPES_COUNT > 1
|
|
|
|
{1, S_O(battery_type), 0, "battery type", "alkaline,nimh" },
|
|
|
|
#endif
|
|
|
|
|
2005-04-15 12:08:49 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
/* remote lcd */
|
2005-05-30 00:00:22 +00:00
|
|
|
{6, S_O(remote_contrast), 42, "remote contrast", NULL },
|
|
|
|
{1, S_O(remote_invert), false, "remote invert", off_on },
|
|
|
|
{5, S_O(remote_backlight_timeout), 5, "remote backlight timeout",
|
|
|
|
"off,on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90" },
|
2005-06-17 21:43:00 +00:00
|
|
|
{1, S_O(remote_flip_display), false, "remote flip display", off_on },
|
2005-04-15 12:08:49 +00:00
|
|
|
#endif
|
|
|
|
|
2005-08-08 19:23:28 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP /* move to LCD next time we bump version */
|
|
|
|
{1, S_O(bidi_support), false, "bidi hebrew/arabic", off_on },
|
|
|
|
#endif
|
|
|
|
|
2005-07-28 08:36:24 +00:00
|
|
|
/* new stuff to be added here */
|
|
|
|
/* If values are just added to the end, no need to bump the version. */
|
|
|
|
|
2005-08-08 19:23:28 +00:00
|
|
|
/* Current sum of bits: 277 (worst case, but w/o remote lcd) */
|
2004-06-18 20:41:59 +00:00
|
|
|
/* Sum of all bit sizes must not grow beyond 288! */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* the part of the settings which ends up in HD sector only */
|
2004-07-20 19:13:46 +00:00
|
|
|
static const struct bit_entry hd_bits[] =
|
2004-06-18 20:41:59 +00:00
|
|
|
{
|
|
|
|
/* This table starts after the 44 RTC bytes = 352 bits. */
|
|
|
|
/* Here we need 11 bits to tell how far this is populated. */
|
|
|
|
|
|
|
|
/* placeholder, containing the size information */
|
|
|
|
{11, 0, 0, 0, NULL, NULL }, /* 11 bit to tell how far this is populated */
|
|
|
|
|
|
|
|
/* # of bits, offset+size, default, .cfg name, .cfg values */
|
|
|
|
/* more display */
|
2004-12-18 10:29:47 +00:00
|
|
|
#ifdef CONFIG_BACKLIGHT
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(caption_backlight), false, "caption backlight", off_on },
|
2004-10-09 19:56:27 +00:00
|
|
|
#endif
|
2004-10-15 20:30:29 +00:00
|
|
|
{4, S_O(scroll_speed), 9, "scroll speed", NULL }, /* 0...15 */
|
2005-07-28 08:36:24 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#if LCD_WIDTH > 127
|
|
|
|
{8, S_O(scroll_step), 6, "scroll step", NULL }, /* 1...160 */
|
|
|
|
#else
|
2004-06-18 20:41:59 +00:00
|
|
|
{7, S_O(scroll_step), 6, "scroll step", NULL }, /* 1...112 */
|
2005-07-28 08:36:24 +00:00
|
|
|
#endif
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
2004-06-18 20:41:59 +00:00
|
|
|
{8, S_O(scroll_delay), 100, "scroll delay", NULL }, /* 0...250 */
|
|
|
|
{8, S_O(bidir_limit), 50, "bidir limit", NULL }, /* 0...200 */
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
{3, S_O(jump_scroll), 0, "jump scroll", NULL }, /* 0...5 */
|
|
|
|
{8, S_O(jump_scroll_delay), 50, "jump scroll delay", NULL }, /* 0...250 */
|
|
|
|
#endif
|
|
|
|
/* more playback */
|
|
|
|
{1, S_O(play_selected), true, "play selected", off_on },
|
|
|
|
{1, S_O(fade_on_stop), true, "volume fade", off_on },
|
2004-06-23 08:12:19 +00:00
|
|
|
{4, S_O(ff_rewind_min_step), FF_REWIND_1000,
|
2004-06-18 20:41:59 +00:00
|
|
|
"scan min step", "1,2,3,4,5,6,8,10,15,20,25,30,45,60" },
|
|
|
|
{4, S_O(ff_rewind_accel), 3, "scan accel", NULL },
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2005-07-21 11:44:00 +00:00
|
|
|
{3, S_O(buffer_margin), 0, "antiskip",
|
|
|
|
"5s,15s,30s,1min,2min,3min,5min,10min" },
|
|
|
|
#else
|
2004-06-18 20:41:59 +00:00
|
|
|
{3, S_O(buffer_margin), 0, "antiskip", NULL },
|
2005-07-21 11:44:00 +00:00
|
|
|
#endif
|
2004-06-18 20:41:59 +00:00
|
|
|
/* disk */
|
2004-10-09 22:04:47 +00:00
|
|
|
#ifndef HAVE_MMC
|
2004-06-18 20:41:59 +00:00
|
|
|
#ifdef HAVE_ATA_POWER_OFF
|
|
|
|
{1, S_O(disk_poweroff), false, "disk poweroff", off_on },
|
|
|
|
#endif
|
|
|
|
{8, S_O(disk_spindown), 5, "disk spindown", NULL },
|
2005-07-28 08:36:24 +00:00
|
|
|
#endif /* HAVE_MMC */
|
2004-06-18 20:41:59 +00:00
|
|
|
/* browser */
|
2005-06-21 19:25:55 +00:00
|
|
|
{3, S_O(dirfilter), SHOW_SUPPORTED,
|
2005-01-17 11:37:36 +00:00
|
|
|
"show files", "all,supported,music,playlists,id3 database" },
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(sort_case), false, "sort case", off_on },
|
|
|
|
{1, S_O(browse_current), false, "follow playlist", off_on },
|
|
|
|
/* playlist */
|
|
|
|
{1, S_O(playlist_viewer_icons), true, "playlist viewer icons", off_on },
|
2004-10-10 01:25:32 +00:00
|
|
|
{1, S_O(playlist_viewer_indices), true,
|
2004-06-18 20:41:59 +00:00
|
|
|
"playlist viewer indices", off_on },
|
|
|
|
{1, S_O(playlist_viewer_track_display), 0,
|
|
|
|
"playlist viewer track display", "track name,full path" },
|
|
|
|
{2, S_O(recursive_dir_insert), RECURSE_OFF,
|
|
|
|
"recursive directory insert", off_on_ask },
|
|
|
|
/* bookmarks */
|
|
|
|
{3, S_O(autocreatebookmark), BOOKMARK_NO, "autocreate bookmarks",
|
|
|
|
"off,on,ask,recent only - on,recent only - ask" },
|
|
|
|
{2, S_O(autoloadbookmark), BOOKMARK_NO,
|
|
|
|
"autoload bookmarks", off_on_ask },
|
|
|
|
{2, S_O(usemrb), BOOKMARK_NO,
|
|
|
|
"use most-recent-bookmarks", "off,on,unique only" },
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
/* peak meter */
|
|
|
|
{5, S_O(peak_meter_clip_hold), 16, "peak meter clip hold", /* 0...25 */
|
|
|
|
"on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90,2min,3min,5min,10min,20min,45min,90min" },
|
2005-08-29 20:07:17 +00:00
|
|
|
{5, S_O(peak_meter_hold), 3, "peak meter hold",
|
2004-06-18 20:41:59 +00:00
|
|
|
"off,200ms,300ms,500ms,1,2,3,4,5,6,7,8,9,10,15,20,30,1min" },
|
|
|
|
{7, S_O(peak_meter_release), 8, "peak meter release", NULL }, /* 0...126 */
|
2004-06-23 07:15:22 +00:00
|
|
|
{1, S_O(peak_meter_dbfs), true, "peak meter dbfs", off_on },
|
2004-06-18 20:41:59 +00:00
|
|
|
{7, S_O(peak_meter_min), 60, "peak meter min", NULL }, /* 0...100 */
|
|
|
|
{7, S_O(peak_meter_max), 0, "peak meter max", NULL }, /* 0...100 */
|
|
|
|
#endif
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == MAS3587F
|
2004-06-18 20:41:59 +00:00
|
|
|
/* recording */
|
|
|
|
{1, S_O(rec_editable), false, "editable recordings", off_on },
|
2004-10-27 09:24:02 +00:00
|
|
|
{4, S_O(rec_timesplit), 0, "rec timesplit", /* 0...15 */
|
|
|
|
"off,00:05,00:10,00:15,00:30,01:00,01:14,01:20,02:00,04:00,06:00,08:00,10:00,12:00,18:00,24:00" },
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(rec_channels), 0, "rec channels", "stereo,mono" },
|
|
|
|
{4, S_O(rec_mic_gain), 8, "rec mic gain", NULL },
|
|
|
|
{3, S_O(rec_quality), 5, "rec quality", NULL },
|
2005-09-06 20:48:28 +00:00
|
|
|
#ifdef HAVE_SPDIF_IN
|
|
|
|
{2, S_O(rec_source), 0 /* 0=mic */, "rec source", "mic,line,spdif" },
|
|
|
|
#else
|
|
|
|
{1, S_O(rec_source), 0 /* 0=mic */, "rec source", "mic,line" },
|
|
|
|
#endif
|
2004-06-18 20:41:59 +00:00
|
|
|
{3, S_O(rec_frequency), 0, /* 0=44.1kHz */
|
|
|
|
"rec frequency", "44,48,32,22,24,16" },
|
|
|
|
{4, S_O(rec_left_gain), 2, /* 0dB */
|
|
|
|
"rec left gain", NULL }, /* 0...15 */
|
|
|
|
{4, S_O(rec_right_gain), 2, /* 0dB */
|
|
|
|
"rec right gain", NULL }, /* 0...15 */
|
2004-10-04 13:12:31 +00:00
|
|
|
{5, S_O(rec_prerecord_time), 0, "prerecording time", NULL }, /* 0...30 */
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(rec_directory), 0, /* rec_base_directory */
|
|
|
|
"rec directory", REC_BASE_DIR ",current" },
|
|
|
|
#endif
|
2005-08-29 21:15:27 +00:00
|
|
|
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
|
2005-07-28 08:36:24 +00:00
|
|
|
{7, S_O(mdb_strength), 0, "mdb strength", NULL},
|
|
|
|
{7, S_O(mdb_harmonics), 0, "mdb harmonics", NULL},
|
|
|
|
{9, S_O(mdb_center), 0, "mdb center", NULL},
|
|
|
|
{9, S_O(mdb_shape), 0, "mdb shape", NULL},
|
|
|
|
{1, S_O(mdb_enable), 0, "mdb enable", off_on},
|
|
|
|
#endif
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == MAS3507D
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(line_in), false, "line in", off_on },
|
|
|
|
#endif
|
|
|
|
/* voice */
|
2004-10-06 21:37:46 +00:00
|
|
|
{2, S_O(talk_dir), 0, "talk dir", off_number_spell_hover },
|
|
|
|
{2, S_O(talk_file), 0, "talk file", off_number_spell_hover },
|
2004-06-18 20:41:59 +00:00
|
|
|
{1, S_O(talk_menu), true, "talk menu", off_on },
|
|
|
|
|
2004-06-22 09:16:44 +00:00
|
|
|
{2, S_O(sort_file), 0, "sort files", "alpha,oldest,newest,type" },
|
|
|
|
{2, S_O(sort_dir), 0, "sort dirs", "alpha,oldest,newest" },
|
2004-07-27 22:23:01 +00:00
|
|
|
{1, S_O(id3_v1_first), 0, "id3 tag priority", "v2-v1,v1-v2"},
|
2004-07-27 19:20:51 +00:00
|
|
|
|
2005-02-04 10:37:21 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
{1, S_O(rec_startup), false, "rec screen on startup", off_on },
|
2005-04-04 09:12:12 +00:00
|
|
|
|
|
|
|
/* values for the trigger */
|
|
|
|
{8 | SIGNED, S_O(rec_start_thres), -35, "trigger start threshold", NULL},
|
|
|
|
{8 | SIGNED, S_O(rec_stop_thres), -45, "trigger stop threshold", NULL},
|
|
|
|
{4, S_O(rec_start_duration), 0, "trigger start duration", trig_durations_conf},
|
|
|
|
{4, S_O(rec_stop_postrec), 2, "trigger stop postrec", trig_durations_conf},
|
|
|
|
{4, S_O(rec_stop_gap), 1, "trigger min gap", trig_durations_conf},
|
2005-09-02 07:27:07 +00:00
|
|
|
{4, S_O(rec_trigger_mode ), 0, "trigger mode", "off,once,repeat"},
|
2005-02-04 10:37:21 +00:00
|
|
|
#endif
|
2004-06-18 20:41:59 +00:00
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2005-07-22 16:46:27 +00:00
|
|
|
{3, S_O(crossfade_duration), 0, "crossfade duration", "1s,2s,4s,6s,8s,10s,12s,14s"},
|
2005-06-09 09:47:00 +00:00
|
|
|
#endif
|
2005-06-20 17:03:09 +00:00
|
|
|
|
|
|
|
#if CONFIG_BACKLIGHT == BL_IRIVER
|
|
|
|
/* backlight fading */
|
|
|
|
{2, S_O(backlight_fade_in), 1, "backlight fade in", "off,500ms,1s,2s"},
|
|
|
|
{3, S_O(backlight_fade_out), 3, "backlight fade out",
|
|
|
|
"off,500ms,1s,2s,3s,4s,5s,10s"},
|
|
|
|
#endif
|
2005-07-01 09:42:39 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SPDIF_POWER
|
|
|
|
{1, S_O(spdif_enable), false, "spdif enable", off_on},
|
|
|
|
#endif
|
2005-07-01 11:25:16 +00:00
|
|
|
|
|
|
|
{1, S_O(next_folder), false, "move to next folder", off_on },
|
2005-07-02 10:50:42 +00:00
|
|
|
{1, S_O(runtimedb), false, "gather runtime data", off_on },
|
2005-07-01 11:25:16 +00:00
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2005-07-22 16:46:27 +00:00
|
|
|
{2, S_O(crossfade), 0, "crossfade type", "off,crossfade,mix"},
|
2005-07-24 15:32:28 +00:00
|
|
|
{1, S_O(replaygain), false, "replaygain", off_on },
|
2005-09-24 15:22:48 +00:00
|
|
|
{2, S_O(replaygain_type), REPLAYGAIN_ALBUM, "replaygain type",
|
|
|
|
"track,album,track shuffle" },
|
2005-07-24 15:32:28 +00:00
|
|
|
{1, S_O(replaygain_noclip), false, "replaygain noclip", off_on },
|
2005-08-14 06:22:53 +00:00
|
|
|
{8 | SIGNED, S_O(replaygain_preamp), 0, "replaygain preamp", NULL },
|
2005-08-20 21:17:41 +00:00
|
|
|
{2, S_O(beep), 0, "off,weak,moderate,strong", NULL },
|
2005-07-22 16:46:27 +00:00
|
|
|
#endif
|
2005-10-07 17:38:05 +00:00
|
|
|
#ifdef HAVE_DIRCACHE
|
|
|
|
{1, S_O(dircache), false, "dircache", off_on },
|
|
|
|
{22, S_O(dircache_size), 0, NULL, NULL },
|
|
|
|
#endif
|
2005-07-22 16:46:27 +00:00
|
|
|
|
2005-07-28 08:36:24 +00:00
|
|
|
/* If values are just added to the end, no need to bump the version. */
|
2005-02-04 10:37:21 +00:00
|
|
|
/* new stuff to be added at the end */
|
2005-07-28 08:36:24 +00:00
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
/* Sum of all bit sizes must not grow beyond 0xB8*8 = 1472 */
|
|
|
|
};
|
|
|
|
|
2005-05-04 22:30:36 +00:00
|
|
|
/* helper function to extract n (<=32) bits from an arbitrary position
|
|
|
|
* counting from LSB to MSB */
|
2004-06-18 20:41:59 +00:00
|
|
|
static unsigned long get_bits(
|
2004-08-18 01:09:31 +00:00
|
|
|
const unsigned long* p, /* the start of the bitfield array */
|
2004-06-18 20:41:59 +00:00
|
|
|
unsigned int from, /* bit no. to start reading from */
|
|
|
|
unsigned int size) /* how many bits to read */
|
|
|
|
{
|
2005-05-04 22:30:36 +00:00
|
|
|
unsigned int long_index = from / 32;
|
|
|
|
unsigned int bit_index = from % 32;
|
2004-06-18 20:41:59 +00:00
|
|
|
unsigned long result;
|
|
|
|
|
2005-05-04 22:30:36 +00:00
|
|
|
result = p[long_index] >> bit_index;
|
2004-06-18 20:41:59 +00:00
|
|
|
|
2005-05-04 22:30:36 +00:00
|
|
|
if (bit_index + size > 32) /* crossing longword boundary */
|
|
|
|
result |= p[long_index+1] << (32 - bit_index);
|
2004-06-18 20:41:59 +00:00
|
|
|
|
2005-05-04 22:30:36 +00:00
|
|
|
result &= 0xFFFFFFFF >> (32 - size);
|
2004-06-18 20:41:59 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-05-04 22:30:36 +00:00
|
|
|
/* helper function to set n (<=32) bits to an arbitrary position,
|
|
|
|
* counting from LSB to MSB */
|
2004-06-18 20:41:59 +00:00
|
|
|
static void set_bits(
|
|
|
|
unsigned long* p, /* the start of the bitfield array */
|
|
|
|
unsigned int from, /* bit no. to start writing into */
|
|
|
|
unsigned int size, /* how many bits to change */
|
|
|
|
unsigned long value) /* content (LSBs will be taken) */
|
|
|
|
{
|
2005-05-04 22:30:36 +00:00
|
|
|
unsigned int long_index = from / 32;
|
|
|
|
unsigned int bit_index = from % 32;
|
2004-06-18 20:41:59 +00:00
|
|
|
unsigned long mask;
|
|
|
|
|
2005-05-04 22:30:36 +00:00
|
|
|
mask = 0xFFFFFFFF >> (32 - size);
|
|
|
|
value &= mask;
|
|
|
|
mask <<= bit_index;
|
|
|
|
|
|
|
|
if (bit_index + size > 32)
|
|
|
|
p[long_index+1] =
|
|
|
|
(p[long_index+1] & (0xFFFFFFFF << (bit_index + size - 32)))
|
|
|
|
| (value >> (32 - bit_index));
|
|
|
|
|
|
|
|
p[long_index] = (p[long_index] & ~mask) | (value << bit_index);
|
2004-06-18 20:41:59 +00:00
|
|
|
}
|
2002-07-15 11:02:12 +00:00
|
|
|
|
|
|
|
/*
|
2002-08-16 14:41:47 +00:00
|
|
|
* Calculates the checksum for the config block and returns it
|
2002-07-15 11:02:12 +00:00
|
|
|
*/
|
|
|
|
|
2004-08-18 01:09:31 +00:00
|
|
|
static unsigned short calculate_config_checksum(const unsigned char* buf)
|
2002-07-15 11:02:12 +00:00
|
|
|
{
|
2002-08-13 17:16:09 +00:00
|
|
|
unsigned int i;
|
|
|
|
unsigned char cksum[2];
|
2002-07-15 11:02:12 +00:00
|
|
|
cksum[0] = cksum[1] = 0;
|
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
for (i=0; i < RTC_BLOCK_SIZE - 2; i+=2 ) {
|
|
|
|
cksum[0] ^= buf[i];
|
|
|
|
cksum[1] ^= buf[i+1];
|
2002-07-15 11:02:12 +00:00
|
|
|
}
|
2002-08-13 17:16:09 +00:00
|
|
|
|
|
|
|
return (cksum[0] << 8) | cksum[1];
|
2002-07-15 11:02:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* initialize the config block buffer
|
|
|
|
*/
|
|
|
|
static void init_config_buffer( void )
|
|
|
|
{
|
|
|
|
DEBUGF( "init_config_buffer()\n" );
|
|
|
|
|
2004-06-19 15:50:02 +00:00
|
|
|
/* reset to 0 - all unused */
|
|
|
|
memset(config_block, 0, CONFIG_BLOCK_SIZE);
|
2002-07-15 11:02:12 +00:00
|
|
|
/* insert header */
|
2002-08-16 14:41:47 +00:00
|
|
|
config_block[0] = 'R';
|
|
|
|
config_block[1] = 'o';
|
|
|
|
config_block[2] = 'c';
|
|
|
|
config_block[3] = CONFIG_BLOCK_VERSION;
|
2002-07-15 11:02:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-08-13 17:16:09 +00:00
|
|
|
* save the config block buffer to disk or RTC RAM
|
2002-07-15 11:02:12 +00:00
|
|
|
*/
|
|
|
|
static int save_config_buffer( void )
|
|
|
|
{
|
2002-08-13 17:16:09 +00:00
|
|
|
unsigned short chksum;
|
|
|
|
#ifdef HAVE_RTC
|
|
|
|
unsigned int i;
|
|
|
|
#endif
|
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
/* update the checksum in the end of the block before saving */
|
2002-08-16 14:41:47 +00:00
|
|
|
chksum = calculate_config_checksum(config_block);
|
|
|
|
config_block[ RTC_BLOCK_SIZE - 2 ] = chksum >> 8;
|
|
|
|
config_block[ RTC_BLOCK_SIZE - 1 ] = chksum & 0xff;
|
2002-08-13 17:16:09 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_RTC
|
2002-07-15 11:02:12 +00:00
|
|
|
/* FIXME: okay, it _would_ be cleaner and faster to implement rtc_write so
|
|
|
|
that it would write a number of bytes at a time since the RTC chip
|
|
|
|
supports that, but this will have to do for now 8-) */
|
2002-08-16 14:41:47 +00:00
|
|
|
for (i=0; i < RTC_BLOCK_SIZE; i++ ) {
|
|
|
|
int r = rtc_write(0x14+i, config_block[i]);
|
2002-07-15 11:02:12 +00:00
|
|
|
if (r) {
|
2002-10-14 09:11:59 +00:00
|
|
|
DEBUGF( "save_config_buffer: rtc_write failed at addr 0x%02x: %d\n",
|
|
|
|
14+i, r );
|
2002-07-15 11:02:12 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
2002-08-13 17:16:09 +00:00
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
#endif
|
2002-08-13 17:16:09 +00:00
|
|
|
|
2004-09-28 18:09:10 +00:00
|
|
|
if (config_sector != 0)
|
|
|
|
ata_delayed_write( config_sector, config_block);
|
2002-08-13 17:16:09 +00:00
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-06-27 00:20:00 +00:00
|
|
|
/*
|
2002-08-13 17:16:09 +00:00
|
|
|
* load the config block buffer from disk or RTC RAM
|
2002-06-27 00:20:00 +00:00
|
|
|
*/
|
2004-06-19 15:50:02 +00:00
|
|
|
static int load_config_buffer(int which)
|
2002-06-27 00:20:00 +00:00
|
|
|
{
|
2002-08-13 17:16:09 +00:00
|
|
|
unsigned short chksum;
|
2002-08-16 14:41:47 +00:00
|
|
|
bool correct = false;
|
2002-08-13 17:16:09 +00:00
|
|
|
|
2004-06-19 15:50:02 +00:00
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
DEBUGF( "load_config_buffer()\n" );
|
2002-08-13 17:16:09 +00:00
|
|
|
|
2004-06-19 15:50:02 +00:00
|
|
|
if (which & SETTINGS_HD)
|
|
|
|
{
|
2004-09-28 18:09:10 +00:00
|
|
|
if (config_sector != 0) {
|
2004-12-28 22:16:07 +00:00
|
|
|
ata_read_sectors(IF_MV2(0,) config_sector, 1, config_block);
|
2004-06-19 15:50:02 +00:00
|
|
|
/* calculate the checksum, check it and the header */
|
|
|
|
chksum = calculate_config_checksum(config_block);
|
2002-08-16 14:41:47 +00:00
|
|
|
|
2004-06-19 15:50:02 +00:00
|
|
|
if (config_block[0] == 'R' &&
|
|
|
|
config_block[1] == 'o' &&
|
|
|
|
config_block[2] == 'c' &&
|
|
|
|
config_block[3] == CONFIG_BLOCK_VERSION &&
|
|
|
|
(chksum >> 8) == config_block[RTC_BLOCK_SIZE - 2] &&
|
|
|
|
(chksum & 0xff) == config_block[RTC_BLOCK_SIZE - 1])
|
|
|
|
{
|
|
|
|
DEBUGF( "load_config_buffer: header & checksum test ok\n" );
|
|
|
|
correct = true;
|
|
|
|
}
|
2002-08-16 14:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-13 17:16:09 +00:00
|
|
|
#ifdef HAVE_RTC
|
2004-03-13 00:04:58 +00:00
|
|
|
if(!correct)
|
|
|
|
{
|
|
|
|
/* If the disk sector was incorrect, reinit the buffer */
|
2004-06-19 15:50:02 +00:00
|
|
|
memset(config_block, 0, CONFIG_BLOCK_SIZE);
|
2004-03-13 00:04:58 +00:00
|
|
|
}
|
2002-08-16 14:41:47 +00:00
|
|
|
|
2004-06-19 15:50:02 +00:00
|
|
|
if (which & SETTINGS_RTC)
|
2002-08-13 17:16:09 +00:00
|
|
|
{
|
2004-06-19 15:50:02 +00:00
|
|
|
unsigned int i;
|
|
|
|
unsigned char rtc_block[RTC_BLOCK_SIZE];
|
|
|
|
|
|
|
|
/* read rtc block */
|
|
|
|
for (i=0; i < RTC_BLOCK_SIZE; i++ )
|
|
|
|
rtc_block[i] = rtc_read(0x14+i);
|
|
|
|
|
|
|
|
chksum = calculate_config_checksum(rtc_block);
|
|
|
|
|
|
|
|
/* if rtc block is ok, use that */
|
|
|
|
if (rtc_block[0] == 'R' &&
|
|
|
|
rtc_block[1] == 'o' &&
|
|
|
|
rtc_block[2] == 'c' &&
|
|
|
|
rtc_block[3] == CONFIG_BLOCK_VERSION &&
|
|
|
|
(chksum >> 8) == rtc_block[RTC_BLOCK_SIZE - 2] &&
|
|
|
|
(chksum & 0xff) == rtc_block[RTC_BLOCK_SIZE - 1])
|
|
|
|
{
|
|
|
|
memcpy(config_block, rtc_block, RTC_BLOCK_SIZE);
|
|
|
|
correct = true;
|
|
|
|
}
|
2002-08-13 17:16:09 +00:00
|
|
|
}
|
2002-08-16 14:41:47 +00:00
|
|
|
#endif
|
2002-07-28 16:09:44 +00:00
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
if ( !correct ) {
|
|
|
|
/* if checksum is not valid, clear the config buffer */
|
|
|
|
DEBUGF( "load_config_buffer: header & checksum test failed\n" );
|
|
|
|
init_config_buffer();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2002-07-28 16:09:44 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
|
|
|
|
/* helper to save content of global_settings into a bitfield,
|
|
|
|
as described per table */
|
|
|
|
static void save_bit_table(const struct bit_entry* p_table, int count, int bitstart)
|
|
|
|
{
|
|
|
|
unsigned long* p_bitfield = (unsigned long*)config_block; /* 32 bit addr. */
|
|
|
|
unsigned long value; /* 32 bit content */
|
|
|
|
int i;
|
|
|
|
const struct bit_entry* p_run = p_table; /* start after the size info */
|
|
|
|
int curr_bit = bitstart + p_table->bit_size;
|
|
|
|
count--; /* first is excluded from loop */
|
|
|
|
|
|
|
|
for (i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
p_run++;
|
|
|
|
/* could do a memcpy, but that would be endian-dependent */
|
|
|
|
switch(p_run->byte_size)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
value = ((unsigned char*)&global_settings)[p_run->settings_offset];
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
value = ((unsigned short*)&global_settings)[p_run->settings_offset/2];
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
value = ((unsigned int*)&global_settings)[p_run->settings_offset/4];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DEBUGF( "illegal size!" );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
set_bits(p_bitfield, curr_bit, p_run->bit_size & 0x3F, value);
|
|
|
|
curr_bit += p_run->bit_size & 0x3F;
|
|
|
|
}
|
|
|
|
set_bits(p_bitfield, bitstart, p_table->bit_size, /* write size */
|
|
|
|
curr_bit); /* = position after last element */
|
|
|
|
}
|
|
|
|
|
2004-09-28 18:09:10 +00:00
|
|
|
/*
|
|
|
|
* figure out the config sector from the partition table and the
|
|
|
|
* mounted file system
|
|
|
|
*/
|
|
|
|
void settings_calc_config_sector(void)
|
|
|
|
{
|
|
|
|
#ifdef SIMULATOR
|
|
|
|
config_sector = 61;
|
|
|
|
#else
|
2005-02-11 18:41:40 +00:00
|
|
|
int i;
|
|
|
|
long partition_start;
|
|
|
|
long sector = 0;
|
2004-09-28 18:09:10 +00:00
|
|
|
|
2004-12-28 22:16:07 +00:00
|
|
|
if (fat_startsector(IF_MV(0)) != 0) /* There is a partition table */
|
2004-09-28 18:09:10 +00:00
|
|
|
{
|
|
|
|
sector = 61;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
partition_start = disk_partinfo(i)->start;
|
|
|
|
if (partition_start != 0 && (partition_start - 2) < sector)
|
|
|
|
sector = partition_start - 2;
|
|
|
|
}
|
|
|
|
if (sector < 0)
|
|
|
|
sector = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
config_sector = sector;
|
|
|
|
#endif
|
|
|
|
}
|
2004-06-18 20:41:59 +00:00
|
|
|
|
2002-06-27 00:20:00 +00:00
|
|
|
/*
|
2002-07-15 11:02:12 +00:00
|
|
|
* persist all runtime user settings to disk or RTC RAM
|
2002-06-27 00:20:00 +00:00
|
|
|
*/
|
2002-07-15 11:02:12 +00:00
|
|
|
int settings_save( void )
|
2002-06-27 00:20:00 +00:00
|
|
|
{
|
2002-12-02 16:07:56 +00:00
|
|
|
{
|
2003-07-04 08:20:30 +00:00
|
|
|
int elapsed_secs;
|
2002-12-02 16:07:56 +00:00
|
|
|
|
2003-07-04 08:20:30 +00:00
|
|
|
elapsed_secs = (current_tick - lasttime) / HZ;
|
|
|
|
global_settings.runtime += elapsed_secs;
|
|
|
|
lasttime += (elapsed_secs * HZ);
|
2002-12-04 11:25:56 +00:00
|
|
|
|
2002-12-02 16:07:56 +00:00
|
|
|
if ( global_settings.runtime > global_settings.topruntime )
|
|
|
|
global_settings.topruntime = global_settings.runtime;
|
|
|
|
}
|
2004-06-18 20:41:59 +00:00
|
|
|
|
|
|
|
/* serialize scalar values into RTC and HD sector, specified via table */
|
|
|
|
save_bit_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), 4*8);
|
|
|
|
save_bit_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), RTC_BLOCK_SIZE*8);
|
2002-12-12 15:20:37 +00:00
|
|
|
|
2002-10-08 15:42:40 +00:00
|
|
|
strncpy(&config_block[0xb8], global_settings.wps_file, MAX_FILENAME);
|
|
|
|
strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME);
|
|
|
|
strncpy(&config_block[0xe0], global_settings.font_file, MAX_FILENAME);
|
2002-08-16 14:41:47 +00:00
|
|
|
|
2002-07-28 16:09:44 +00:00
|
|
|
if(save_config_buffer())
|
|
|
|
{
|
|
|
|
lcd_clear_display();
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2002-09-18 14:08:05 +00:00
|
|
|
lcd_puts(0, 0, str(LANG_SETTINGS_SAVE_PLAYER));
|
|
|
|
lcd_puts(0, 1, str(LANG_SETTINGS_BATTERY_PLAYER));
|
2002-07-28 16:09:44 +00:00
|
|
|
#else
|
2002-09-18 14:08:05 +00:00
|
|
|
lcd_puts(4, 2, str(LANG_SETTINGS_SAVE_RECORDER));
|
|
|
|
lcd_puts(2, 4, str(LANG_SETTINGS_BATTERY_RECORDER));
|
2002-07-28 16:09:44 +00:00
|
|
|
lcd_update();
|
|
|
|
#endif
|
|
|
|
sleep(HZ*2);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
2002-06-27 00:20:00 +00:00
|
|
|
}
|
|
|
|
|
2002-10-29 12:09:15 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
/**
|
|
|
|
* Applies the range infos stored in global_settings to
|
|
|
|
* the peak meter.
|
|
|
|
*/
|
|
|
|
void settings_apply_pm_range(void)
|
|
|
|
{
|
|
|
|
int pm_min, pm_max;
|
|
|
|
|
|
|
|
/* depending on the scale mode (dBfs or percent) the values
|
|
|
|
of global_settings.peak_meter_dbfs have different meanings */
|
|
|
|
if (global_settings.peak_meter_dbfs)
|
|
|
|
{
|
|
|
|
/* convert to dBfs * 100 */
|
|
|
|
pm_min = -(((int)global_settings.peak_meter_min) * 100);
|
|
|
|
pm_max = -(((int)global_settings.peak_meter_max) * 100);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* percent is stored directly -> no conversion */
|
|
|
|
pm_min = global_settings.peak_meter_min;
|
|
|
|
pm_max = global_settings.peak_meter_max;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* apply the range */
|
|
|
|
peak_meter_init_range(global_settings.peak_meter_dbfs, pm_min, pm_max);
|
|
|
|
}
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
|
|
|
|
2004-07-06 12:17:14 +00:00
|
|
|
void sound_settings_apply(void)
|
2002-10-03 09:31:01 +00:00
|
|
|
{
|
2005-04-01 13:41:03 +00:00
|
|
|
sound_set(SOUND_BASS, global_settings.bass);
|
|
|
|
sound_set(SOUND_TREBLE, global_settings.treble);
|
|
|
|
sound_set(SOUND_BALANCE, global_settings.balance);
|
|
|
|
sound_set(SOUND_VOLUME, global_settings.volume);
|
|
|
|
sound_set(SOUND_CHANNELS, global_settings.channel_config);
|
|
|
|
sound_set(SOUND_STEREO_WIDTH, global_settings.stereo_width);
|
2005-08-29 21:15:27 +00:00
|
|
|
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
|
2005-04-01 13:41:03 +00:00
|
|
|
sound_set(SOUND_LOUDNESS, global_settings.loudness);
|
|
|
|
sound_set(SOUND_AVC, global_settings.avc);
|
|
|
|
sound_set(SOUND_MDB_STRENGTH, global_settings.mdb_strength);
|
|
|
|
sound_set(SOUND_MDB_HARMONICS, global_settings.mdb_harmonics);
|
|
|
|
sound_set(SOUND_MDB_CENTER, global_settings.mdb_center);
|
|
|
|
sound_set(SOUND_MDB_SHAPE, global_settings.mdb_shape);
|
|
|
|
sound_set(SOUND_MDB_ENABLE, global_settings.mdb_enable);
|
|
|
|
sound_set(SOUND_SUPERBASS, global_settings.superbass);
|
2002-10-03 09:31:01 +00:00
|
|
|
#endif
|
2004-07-06 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void settings_apply(void)
|
|
|
|
{
|
|
|
|
char buf[64];
|
|
|
|
|
|
|
|
sound_settings_apply();
|
2002-10-03 09:31:01 +00:00
|
|
|
|
2005-04-04 12:06:29 +00:00
|
|
|
audio_set_buffer_margin(global_settings.buffer_margin);
|
2003-09-04 22:49:33 +00:00
|
|
|
|
2002-10-03 09:31:01 +00:00
|
|
|
lcd_set_contrast(global_settings.contrast);
|
|
|
|
lcd_scroll_speed(global_settings.scroll_speed);
|
2005-04-15 12:08:49 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2005-06-17 21:43:00 +00:00
|
|
|
lcd_remote_set_contrast(global_settings.remote_contrast);
|
|
|
|
lcd_remote_set_invert_display(global_settings.remote_invert);
|
|
|
|
lcd_remote_set_flip(global_settings.remote_flip_display);
|
2005-05-30 00:00:22 +00:00
|
|
|
remote_backlight_set_timeout(global_settings.remote_backlight_timeout);
|
2005-06-17 21:43:00 +00:00
|
|
|
#endif
|
2002-10-03 09:31:01 +00:00
|
|
|
backlight_set_timeout(global_settings.backlight_timeout);
|
|
|
|
backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
|
2005-06-20 17:03:09 +00:00
|
|
|
#if CONFIG_BACKLIGHT == BL_IRIVER
|
|
|
|
backlight_set_fade_in(global_settings.backlight_fade_in);
|
|
|
|
backlight_set_fade_out(global_settings.backlight_fade_out);
|
|
|
|
#endif
|
2002-10-03 09:31:01 +00:00
|
|
|
ata_spindown(global_settings.disk_spindown);
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == MAS3507D
|
2003-11-03 23:36:36 +00:00
|
|
|
dac_line_in(global_settings.line_in);
|
|
|
|
#endif
|
2005-09-11 12:07:13 +00:00
|
|
|
mpeg_id3_options(global_settings.id3_v1_first);
|
2003-02-12 09:02:55 +00:00
|
|
|
#ifdef HAVE_ATA_POWER_OFF
|
2002-11-29 13:57:00 +00:00
|
|
|
ata_poweroff(global_settings.disk_poweroff);
|
2002-11-30 09:42:13 +00:00
|
|
|
#endif
|
|
|
|
|
2002-10-03 09:31:01 +00:00
|
|
|
set_poweroff_timeout(global_settings.poweroff);
|
2002-10-08 15:42:40 +00:00
|
|
|
|
2002-12-16 22:58:48 +00:00
|
|
|
set_battery_capacity(global_settings.battery_capacity);
|
2005-01-30 16:25:46 +00:00
|
|
|
#if BATTERY_TYPES_COUNT > 1
|
|
|
|
set_battery_type(global_settings.battery_type);
|
|
|
|
#endif
|
2002-12-16 22:58:48 +00:00
|
|
|
|
2002-10-29 12:09:15 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-08-08 19:23:28 +00:00
|
|
|
set_bidi_support(global_settings.bidi_support);
|
2003-02-27 14:22:30 +00:00
|
|
|
lcd_set_invert_display(global_settings.invert);
|
2003-12-20 10:00:37 +00:00
|
|
|
lcd_set_flip(global_settings.flip_display);
|
|
|
|
button_set_flip(global_settings.flip_display);
|
|
|
|
lcd_update(); /* refresh after flipping the screen */
|
2002-10-29 12:09:15 +00:00
|
|
|
settings_apply_pm_range();
|
|
|
|
peak_meter_init_times(
|
|
|
|
global_settings.peak_meter_release, global_settings.peak_meter_hold,
|
|
|
|
global_settings.peak_meter_clip_hold);
|
|
|
|
#endif
|
|
|
|
|
2002-10-09 08:51:08 +00:00
|
|
|
if ( global_settings.wps_file[0] &&
|
|
|
|
global_settings.wps_file[0] != 0xff ) {
|
2002-10-08 15:42:40 +00:00
|
|
|
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.wps",
|
|
|
|
global_settings.wps_file);
|
|
|
|
wps_load(buf, false);
|
|
|
|
}
|
2002-10-09 23:13:25 +00:00
|
|
|
else
|
|
|
|
wps_reset();
|
|
|
|
|
2002-10-08 15:42:40 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-10-09 08:51:08 +00:00
|
|
|
if ( global_settings.font_file[0] &&
|
|
|
|
global_settings.font_file[0] != 0xff ) {
|
2004-01-08 12:40:25 +00:00
|
|
|
snprintf(buf, sizeof buf, ROCKBOX_DIR FONT_DIR "/%s.fnt",
|
2002-10-08 15:42:40 +00:00
|
|
|
global_settings.font_file);
|
|
|
|
font_load(buf);
|
|
|
|
}
|
2002-10-09 23:13:25 +00:00
|
|
|
else
|
|
|
|
font_reset();
|
2002-12-12 15:20:37 +00:00
|
|
|
|
|
|
|
lcd_scroll_step(global_settings.scroll_step);
|
2003-05-22 06:42:14 +00:00
|
|
|
#else
|
|
|
|
lcd_jump_scroll(global_settings.jump_scroll);
|
2003-05-28 09:00:27 +00:00
|
|
|
lcd_jump_scroll_delay(global_settings.jump_scroll_delay * (HZ/10));
|
2002-10-08 15:42:40 +00:00
|
|
|
#endif
|
2003-02-12 09:07:48 +00:00
|
|
|
lcd_bidir_scroll(global_settings.bidir_limit);
|
2002-12-12 15:20:37 +00:00
|
|
|
lcd_scroll_delay(global_settings.scroll_delay * (HZ/10));
|
2002-10-09 23:13:25 +00:00
|
|
|
|
2002-10-09 08:51:08 +00:00
|
|
|
if ( global_settings.lang_file[0] &&
|
|
|
|
global_settings.lang_file[0] != 0xff ) {
|
2004-01-08 12:40:25 +00:00
|
|
|
snprintf(buf, sizeof buf, ROCKBOX_DIR LANG_DIR "/%s.lng",
|
2002-10-08 15:42:40 +00:00
|
|
|
global_settings.lang_file);
|
|
|
|
lang_load(buf);
|
2004-04-06 07:06:59 +00:00
|
|
|
talk_init(); /* use voice of same language */
|
2002-10-08 15:42:40 +00:00
|
|
|
}
|
2005-06-09 09:47:00 +00:00
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2005-07-22 16:46:27 +00:00
|
|
|
audio_set_crossfade(global_settings.crossfade);
|
2005-09-24 15:22:48 +00:00
|
|
|
dsp_set_replaygain(true);
|
2005-06-09 09:47:00 +00:00
|
|
|
#endif
|
2005-07-01 09:42:39 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SPDIF_POWER
|
|
|
|
spdif_power_enable(global_settings.spdif_enable);
|
|
|
|
#endif
|
2002-10-03 09:31:01 +00:00
|
|
|
}
|
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
|
|
|
|
/* helper to load global_settings from a bitfield, as described per table */
|
|
|
|
static void load_bit_table(const struct bit_entry* p_table, int count, int bitstart)
|
|
|
|
{
|
|
|
|
unsigned long* p_bitfield = (unsigned long*)config_block; /* 32 bit addr. */
|
|
|
|
unsigned long value; /* 32 bit content */
|
|
|
|
int i;
|
|
|
|
int maxbit; /* how many bits are valid in the saved part */
|
|
|
|
const struct bit_entry* p_run = p_table; /* start after the size info */
|
|
|
|
count--; /* first is excluded from loop */
|
|
|
|
maxbit = get_bits(p_bitfield, bitstart, p_table->bit_size);
|
|
|
|
bitstart += p_table->bit_size;
|
|
|
|
|
|
|
|
for (i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
p_run++;
|
|
|
|
|
|
|
|
size = p_run->bit_size & 0x3F; /* mask off abused bits */
|
|
|
|
if (bitstart + size > maxbit)
|
|
|
|
break; /* exit if this is not valid any more in bitfield */
|
|
|
|
|
|
|
|
value = get_bits(p_bitfield, bitstart, size);
|
|
|
|
bitstart += size;
|
|
|
|
if (p_run->bit_size & SIGNED)
|
|
|
|
{ // sign extend the read value
|
|
|
|
unsigned long mask = 0xFFFFFFFF << (size - 1);
|
|
|
|
if (value & mask) /* true if MSB of value is set */
|
|
|
|
value |= mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* could do a memcpy, but that would be endian-dependent */
|
|
|
|
switch(p_run->byte_size)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
((unsigned char*)&global_settings)[p_run->settings_offset] =
|
|
|
|
(unsigned char)value;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
((unsigned short*)&global_settings)[p_run->settings_offset/2] =
|
|
|
|
(unsigned short)value;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
((unsigned int*)&global_settings)[p_run->settings_offset/4] =
|
|
|
|
(unsigned int)value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DEBUGF( "illegal size!" );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-27 00:20:00 +00:00
|
|
|
/*
|
2002-07-15 11:02:12 +00:00
|
|
|
* load settings from disk or RTC RAM
|
2002-06-27 00:20:00 +00:00
|
|
|
*/
|
2004-06-19 15:50:02 +00:00
|
|
|
void settings_load(int which)
|
2002-06-27 00:20:00 +00:00
|
|
|
{
|
|
|
|
DEBUGF( "reload_all_settings()\n" );
|
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
/* load the buffer from the RTC (resets it to all-unused if the block
|
|
|
|
is invalid) and decode the settings which are set in the block */
|
2004-06-19 15:50:02 +00:00
|
|
|
if (!load_config_buffer(which))
|
2004-06-18 20:41:59 +00:00
|
|
|
{
|
|
|
|
/* load scalar values from RTC and HD sector, specified via table */
|
2004-06-19 15:50:02 +00:00
|
|
|
if (which & SETTINGS_RTC)
|
|
|
|
{
|
|
|
|
load_bit_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), 4*8);
|
|
|
|
}
|
|
|
|
if (which & SETTINGS_HD)
|
|
|
|
{
|
2005-07-28 08:36:24 +00:00
|
|
|
load_bit_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]),
|
2004-06-19 15:50:02 +00:00
|
|
|
RTC_BLOCK_SIZE*8);
|
|
|
|
}
|
2003-05-09 21:29:44 +00:00
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
if ( global_settings.contrast < MIN_CONTRAST_SETTING )
|
|
|
|
global_settings.contrast = lcd_default_contrast();
|
2003-05-09 16:01:21 +00:00
|
|
|
|
2002-10-08 15:42:40 +00:00
|
|
|
strncpy(global_settings.wps_file, &config_block[0xb8], MAX_FILENAME);
|
|
|
|
strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME);
|
|
|
|
strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME);
|
2004-06-19 15:50:02 +00:00
|
|
|
}
|
2002-06-27 00:20:00 +00:00
|
|
|
}
|
|
|
|
|
2003-02-17 09:53:11 +00:00
|
|
|
void set_file(char* filename, char* setting, int maxlen)
|
|
|
|
{
|
|
|
|
char* fptr = strrchr(filename,'/');
|
|
|
|
int len;
|
|
|
|
int extlen = 0;
|
|
|
|
char* ptr;
|
|
|
|
|
|
|
|
if (!fptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
*fptr = 0;
|
|
|
|
fptr++;
|
|
|
|
|
|
|
|
len = strlen(fptr);
|
|
|
|
ptr = fptr + len;
|
|
|
|
while (*ptr != '.') {
|
|
|
|
extlen++;
|
|
|
|
ptr--;
|
|
|
|
}
|
|
|
|
|
2004-09-05 16:43:31 +00:00
|
|
|
if (strncasecmp(ROCKBOX_DIR, filename ,strlen(ROCKBOX_DIR)) ||
|
2004-01-08 12:40:25 +00:00
|
|
|
(len-extlen > maxlen))
|
2003-02-17 09:53:11 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
strncpy(setting, fptr, len-extlen);
|
|
|
|
setting[len-extlen]=0;
|
|
|
|
|
|
|
|
settings_save();
|
|
|
|
}
|
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
/* helper to sort a .cfg file entry into a global_settings member,
|
|
|
|
as described per table. Returns the position if found, else 0. */
|
|
|
|
static int load_cfg_table(
|
|
|
|
const struct bit_entry* p_table, /* the table which describes the entries */
|
|
|
|
int count, /* number of entries in the table, including the first */
|
2004-08-18 01:09:31 +00:00
|
|
|
const char* name, /* the item to be searched */
|
|
|
|
const char* value, /* the value which got loaded for that item */
|
2004-06-18 20:41:59 +00:00
|
|
|
int hint) /* position to start looking */
|
2002-10-02 16:33:26 +00:00
|
|
|
{
|
2004-06-18 20:41:59 +00:00
|
|
|
int i = hint;
|
2002-10-02 16:33:26 +00:00
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
do
|
2002-10-02 16:33:26 +00:00
|
|
|
{
|
2004-06-18 20:41:59 +00:00
|
|
|
if (p_table[i].cfg_name != NULL && !strcasecmp(name, p_table[i].cfg_name))
|
|
|
|
{ /* found */
|
|
|
|
int val = 0;
|
|
|
|
if (p_table[i].cfg_val == NULL)
|
|
|
|
{ /* numerical value, just convert the string */
|
|
|
|
val = atoi(value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* set of string values, find the index */
|
|
|
|
const char* item;
|
|
|
|
const char* run;
|
|
|
|
int len = strlen(value);
|
|
|
|
|
|
|
|
item = run = p_table[i].cfg_val;
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
/* count the length of the field */
|
|
|
|
while (*run != ',' && *run != '\0')
|
|
|
|
run++;
|
|
|
|
|
|
|
|
if (!strncasecmp(value, item, MAX(run-item, len)))
|
|
|
|
break; /* match, exit the search */
|
|
|
|
|
|
|
|
if (*run == '\0') /* reached the end of the choices */
|
|
|
|
return i; /* return the position, but don't update */
|
|
|
|
|
|
|
|
val++; /* count the item up */
|
|
|
|
run++; /* behind the ',' */
|
|
|
|
item = run;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* could do a memcpy, but that would be endian-dependent */
|
|
|
|
switch(p_table[i].byte_size)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
((unsigned char*)&global_settings)[p_table[i].settings_offset] =
|
|
|
|
(unsigned char)val;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
((unsigned short*)&global_settings)[p_table[i].settings_offset/2] =
|
|
|
|
(unsigned short)val;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
((unsigned int*)&global_settings)[p_table[i].settings_offset/4] =
|
|
|
|
(unsigned int)val;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DEBUGF( "illegal size!" );
|
|
|
|
continue;
|
|
|
|
}
|
2003-02-14 14:14:55 +00:00
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
return i; /* return the position */
|
|
|
|
}
|
2003-02-14 14:14:55 +00:00
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
i++;
|
|
|
|
if (i==count)
|
|
|
|
i=1; /* wraparound */
|
|
|
|
} while (i != hint); /* back where we started, all searched */
|
|
|
|
|
|
|
|
return 0; /* indicate not found */
|
2003-02-14 14:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-18 01:09:31 +00:00
|
|
|
bool settings_load_config(const char* file)
|
2002-09-05 01:20:10 +00:00
|
|
|
{
|
|
|
|
int fd;
|
2002-10-02 16:33:26 +00:00
|
|
|
char line[128];
|
2002-09-05 16:30:07 +00:00
|
|
|
|
2002-09-05 01:20:10 +00:00
|
|
|
fd = open(file, O_RDONLY);
|
2003-04-11 07:47:30 +00:00
|
|
|
if (fd < 0)
|
2002-10-02 16:33:26 +00:00
|
|
|
return false;
|
|
|
|
|
2002-10-29 12:16:36 +00:00
|
|
|
while (read_line(fd, line, sizeof line) > 0)
|
2002-09-05 01:20:10 +00:00
|
|
|
{
|
2002-10-02 16:33:26 +00:00
|
|
|
char* name;
|
|
|
|
char* value;
|
2004-06-18 20:41:59 +00:00
|
|
|
const struct bit_entry* table[2] = { rtc_bits, hd_bits };
|
|
|
|
const int ta_size[2] = {
|
|
|
|
sizeof(rtc_bits)/sizeof(rtc_bits[0]),
|
|
|
|
sizeof(hd_bits)/sizeof(hd_bits[0])
|
|
|
|
};
|
|
|
|
int last_table = 0; /* which table was used last round */
|
|
|
|
int last_pos = 1; /* at which position did we succeed */
|
|
|
|
int pos; /* currently returned position */
|
2002-10-02 16:33:26 +00:00
|
|
|
|
|
|
|
if (!settings_parseline(line, &name, &value))
|
|
|
|
continue;
|
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
/* check for the string values */
|
|
|
|
if (!strcasecmp(name, "wps")) {
|
2003-02-17 09:57:55 +00:00
|
|
|
if (wps_load(value,false))
|
2003-02-17 09:53:11 +00:00
|
|
|
set_file(value, global_settings.wps_file, MAX_FILENAME);
|
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "lang")) {
|
|
|
|
if (!lang_load(value))
|
2004-04-06 07:06:59 +00:00
|
|
|
{
|
2003-02-17 09:53:11 +00:00
|
|
|
set_file(value, global_settings.lang_file, MAX_FILENAME);
|
2004-04-06 07:06:59 +00:00
|
|
|
talk_init(); /* use voice of same language */
|
|
|
|
}
|
2003-02-17 09:53:11 +00:00
|
|
|
}
|
2003-02-14 14:14:55 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2003-02-23 18:54:28 +00:00
|
|
|
else if (!strcasecmp(name, "font")) {
|
2003-02-24 23:47:21 +00:00
|
|
|
if (font_load(value))
|
2003-02-23 18:54:28 +00:00
|
|
|
set_file(value, global_settings.font_file, MAX_FILENAME);
|
|
|
|
}
|
2002-10-02 16:33:26 +00:00
|
|
|
#endif
|
2004-06-18 20:41:59 +00:00
|
|
|
|
|
|
|
/* check for scalar values, using the two tables */
|
|
|
|
pos = load_cfg_table(table[last_table], ta_size[last_table],
|
|
|
|
name, value, last_pos);
|
|
|
|
if (pos) /* success */
|
2004-01-14 00:13:04 +00:00
|
|
|
{
|
2004-06-18 20:41:59 +00:00
|
|
|
last_pos = pos; /* remember as a position hint for next round */
|
|
|
|
continue;
|
2004-01-14 00:13:04 +00:00
|
|
|
}
|
2004-06-18 20:41:59 +00:00
|
|
|
|
|
|
|
last_table = 1-last_table; /* try other table */
|
|
|
|
last_pos = 1; /* search from start */
|
|
|
|
pos = load_cfg_table(table[last_table], ta_size[last_table],
|
|
|
|
name, value, last_pos);
|
|
|
|
if (pos) /* success */
|
2004-01-26 17:05:21 +00:00
|
|
|
{
|
2004-06-18 20:41:59 +00:00
|
|
|
last_pos = pos; /* remember as a position hint for next round */
|
|
|
|
continue;
|
2004-01-26 17:05:21 +00:00
|
|
|
}
|
2004-06-18 20:41:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
settings_apply();
|
|
|
|
settings_save();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* helper to save content of global_settings into a file,
|
|
|
|
as described per table */
|
|
|
|
static void save_cfg_table(const struct bit_entry* p_table, int count, int fd)
|
|
|
|
{
|
|
|
|
long value; /* 32 bit content */
|
|
|
|
int i;
|
|
|
|
const struct bit_entry* p_run = p_table; /* start after the size info */
|
|
|
|
count--; /* first is excluded from loop */
|
|
|
|
|
|
|
|
for (i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
p_run++;
|
|
|
|
|
|
|
|
if (p_run->cfg_name == NULL)
|
|
|
|
continue; /* this value is not to be saved */
|
|
|
|
|
|
|
|
/* could do a memcpy, but that would be endian-dependent */
|
|
|
|
switch(p_run->byte_size)
|
2004-03-27 00:11:01 +00:00
|
|
|
{
|
2004-06-18 20:41:59 +00:00
|
|
|
case 1:
|
|
|
|
if (p_run->bit_size & SIGNED) /* signed? */
|
|
|
|
value = ((char*)&global_settings)[p_run->settings_offset];
|
|
|
|
else
|
|
|
|
value = ((unsigned char*)&global_settings)[p_run->settings_offset];
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (p_run->bit_size & SIGNED) /* signed? */
|
|
|
|
value = ((short*)&global_settings)[p_run->settings_offset/2];
|
|
|
|
else
|
|
|
|
value = ((unsigned short*)&global_settings)[p_run->settings_offset/2];
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
value = ((unsigned int*)&global_settings)[p_run->settings_offset/4];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DEBUGF( "illegal size!" );
|
|
|
|
continue;
|
2004-03-27 00:11:01 +00:00
|
|
|
}
|
2004-06-18 20:41:59 +00:00
|
|
|
|
|
|
|
if (p_run->cfg_val == NULL) /* write as number */
|
2004-03-27 00:11:01 +00:00
|
|
|
{
|
2005-02-22 12:19:12 +00:00
|
|
|
fdprintf(fd, "%s: %ld\r\n", p_run->cfg_name, value);
|
2004-03-27 00:11:01 +00:00
|
|
|
}
|
2004-06-18 20:41:59 +00:00
|
|
|
else /* write as item */
|
2004-03-27 00:11:01 +00:00
|
|
|
{
|
2004-06-18 20:41:59 +00:00
|
|
|
const char* p = p_run->cfg_val;
|
|
|
|
|
2005-02-22 12:19:12 +00:00
|
|
|
fdprintf(fd, "%s: ", p_run->cfg_name);
|
2004-06-18 20:41:59 +00:00
|
|
|
|
|
|
|
while(value >= 0)
|
|
|
|
{
|
|
|
|
char c = *p++; /* currently processed char */
|
|
|
|
if (c == ',') /* separator */
|
|
|
|
value--;
|
|
|
|
else if (c == '\0') /* end of string */
|
|
|
|
break; /* not found */
|
|
|
|
else if (value == 0) /* the right place */
|
|
|
|
write(fd, &c, 1); /* char by char, this is lame, OK */
|
|
|
|
}
|
|
|
|
|
2005-02-22 12:19:12 +00:00
|
|
|
fdprintf(fd, "\r\n");
|
2004-06-23 08:12:19 +00:00
|
|
|
if (p_run->cfg_val != off_on) /* explaination for non-bool */
|
2005-02-22 12:19:12 +00:00
|
|
|
fdprintf(fd, "# (possible values: %s)\r\n", p_run->cfg_val);
|
2004-03-27 00:11:01 +00:00
|
|
|
}
|
2002-09-05 01:20:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
bool settings_save_config(void)
|
|
|
|
{
|
2005-09-02 01:15:35 +00:00
|
|
|
int fd;
|
2003-03-10 16:31:02 +00:00
|
|
|
char filename[MAX_PATH];
|
2005-09-02 01:15:35 +00:00
|
|
|
|
|
|
|
create_numbered_filename(filename, ROCKBOX_DIR, "config", ".cfg", 2);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
/* allow user to modify filename */
|
2005-09-02 01:15:35 +00:00
|
|
|
while (true) {
|
2003-03-10 16:31:02 +00:00
|
|
|
if (!kbd_input(filename, sizeof filename)) {
|
|
|
|
fd = creat(filename,0);
|
|
|
|
if (fd < 0) {
|
|
|
|
lcd_clear_display();
|
2005-09-02 01:15:35 +00:00
|
|
|
splash(HZ, true, str(LANG_FAILED));
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
else
|
2005-09-02 01:15:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lcd_clear_display();
|
|
|
|
splash(HZ, true, str(LANG_RESET_DONE_CANCEL));
|
|
|
|
return false;
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-02 01:15:35 +00:00
|
|
|
fdprintf(fd, "# .cfg file created by rockbox %s - "
|
|
|
|
"http://www.rockbox.org\r\n#\r\n"
|
|
|
|
"#\r\n# wps / language / font \r\n#\r\n", appsversion);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
if (global_settings.wps_file[0] != 0)
|
2005-02-22 12:19:12 +00:00
|
|
|
fdprintf(fd, "wps: %s/%s.wps\r\n", ROCKBOX_DIR,
|
2005-09-02 01:15:35 +00:00
|
|
|
global_settings.wps_file);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
if (global_settings.lang_file[0] != 0)
|
2005-09-02 01:15:35 +00:00
|
|
|
fdprintf(fd, "lang: %s/%s.lng\r\n", ROCKBOX_DIR LANG_DIR,
|
|
|
|
global_settings.lang_file);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2003-04-24 17:53:17 +00:00
|
|
|
if (global_settings.font_file[0] != 0)
|
2005-02-22 12:19:12 +00:00
|
|
|
fdprintf(fd, "font: %s/%s.fnt\r\n", ROCKBOX_DIR FONT_DIR,
|
2005-09-02 01:15:35 +00:00
|
|
|
global_settings.font_file);
|
2003-03-10 16:31:02 +00:00
|
|
|
#endif
|
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
/* here's the action: write values to file, specified via table */
|
|
|
|
save_cfg_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), fd);
|
|
|
|
save_cfg_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), fd);
|
|
|
|
|
2003-03-10 16:31:02 +00:00
|
|
|
close(fd);
|
|
|
|
|
|
|
|
lcd_clear_display();
|
2005-09-02 01:15:35 +00:00
|
|
|
splash(HZ, true, "%s %s", str(LANG_SETTINGS_SAVED1),
|
|
|
|
str(LANG_SETTINGS_SAVED2));
|
2003-03-10 16:31:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
|
|
|
|
/* helper to load defaults from table into global_settings members */
|
|
|
|
static void default_table(const struct bit_entry* p_table, int count)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=1; i<count; i++) /* exclude the first, the size placeholder */
|
|
|
|
{
|
|
|
|
/* could do a memcpy, but that would be endian-dependent */
|
|
|
|
switch(p_table[i].byte_size)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
((unsigned char*)&global_settings)[p_table[i].settings_offset] =
|
|
|
|
(unsigned char)p_table[i].default_val;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
((unsigned short*)&global_settings)[p_table[i].settings_offset/2] =
|
|
|
|
(unsigned short)p_table[i].default_val;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
((unsigned int*)&global_settings)[p_table[i].settings_offset/4] =
|
|
|
|
(unsigned int)p_table[i].default_val;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DEBUGF( "illegal size!" );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-27 00:20:00 +00:00
|
|
|
/*
|
|
|
|
* reset all settings to their default value
|
|
|
|
*/
|
2002-07-15 11:02:12 +00:00
|
|
|
void settings_reset(void) {
|
2002-06-27 00:20:00 +00:00
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
DEBUGF( "settings_reset()\n" );
|
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
/* read defaults from table(s) into global_settings */
|
|
|
|
default_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]));
|
|
|
|
default_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]));
|
|
|
|
|
|
|
|
/* do some special cases not covered by table */
|
2005-04-01 13:41:03 +00:00
|
|
|
global_settings.volume = sound_default(SOUND_VOLUME);
|
|
|
|
global_settings.balance = sound_default(SOUND_BALANCE);
|
|
|
|
global_settings.bass = sound_default(SOUND_BASS);
|
|
|
|
global_settings.treble = sound_default(SOUND_TREBLE);
|
|
|
|
global_settings.loudness = sound_default(SOUND_LOUDNESS);
|
|
|
|
global_settings.avc = sound_default(SOUND_AVC);
|
|
|
|
global_settings.channel_config = sound_default(SOUND_CHANNELS);
|
|
|
|
global_settings.stereo_width = sound_default(SOUND_STEREO_WIDTH);
|
|
|
|
global_settings.mdb_strength = sound_default(SOUND_MDB_STRENGTH);
|
|
|
|
global_settings.mdb_harmonics = sound_default(SOUND_MDB_HARMONICS);
|
|
|
|
global_settings.mdb_center = sound_default(SOUND_MDB_CENTER);
|
|
|
|
global_settings.mdb_shape = sound_default(SOUND_MDB_SHAPE);
|
|
|
|
global_settings.mdb_enable = sound_default(SOUND_MDB_ENABLE);
|
|
|
|
global_settings.superbass = sound_default(SOUND_SUPERBASS);
|
2003-07-09 23:07:49 +00:00
|
|
|
global_settings.contrast = lcd_default_contrast();
|
2004-06-18 20:41:59 +00:00
|
|
|
global_settings.wps_file[0] = '\0';
|
|
|
|
global_settings.font_file[0] = '\0';
|
|
|
|
global_settings.lang_file[0] = '\0';
|
|
|
|
|
2002-06-27 00:20:00 +00:00
|
|
|
}
|
2002-06-27 01:08:11 +00:00
|
|
|
|
2004-08-18 01:09:31 +00:00
|
|
|
bool set_bool(const char* string, bool* variable )
|
2002-06-27 01:08:11 +00:00
|
|
|
{
|
2004-03-15 08:27:51 +00:00
|
|
|
return set_bool_options(string, variable,
|
|
|
|
STR(LANG_SET_BOOL_YES),
|
|
|
|
STR(LANG_SET_BOOL_NO),
|
|
|
|
NULL);
|
2003-06-05 11:11:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* wrapper to convert from int param to bool param in set_option */
|
|
|
|
static void (*boolfunction)(bool);
|
|
|
|
void bool_funcwrapper(int value)
|
|
|
|
{
|
|
|
|
if (value)
|
|
|
|
boolfunction(true);
|
|
|
|
else
|
|
|
|
boolfunction(false);
|
2002-09-05 04:42:12 +00:00
|
|
|
}
|
2002-08-20 19:37:00 +00:00
|
|
|
|
2004-08-18 01:09:31 +00:00
|
|
|
bool set_bool_options(const char* string, bool* variable,
|
|
|
|
const char* yes_str, int yes_voice,
|
|
|
|
const char* no_str, int no_voice,
|
2004-03-15 08:27:51 +00:00
|
|
|
void (*function)(bool))
|
2002-09-05 04:42:12 +00:00
|
|
|
{
|
2004-03-15 08:27:51 +00:00
|
|
|
struct opt_items names[] = { {no_str, no_voice}, {yes_str, yes_voice} };
|
2002-09-24 17:22:12 +00:00
|
|
|
bool result;
|
|
|
|
|
2003-06-05 11:11:10 +00:00
|
|
|
boolfunction = function;
|
|
|
|
result = set_option(string, variable, BOOL, names, 2,
|
|
|
|
function ? bool_funcwrapper : NULL);
|
2002-09-24 17:22:12 +00:00
|
|
|
return result;
|
2002-06-27 01:08:11 +00:00
|
|
|
}
|
|
|
|
|
2004-08-18 01:09:31 +00:00
|
|
|
bool set_int(const char* string,
|
|
|
|
const char* unit,
|
2004-03-20 16:49:58 +00:00
|
|
|
int voice_unit,
|
2002-06-27 01:08:11 +00:00
|
|
|
int* variable,
|
|
|
|
void (*function)(int),
|
|
|
|
int step,
|
|
|
|
int min,
|
2005-08-11 18:56:20 +00:00
|
|
|
int max,
|
|
|
|
void (*formatter)(char*, int, int, const char*) )
|
2002-06-27 01:08:11 +00:00
|
|
|
{
|
|
|
|
bool done = false;
|
2002-09-19 09:00:25 +00:00
|
|
|
int button;
|
2003-01-14 13:49:28 +00:00
|
|
|
int org_value=*variable;
|
2005-02-11 21:50:34 +00:00
|
|
|
int last_value = INT_MAX; /* out of range init */
|
2002-06-27 01:08:11 +00:00
|
|
|
|
2002-08-20 19:37:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
if(global_settings.statusbar)
|
|
|
|
lcd_setmargins(0, STATUSBAR_HEIGHT);
|
|
|
|
else
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
#endif
|
2002-09-05 04:42:12 +00:00
|
|
|
|
2002-06-27 01:08:11 +00:00
|
|
|
lcd_clear_display();
|
2002-08-20 19:37:00 +00:00
|
|
|
lcd_puts_scroll(0, 0, string);
|
2002-06-27 01:08:11 +00:00
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
char str[32];
|
2005-08-11 18:56:20 +00:00
|
|
|
|
|
|
|
if (formatter)
|
|
|
|
{
|
|
|
|
formatter(str, sizeof str, *variable, unit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(str,sizeof str,"%d %s ", *variable, unit);
|
|
|
|
}
|
|
|
|
|
2002-08-20 19:37:00 +00:00
|
|
|
lcd_puts(0, 1, str);
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2003-04-23 11:26:25 +00:00
|
|
|
status_draw(true);
|
2002-08-20 19:37:00 +00:00
|
|
|
#endif
|
2002-06-27 01:08:11 +00:00
|
|
|
lcd_update();
|
|
|
|
|
2004-03-27 00:11:01 +00:00
|
|
|
if (global_settings.talk_menu && *variable != last_value)
|
2004-03-20 16:49:58 +00:00
|
|
|
{
|
|
|
|
if (voice_unit < UNIT_LAST)
|
|
|
|
{ /* use the available unit definition */
|
|
|
|
talk_value(*variable, voice_unit, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* say the number, followed by an arbitrary voice ID */
|
|
|
|
talk_number(*variable, false);
|
|
|
|
talk_id(voice_unit, true);
|
|
|
|
}
|
|
|
|
last_value = *variable;
|
|
|
|
}
|
|
|
|
|
2002-09-19 09:00:25 +00:00
|
|
|
button = button_get_w_tmo(HZ/2);
|
|
|
|
switch(button) {
|
2004-09-19 21:58:37 +00:00
|
|
|
case SETTINGS_INC:
|
|
|
|
case SETTINGS_INC | BUTTON_REPEAT:
|
2002-06-27 01:08:11 +00:00
|
|
|
*variable += step;
|
|
|
|
break;
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
case SETTINGS_DEC:
|
|
|
|
case SETTINGS_DEC | BUTTON_REPEAT:
|
2002-06-27 01:08:11 +00:00
|
|
|
*variable -= step;
|
|
|
|
break;
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
case SETTINGS_OK:
|
|
|
|
#ifdef SETTINGS_OK2
|
|
|
|
case SETTINGS_OK2:
|
2003-01-14 13:49:28 +00:00
|
|
|
#endif
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
case SETTINGS_CANCEL:
|
|
|
|
#ifdef SETTINGS_CANCEL2
|
|
|
|
case SETTINGS_CANCEL2:
|
2002-06-27 01:08:11 +00:00
|
|
|
#endif
|
2003-01-14 13:49:28 +00:00
|
|
|
if (*variable != org_value) {
|
2003-01-15 14:16:21 +00:00
|
|
|
*variable=org_value;
|
|
|
|
lcd_stop_scroll();
|
|
|
|
lcd_puts(0, 0, str(LANG_MENU_SETTING_CANCEL));
|
|
|
|
lcd_update();
|
|
|
|
sleep(HZ/2);
|
2003-01-14 13:49:28 +00:00
|
|
|
}
|
2002-06-27 01:08:11 +00:00
|
|
|
done = true;
|
|
|
|
break;
|
2002-09-24 17:22:12 +00:00
|
|
|
|
2004-07-26 16:06:59 +00:00
|
|
|
default:
|
|
|
|
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
return true;
|
|
|
|
break;
|
2002-06-27 01:08:11 +00:00
|
|
|
}
|
2002-12-16 23:33:34 +00:00
|
|
|
if(*variable > max )
|
|
|
|
*variable = max;
|
|
|
|
|
|
|
|
if(*variable < min )
|
|
|
|
*variable = min;
|
|
|
|
|
2002-09-19 09:00:25 +00:00
|
|
|
if ( function && button != BUTTON_NONE)
|
2002-06-27 01:08:11 +00:00
|
|
|
function(*variable);
|
|
|
|
}
|
|
|
|
lcd_stop_scroll();
|
2002-09-24 17:22:12 +00:00
|
|
|
|
|
|
|
return false;
|
2002-06-27 01:08:11 +00:00
|
|
|
}
|
|
|
|
|
2003-06-05 11:11:10 +00:00
|
|
|
/* NOTE: the 'type' parameter specifies the actual type of the variable
|
|
|
|
that 'variable' points to. not the value within. Only variables with
|
|
|
|
type 'bool' should use parameter BOOL.
|
|
|
|
|
2003-06-05 14:22:03 +00:00
|
|
|
The type separation is necessary since int and bool are fundamentally
|
2003-06-05 11:11:10 +00:00
|
|
|
different and bit-incompatible types and can not share the same access
|
|
|
|
code. */
|
|
|
|
|
2004-08-18 01:09:31 +00:00
|
|
|
bool set_option(const char* string, void* variable, enum optiontype type,
|
2004-07-23 23:01:20 +00:00
|
|
|
const struct opt_items* options, int numoptions, void (*function)(int))
|
2002-06-27 01:08:11 +00:00
|
|
|
{
|
|
|
|
bool done = false;
|
2002-09-19 09:00:25 +00:00
|
|
|
int button;
|
2003-06-05 11:11:10 +00:00
|
|
|
int* intvar = (int*)variable;
|
|
|
|
bool* boolvar = (bool*)variable;
|
2003-06-05 14:22:03 +00:00
|
|
|
int oldval = 0;
|
2004-03-15 08:27:51 +00:00
|
|
|
int index, oldindex = -1; /* remember what we said */
|
2003-06-05 14:22:03 +00:00
|
|
|
|
|
|
|
if (type==INT)
|
|
|
|
oldval=*intvar;
|
|
|
|
else
|
|
|
|
oldval=*boolvar;
|
2002-06-27 01:08:11 +00:00
|
|
|
|
2002-08-20 19:37:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
if(global_settings.statusbar)
|
|
|
|
lcd_setmargins(0, STATUSBAR_HEIGHT);
|
|
|
|
else
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
#endif
|
2003-01-14 13:49:28 +00:00
|
|
|
|
2002-06-27 01:08:11 +00:00
|
|
|
lcd_clear_display();
|
2002-08-20 19:37:00 +00:00
|
|
|
lcd_puts_scroll(0, 0, string);
|
2002-06-27 01:08:11 +00:00
|
|
|
|
|
|
|
while ( !done ) {
|
2004-03-15 08:27:51 +00:00
|
|
|
index = type==INT ? *intvar : (int)*boolvar;
|
2004-07-23 23:01:20 +00:00
|
|
|
lcd_puts(0, 1, P2STR(options[index].string));
|
2004-03-27 00:11:01 +00:00
|
|
|
if (global_settings.talk_menu && index != oldindex)
|
2004-03-15 08:27:51 +00:00
|
|
|
{
|
|
|
|
talk_id(options[index].voice_id, false);
|
|
|
|
oldindex = index;
|
|
|
|
}
|
2002-08-20 19:37:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2003-04-23 11:26:25 +00:00
|
|
|
status_draw(true);
|
2002-08-20 19:37:00 +00:00
|
|
|
#endif
|
2002-06-27 01:08:11 +00:00
|
|
|
lcd_update();
|
|
|
|
|
2002-09-19 09:00:25 +00:00
|
|
|
button = button_get_w_tmo(HZ/2);
|
|
|
|
switch (button) {
|
2004-09-19 21:58:37 +00:00
|
|
|
case SETTINGS_INC:
|
|
|
|
case SETTINGS_INC | BUTTON_REPEAT:
|
2003-06-05 11:11:10 +00:00
|
|
|
if (type == INT) {
|
|
|
|
if ( *intvar < (numoptions-1) )
|
|
|
|
(*intvar)++;
|
|
|
|
else
|
|
|
|
(*intvar) -= (numoptions-1);
|
|
|
|
}
|
2003-04-16 00:12:31 +00:00
|
|
|
else
|
2003-06-05 11:11:10 +00:00
|
|
|
*boolvar = !*boolvar;
|
2002-06-27 01:08:11 +00:00
|
|
|
break;
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
case SETTINGS_DEC:
|
|
|
|
case SETTINGS_DEC | BUTTON_REPEAT:
|
2003-06-05 11:11:10 +00:00
|
|
|
if (type == INT) {
|
|
|
|
if ( *intvar > 0 )
|
|
|
|
(*intvar)--;
|
|
|
|
else
|
|
|
|
(*intvar) += (numoptions-1);
|
|
|
|
}
|
2002-09-14 06:03:51 +00:00
|
|
|
else
|
2003-06-05 11:11:10 +00:00
|
|
|
*boolvar = !*boolvar;
|
2002-06-27 01:08:11 +00:00
|
|
|
break;
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
case SETTINGS_OK:
|
|
|
|
#ifdef SETTINGS_OK2
|
|
|
|
case SETTINGS_OK2:
|
2003-01-14 13:49:28 +00:00
|
|
|
#endif
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
|
2004-09-19 21:58:37 +00:00
|
|
|
case SETTINGS_CANCEL:
|
|
|
|
#ifdef SETTINGS_CANCEL2
|
|
|
|
case SETTINGS_CANCEL2:
|
2002-06-27 01:08:11 +00:00
|
|
|
#endif
|
2003-06-05 14:22:03 +00:00
|
|
|
if (((type==INT) && (*intvar != oldval)) ||
|
2003-06-11 15:36:04 +00:00
|
|
|
((type==BOOL) && (*boolvar != (bool)oldval))) {
|
2003-06-05 11:11:10 +00:00
|
|
|
if (type==INT)
|
2003-06-05 14:22:03 +00:00
|
|
|
*intvar=oldval;
|
2003-06-05 11:11:10 +00:00
|
|
|
else
|
2003-06-05 14:22:03 +00:00
|
|
|
*boolvar=oldval;
|
2003-01-15 14:16:21 +00:00
|
|
|
lcd_stop_scroll();
|
|
|
|
lcd_puts(0, 0, str(LANG_MENU_SETTING_CANCEL));
|
|
|
|
lcd_update();
|
|
|
|
sleep(HZ/2);
|
2003-01-14 13:49:28 +00:00
|
|
|
}
|
2002-06-27 01:08:11 +00:00
|
|
|
done = true;
|
|
|
|
break;
|
2002-09-24 17:22:12 +00:00
|
|
|
|
2004-07-26 16:06:59 +00:00
|
|
|
default:
|
|
|
|
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
return true;
|
|
|
|
break;
|
2002-06-27 01:08:11 +00:00
|
|
|
}
|
2002-09-10 05:31:12 +00:00
|
|
|
|
2003-06-05 11:11:10 +00:00
|
|
|
if ( function && button != BUTTON_NONE) {
|
|
|
|
if (type == INT)
|
|
|
|
function(*intvar);
|
|
|
|
else
|
|
|
|
function(*boolvar);
|
|
|
|
}
|
2002-06-27 01:08:11 +00:00
|
|
|
}
|
|
|
|
lcd_stop_scroll();
|
2002-09-24 17:22:12 +00:00
|
|
|
return false;
|
2002-06-27 01:08:11 +00:00
|
|
|
}
|
2002-08-09 12:38:45 +00:00
|
|
|
|
2005-02-02 21:52:55 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2003-11-20 00:33:43 +00:00
|
|
|
/* This array holds the record timer interval lengths, in seconds */
|
2004-08-01 21:50:57 +00:00
|
|
|
static const unsigned long rec_timer_seconds[] =
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2005-06-04 12:14:46 +00:00
|
|
|
0, /* 0 means OFF */
|
2003-11-20 00:33:43 +00:00
|
|
|
5*60, /* 00:05 */
|
|
|
|
10*60, /* 00:10 */
|
|
|
|
15*60, /* 00:15 */
|
|
|
|
30*60, /* 00:30 */
|
|
|
|
60*60, /* 01:00 */
|
2004-10-27 09:24:02 +00:00
|
|
|
74*60, /* 74:00 */
|
|
|
|
80*60, /* 80:00 */
|
2003-11-20 00:33:43 +00:00
|
|
|
2*60*60, /* 02:00 */
|
|
|
|
4*60*60, /* 04:00 */
|
|
|
|
6*60*60, /* 06:00 */
|
|
|
|
8*60*60, /* 08:00 */
|
2005-02-11 18:41:40 +00:00
|
|
|
10L*60*60, /* 10:00 */
|
|
|
|
12L*60*60, /* 12:00 */
|
|
|
|
18L*60*60, /* 18:00 */
|
|
|
|
24L*60*60 /* 24:00 */
|
2003-11-20 00:33:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
unsigned int rec_timesplit_seconds(void)
|
|
|
|
{
|
|
|
|
return rec_timer_seconds[global_settings.rec_timesplit];
|
|
|
|
}
|
2005-04-04 09:12:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Time strings used for the trigger durations.
|
|
|
|
* Keep synchronous to trigger_times in settings_apply_trigger
|
|
|
|
*/
|
2005-08-18 07:02:03 +00:00
|
|
|
const char * const trig_durations[TRIG_DURATION_COUNT] =
|
2005-04-04 09:12:12 +00:00
|
|
|
{
|
|
|
|
"0s", "1s", "2s", "5s",
|
|
|
|
"10s", "15s", "20s", "25s", "30s",
|
|
|
|
"1min", "2min", "5min", "10min"
|
|
|
|
};
|
|
|
|
|
|
|
|
void settings_apply_trigger(void)
|
|
|
|
{
|
|
|
|
/* Keep synchronous to trig_durations and trig_durations_conf*/
|
|
|
|
static const long trigger_times[TRIG_DURATION_COUNT] = {
|
|
|
|
0, HZ, 2*HZ, 5*HZ,
|
|
|
|
10*HZ, 15*HZ, 20*HZ, 25*HZ, 30*HZ,
|
|
|
|
60*HZ, 2*60*HZ, 5*60*HZ, 10*60*HZ
|
|
|
|
};
|
|
|
|
|
|
|
|
peak_meter_define_trigger(
|
|
|
|
global_settings.rec_start_thres,
|
|
|
|
trigger_times[global_settings.rec_start_duration],
|
|
|
|
MIN(trigger_times[global_settings.rec_start_duration] / 2, 2*HZ),
|
|
|
|
global_settings.rec_stop_thres,
|
|
|
|
trigger_times[global_settings.rec_stop_postrec],
|
|
|
|
trigger_times[global_settings.rec_stop_gap]
|
|
|
|
);
|
|
|
|
}
|
2003-11-20 00:33:43 +00:00
|
|
|
#endif
|