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>
|
|
|
|
#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"
|
2002-06-28 11:54:47 +00:00
|
|
|
#include "mpeg.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"
|
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"
|
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"
|
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"
|
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"
|
2002-09-18 14:08:05 +00:00
|
|
|
|
2002-06-27 00:20:00 +00:00
|
|
|
struct user_settings global_settings;
|
2002-09-01 19:50:45 +00:00
|
|
|
char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */
|
2002-06-27 00:20:00 +00:00
|
|
|
|
2003-01-11 22:39:25 +00:00
|
|
|
#define CONFIG_BLOCK_VERSION 4
|
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
|
|
|
|
|
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>
|
|
|
|
0x04 0x18 <volume byte>
|
|
|
|
0x05 0x19 <balance byte>
|
|
|
|
0x06 0x1a <bass byte>
|
|
|
|
0x07 0x1b <treble byte>
|
|
|
|
0x08 0x1c <loudness byte>
|
|
|
|
0x09 0x1d <bass boost byte>
|
2003-02-27 14:22:30 +00:00
|
|
|
0x0a 0x1e <contrast (bit 0-5), invert bit (bit 6)>
|
2003-04-16 00:12:31 +00:00
|
|
|
0x0b 0x1f <backlight_on_when_charging, invert_cursor, backlight_timeout>
|
2002-07-15 11:02:12 +00:00
|
|
|
0x0c 0x20 <poweroff timer byte>
|
|
|
|
0x0d 0x21 <resume settings byte>
|
2002-09-24 19:12:09 +00:00
|
|
|
0x0e 0x22 <shuffle,dirfilter,sort_case,discharge,statusbar,show_hidden,
|
2002-09-18 10:12:16 +00:00
|
|
|
scroll bar>
|
2002-10-28 10:37:10 +00:00
|
|
|
0x0f 0x23 <volume type, battery type, timeformat, scroll speed>
|
2002-09-04 03:38:37 +00:00
|
|
|
0x10 0x24 <ff/rewind min step, acceleration rate>
|
2002-09-09 15:25:54 +00:00
|
|
|
0x11 0x25 <AVC, channel config>
|
2002-08-16 14:41:47 +00:00
|
|
|
0x12 0x26 <(int) Resume playlist index, or -1 if no playlist resume>
|
2002-08-28 05:34:28 +00:00
|
|
|
0x16 0x2a <(int) Byte offset into resume file>
|
2002-08-28 19:34:07 +00:00
|
|
|
0x1a 0x2e <time until disk spindown>
|
2003-01-09 00:55:00 +00:00
|
|
|
0x1b 0x2f <browse current, play selected, queue_resume>
|
2003-04-20 22:00:30 +00:00
|
|
|
0x1c 0x30 <peak meter hold timeout (bit 0-4),
|
|
|
|
rec_editable (bit 7)>
|
2003-01-09 00:55:00 +00:00
|
|
|
0x1d 0x31 <(int) queue resume index>
|
2002-11-10 23:18:33 +00:00
|
|
|
0x21 0x35 <repeat mode (bit 0-1), rec. channels (bit 2),
|
|
|
|
mic gain (bit 4-7)>
|
|
|
|
0x22 0x36 <rec. quality (bit 0-2), source (bit 3-4), frequency (bit 5-7)>
|
|
|
|
0x23 0x37 <rec. left gain (bit 0-3)>
|
|
|
|
0x24 0x38 <rec. right gain (bit 0-3)>
|
2002-12-15 00:33:13 +00:00
|
|
|
0x25 0x39 <disk poweroff flag (bit 0), MP3 buffer margin (bit 1-3),
|
2003-03-12 15:30:59 +00:00
|
|
|
Trickle charge flag (bit 4)>
|
2002-12-02 16:07:56 +00:00
|
|
|
0x26 0x40 <runtime low byte>
|
|
|
|
0x27 0x41 <runtime high byte>
|
|
|
|
0x28 0x42 <topruntime low byte>
|
|
|
|
0x29 0x43 <topruntime high byte>
|
2002-08-06 10:52:51 +00:00
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
0x2a <checksum 2 bytes: xor of 0x0-0x29>
|
|
|
|
|
|
|
|
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
|
|
|
|
versions can read and modify configuration changed by new versions. New
|
|
|
|
versions should check for the value of '0xff' in each config memory
|
|
|
|
location used, and reset the setting in question with a factory default if
|
|
|
|
needed. Memory locations not used by a given version should not be
|
|
|
|
modified unless the header & checksum test fails.
|
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
|
|
|
|
Rest of config block, only saved to disk:
|
2003-02-14 15:54:52 +00:00
|
|
|
0xAE fade on pause/unpause/stop setting (bit 0)
|
2003-04-23 09:17:34 +00:00
|
|
|
caption backlight (bit 1)
|
2003-04-20 22:00:30 +00:00
|
|
|
0xB0 peak meter clip hold timeout (bit 0-4), peak meter performance (bit 7)
|
2003-01-09 00:55:00 +00:00
|
|
|
0xB1 peak meter release step size, peak_meter_dbfs (bit 7)
|
|
|
|
0xB2 peak meter min either in -db or in percent
|
|
|
|
0xB3 peak meter max either in -db or in percent
|
2002-12-16 23:33:34 +00:00
|
|
|
0xB4 battery capacity
|
2002-12-12 15:20:37 +00:00
|
|
|
0xB5 scroll step in pixels
|
|
|
|
0xB6 scroll start and endpoint delay
|
|
|
|
0xB7 bidir scroll setting (bidi if 0-200% longer than screen width)
|
2002-10-08 15:42:40 +00:00
|
|
|
0xB8 (char[20]) WPS file
|
|
|
|
0xCC (char[20]) Lang file
|
|
|
|
0xE0 (char[20]) Font file
|
2002-10-06 05:50:41 +00:00
|
|
|
0xF4 (int) Playlist first index
|
2002-08-16 14:41:47 +00:00
|
|
|
0xF8 (int) Playlist shuffle seed
|
|
|
|
0xFC (char[260]) Resume playlist (path/to/dir or path/to/playlist.m3u)
|
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
*************************************/
|
|
|
|
|
|
|
|
#include "rtc.h"
|
2002-08-16 14:41:47 +00:00
|
|
|
static unsigned char config_block[CONFIG_BLOCK_SIZE];
|
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
|
|
|
*/
|
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
static unsigned short calculate_config_checksum(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" );
|
|
|
|
|
|
|
|
/* reset to 0xff - all unused */
|
2002-08-16 14:41:47 +00:00
|
|
|
memset(config_block, 0xff, 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
|
|
|
DEBUGF( "save_config_buffer()\n" );
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
if (fat_startsector() != 0)
|
|
|
|
ata_delayed_write( 61, 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
|
|
|
*/
|
2002-07-15 11:02:12 +00:00
|
|
|
static int load_config_buffer( void )
|
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
|
|
|
|
|
|
|
#ifdef HAVE_RTC
|
|
|
|
unsigned int i;
|
2002-08-16 14:41:47 +00:00
|
|
|
unsigned char rtc_block[RTC_BLOCK_SIZE];
|
2002-08-13 17:16:09 +00:00
|
|
|
#endif
|
2002-07-15 11:02:12 +00:00
|
|
|
|
|
|
|
DEBUGF( "load_config_buffer()\n" );
|
2002-08-13 17:16:09 +00:00
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
if (fat_startsector() != 0) {
|
|
|
|
ata_read_sectors( 61, 1, config_block);
|
|
|
|
|
|
|
|
/* calculate the checksum, check it and the header */
|
|
|
|
chksum = calculate_config_checksum(config_block);
|
|
|
|
|
|
|
|
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-13 17:16:09 +00:00
|
|
|
#ifdef HAVE_RTC
|
2002-08-16 14:41:47 +00:00
|
|
|
/* read rtc block */
|
|
|
|
for (i=0; i < RTC_BLOCK_SIZE; i++ )
|
|
|
|
rtc_block[i] = rtc_read(0x14+i);
|
|
|
|
|
|
|
|
chksum = calculate_config_checksum(rtc_block);
|
2002-08-13 17:16:09 +00:00
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
/* 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])
|
2002-08-13 17:16:09 +00:00
|
|
|
{
|
2002-08-16 14:41:47 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
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-07-15 11:02:12 +00:00
|
|
|
DEBUGF( "settings_save()\n" );
|
|
|
|
|
|
|
|
/* update the config block buffer with current
|
|
|
|
settings and save the block in the RTC */
|
2002-08-16 14:41:47 +00:00
|
|
|
config_block[0x4] = (unsigned char)global_settings.volume;
|
2002-10-02 23:16:32 +00:00
|
|
|
config_block[0x5] = (char)global_settings.balance;
|
2002-08-16 14:41:47 +00:00
|
|
|
config_block[0x6] = (unsigned char)global_settings.bass;
|
|
|
|
config_block[0x7] = (unsigned char)global_settings.treble;
|
|
|
|
config_block[0x8] = (unsigned char)global_settings.loudness;
|
|
|
|
config_block[0x9] = (unsigned char)global_settings.bass_boost;
|
2002-07-15 11:02:12 +00:00
|
|
|
|
2003-02-27 14:22:30 +00:00
|
|
|
config_block[0xa] = (unsigned char)
|
|
|
|
((global_settings.contrast & 0x3f) |
|
|
|
|
(global_settings.invert ? 0x40 : 0));
|
2002-10-01 10:59:36 +00:00
|
|
|
|
2002-10-06 10:13:48 +00:00
|
|
|
config_block[0xb] = (unsigned char)
|
|
|
|
((global_settings.backlight_on_when_charging?0x40:0) |
|
2003-04-16 00:12:31 +00:00
|
|
|
(global_settings.invert_cursor ? 0x20 : 0) |
|
|
|
|
(global_settings.backlight_timeout & 0x1f));
|
2002-08-16 14:41:47 +00:00
|
|
|
config_block[0xc] = (unsigned char)global_settings.poweroff;
|
|
|
|
config_block[0xd] = (unsigned char)global_settings.resume;
|
2002-07-15 11:02:12 +00:00
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
config_block[0xe] = (unsigned char)
|
2002-07-15 11:02:12 +00:00
|
|
|
((global_settings.playlist_shuffle & 1) |
|
2002-09-24 19:12:09 +00:00
|
|
|
((global_settings.dirfilter & 1) << 1) |
|
2002-08-06 10:52:51 +00:00
|
|
|
((global_settings.sort_case & 1) << 2) |
|
2002-08-07 10:50:46 +00:00
|
|
|
((global_settings.discharge & 1) << 3) |
|
2002-08-22 15:47:30 +00:00
|
|
|
((global_settings.statusbar & 1) << 4) |
|
2002-09-24 19:12:09 +00:00
|
|
|
((global_settings.dirfilter & 2) << 4) |
|
2002-09-18 10:12:16 +00:00
|
|
|
((global_settings.scrollbar & 1) << 6));
|
2002-10-26 05:26:23 +00:00
|
|
|
|
2002-10-14 12:50:20 +00:00
|
|
|
config_block[0xf] = (unsigned char)
|
2002-10-28 10:37:10 +00:00
|
|
|
((global_settings.volume_type & 1) |
|
|
|
|
((global_settings.battery_type & 1) << 1) |
|
|
|
|
((global_settings.timeformat & 1) << 2) |
|
|
|
|
( global_settings.scroll_speed << 3));
|
2002-07-15 11:02:12 +00:00
|
|
|
|
2002-09-04 03:38:37 +00:00
|
|
|
config_block[0x10] = (unsigned char)
|
|
|
|
((global_settings.ff_rewind_min_step & 15) << 4 |
|
|
|
|
(global_settings.ff_rewind_accel & 15));
|
2003-02-27 15:02:20 +00:00
|
|
|
|
2003-02-14 01:49:50 +00:00
|
|
|
config_block[0x11] = (unsigned char)
|
|
|
|
((global_settings.avc & 0x03) |
|
2003-02-27 15:02:20 +00:00
|
|
|
((global_settings.channel_config & 0x07) << 2));
|
2002-08-26 13:21:14 +00:00
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
memcpy(&config_block[0x12], &global_settings.resume_index, 4);
|
|
|
|
memcpy(&config_block[0x16], &global_settings.resume_offset, 4);
|
2002-09-18 10:12:16 +00:00
|
|
|
|
|
|
|
config_block[0x1a] = (unsigned char)global_settings.disk_spindown;
|
|
|
|
config_block[0x1b] = (unsigned char)
|
|
|
|
(((global_settings.browse_current & 1)) |
|
2003-01-09 00:55:00 +00:00
|
|
|
((global_settings.play_selected & 1) << 1) |
|
|
|
|
((global_settings.queue_resume & 3) << 2));
|
2002-09-18 10:12:16 +00:00
|
|
|
|
2003-04-20 22:00:30 +00:00
|
|
|
config_block[0x1c] = (unsigned char)global_settings.peak_meter_hold |
|
|
|
|
(global_settings.rec_editable?0x80:0);
|
2003-01-09 00:55:00 +00:00
|
|
|
|
|
|
|
memcpy(&config_block[0x1d], &global_settings.queue_resume_index, 4);
|
|
|
|
|
2002-11-10 23:18:33 +00:00
|
|
|
config_block[0x21] = (unsigned char)
|
|
|
|
((global_settings.repeat_mode & 3) |
|
|
|
|
((global_settings.rec_channels & 1) << 2) |
|
2002-11-11 13:13:30 +00:00
|
|
|
((global_settings.rec_mic_gain & 0x0f) << 4));
|
2002-11-10 23:18:33 +00:00
|
|
|
config_block[0x22] = (unsigned char)
|
|
|
|
((global_settings.rec_quality & 7) |
|
|
|
|
((global_settings.rec_source & 1) << 3) |
|
|
|
|
((global_settings.rec_frequency & 7) << 5));
|
|
|
|
config_block[0x23] = (unsigned char)global_settings.rec_left_gain;
|
|
|
|
config_block[0x24] = (unsigned char)global_settings.rec_right_gain;
|
2002-12-05 13:09:51 +00:00
|
|
|
config_block[0x25] = (unsigned char)
|
|
|
|
((global_settings.disk_poweroff & 1) |
|
2002-12-15 00:33:13 +00:00
|
|
|
((global_settings.buffer_margin & 7) << 1) |
|
2003-03-12 15:30:59 +00:00
|
|
|
((global_settings.trickle_charge & 1) << 4));
|
2002-10-06 05:50:41 +00:00
|
|
|
|
2002-12-02 16:07:56 +00:00
|
|
|
{
|
|
|
|
static long lasttime = 0;
|
|
|
|
|
2002-12-04 11:25:56 +00:00
|
|
|
global_settings.runtime += (current_tick - lasttime) / HZ;
|
|
|
|
lasttime = current_tick;
|
|
|
|
|
2002-12-02 16:07:56 +00:00
|
|
|
if ( global_settings.runtime > global_settings.topruntime )
|
|
|
|
global_settings.topruntime = global_settings.runtime;
|
|
|
|
|
|
|
|
config_block[0x26]=(unsigned char)(global_settings.runtime & 0xff);
|
|
|
|
config_block[0x27]=(unsigned char)(global_settings.runtime >> 8);
|
|
|
|
config_block[0x28]=(unsigned char)(global_settings.topruntime & 0xff);
|
|
|
|
config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8);
|
|
|
|
}
|
2003-02-14 15:54:52 +00:00
|
|
|
|
2003-04-23 09:17:34 +00:00
|
|
|
config_block[0xae] = (unsigned char)
|
|
|
|
((global_settings.fade_on_stop & 1) |
|
|
|
|
((global_settings.caption_backlight & 1) << 1));
|
2003-01-09 00:55:00 +00:00
|
|
|
config_block[0xb0] = (unsigned char)global_settings.peak_meter_clip_hold |
|
|
|
|
(global_settings.peak_meter_performance ? 0x80 : 0);
|
|
|
|
config_block[0xb1] = global_settings.peak_meter_release |
|
|
|
|
(global_settings.peak_meter_dbfs ? 0x80 : 0);
|
|
|
|
config_block[0xb2] = (unsigned char)global_settings.peak_meter_min;
|
|
|
|
config_block[0xb3] = (unsigned char)global_settings.peak_meter_max;
|
|
|
|
|
2002-12-16 23:33:34 +00:00
|
|
|
config_block[0xb4]=(global_settings.battery_capacity - 1000) / 50;
|
2002-12-12 15:20:37 +00:00
|
|
|
config_block[0xb5]=(unsigned char)global_settings.scroll_step;
|
|
|
|
config_block[0xb6]=(unsigned char)global_settings.scroll_delay;
|
|
|
|
config_block[0xb7]=(unsigned char)global_settings.bidir_limit;
|
|
|
|
|
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-10-06 05:50:41 +00:00
|
|
|
memcpy(&config_block[0xF4], &global_settings.resume_first_index, 4);
|
2002-08-16 14:41:47 +00:00
|
|
|
memcpy(&config_block[0xF8], &global_settings.resume_seed, 4);
|
|
|
|
|
|
|
|
strncpy(&config_block[0xFC], global_settings.resume_file, MAX_PATH);
|
2002-07-15 11:02:12 +00:00
|
|
|
|
2002-10-14 09:11:59 +00:00
|
|
|
DEBUGF( "+Resume file %s\n",global_settings.resume_file );
|
|
|
|
DEBUGF( "+Resume index %X offset %X\n",
|
|
|
|
global_settings.resume_index,
|
|
|
|
global_settings.resume_offset );
|
|
|
|
DEBUGF( "+Resume shuffle %s seed %X\n",
|
|
|
|
global_settings.playlist_shuffle?"on":"off",
|
|
|
|
global_settings.resume_seed );
|
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 */
|
|
|
|
|
2002-10-03 09:31:01 +00:00
|
|
|
void settings_apply(void)
|
|
|
|
{
|
2002-10-08 15:42:40 +00:00
|
|
|
char buf[64];
|
|
|
|
|
2002-10-03 09:31:01 +00:00
|
|
|
mpeg_sound_set(SOUND_BASS, global_settings.bass);
|
|
|
|
mpeg_sound_set(SOUND_TREBLE, global_settings.treble);
|
|
|
|
mpeg_sound_set(SOUND_BALANCE, global_settings.balance);
|
|
|
|
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
|
2003-02-14 01:49:50 +00:00
|
|
|
mpeg_sound_set(SOUND_CHANNELS, global_settings.channel_config);
|
2002-10-03 09:31:01 +00:00
|
|
|
#ifdef HAVE_MAS3587F
|
|
|
|
mpeg_sound_set(SOUND_LOUDNESS, global_settings.loudness);
|
|
|
|
mpeg_sound_set(SOUND_SUPERBASS, global_settings.bass_boost);
|
|
|
|
mpeg_sound_set(SOUND_AVC, global_settings.avc);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
lcd_set_contrast(global_settings.contrast);
|
|
|
|
lcd_scroll_speed(global_settings.scroll_speed);
|
|
|
|
backlight_set_timeout(global_settings.backlight_timeout);
|
|
|
|
backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
|
|
|
|
ata_spindown(global_settings.disk_spindown);
|
2002-11-30 09:42:13 +00:00
|
|
|
|
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);
|
|
|
|
#ifdef HAVE_CHARGE_CTRL
|
2002-10-14 09:11:59 +00:00
|
|
|
charge_restart_level = global_settings.discharge ?
|
|
|
|
CHARGE_RESTART_LO : CHARGE_RESTART_HI;
|
2002-12-15 00:33:13 +00:00
|
|
|
enable_trickle_charge(global_settings.trickle_charge);
|
2002-10-03 09:31:01 +00:00
|
|
|
#endif
|
2002-10-08 15:42:40 +00:00
|
|
|
|
2002-12-16 22:58:48 +00:00
|
|
|
set_battery_capacity(global_settings.battery_capacity);
|
|
|
|
|
2002-10-29 12:09:15 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2003-02-27 14:22:30 +00:00
|
|
|
lcd_set_invert_display(global_settings.invert);
|
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 ) {
|
2002-10-08 15:42:40 +00:00
|
|
|
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.fnt",
|
|
|
|
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);
|
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 ) {
|
2002-10-08 15:42:40 +00:00
|
|
|
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.lng",
|
|
|
|
global_settings.lang_file);
|
|
|
|
lang_load(buf);
|
|
|
|
}
|
2002-10-03 09:31:01 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
*/
|
2002-07-15 11:02:12 +00:00
|
|
|
void settings_load(void)
|
2002-06-27 00:20:00 +00:00
|
|
|
{
|
2002-07-15 11:02:12 +00:00
|
|
|
|
2002-06-27 00:20:00 +00:00
|
|
|
DEBUGF( "reload_all_settings()\n" );
|
|
|
|
|
|
|
|
/* populate settings with default values */
|
2002-07-15 11:02:12 +00:00
|
|
|
settings_reset();
|
2002-06-27 00:20:00 +00:00
|
|
|
|
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 */
|
|
|
|
if (!load_config_buffer()) {
|
2002-08-16 14:41:47 +00:00
|
|
|
if (config_block[0x4] != 0xFF)
|
|
|
|
global_settings.volume = config_block[0x4];
|
|
|
|
if (config_block[0x5] != 0xFF)
|
2002-10-02 23:16:32 +00:00
|
|
|
global_settings.balance = (char)config_block[0x5];
|
2002-08-16 14:41:47 +00:00
|
|
|
if (config_block[0x6] != 0xFF)
|
|
|
|
global_settings.bass = config_block[0x6];
|
|
|
|
if (config_block[0x7] != 0xFF)
|
|
|
|
global_settings.treble = config_block[0x7];
|
|
|
|
if (config_block[0x8] != 0xFF)
|
|
|
|
global_settings.loudness = config_block[0x8];
|
|
|
|
if (config_block[0x9] != 0xFF)
|
|
|
|
global_settings.bass_boost = config_block[0x9];
|
2002-07-15 11:02:12 +00:00
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
if (config_block[0xa] != 0xFF) {
|
2003-02-27 14:22:30 +00:00
|
|
|
global_settings.contrast = config_block[0xa] & 0x3f;
|
|
|
|
global_settings.invert =
|
|
|
|
config_block[0xa] & 0x40 ? true : false;
|
2002-08-13 17:16:09 +00:00
|
|
|
if ( global_settings.contrast < MIN_CONTRAST_SETTING )
|
2002-08-13 17:20:25 +00:00
|
|
|
global_settings.contrast = DEFAULT_CONTRAST_SETTING;
|
2002-08-13 17:16:09 +00:00
|
|
|
}
|
2002-10-06 10:13:48 +00:00
|
|
|
|
2002-10-01 10:59:36 +00:00
|
|
|
if (config_block[0xb] != 0xFF) {
|
2002-10-06 10:13:48 +00:00
|
|
|
/* Bit 7 is unused to be able to detect uninitialized entry */
|
2003-04-16 00:12:31 +00:00
|
|
|
global_settings.backlight_timeout = config_block[0xb] & 0x1f;
|
|
|
|
global_settings.invert_cursor =
|
|
|
|
config_block[0xb] & 0x20 ? true : false;
|
2002-10-06 10:13:48 +00:00
|
|
|
global_settings.backlight_on_when_charging =
|
|
|
|
config_block[0xb] & 0x40 ? true : false;
|
2002-10-01 10:59:36 +00:00
|
|
|
}
|
2002-10-06 10:13:48 +00:00
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
if (config_block[0xc] != 0xFF)
|
|
|
|
global_settings.poweroff = config_block[0xc];
|
|
|
|
if (config_block[0xd] != 0xFF)
|
|
|
|
global_settings.resume = config_block[0xd];
|
|
|
|
if (config_block[0xe] != 0xFF) {
|
|
|
|
global_settings.playlist_shuffle = config_block[0xe] & 1;
|
2002-09-24 19:12:09 +00:00
|
|
|
global_settings.dirfilter = (config_block[0xe] >> 1) & 1;
|
2002-08-16 14:41:47 +00:00
|
|
|
global_settings.sort_case = (config_block[0xe] >> 2) & 1;
|
|
|
|
global_settings.discharge = (config_block[0xe] >> 3) & 1;
|
|
|
|
global_settings.statusbar = (config_block[0xe] >> 4) & 1;
|
2002-09-24 19:12:09 +00:00
|
|
|
global_settings.dirfilter |= ((config_block[0xe] >> 5) & 1) << 1;
|
2002-08-30 13:49:32 +00:00
|
|
|
global_settings.scrollbar = (config_block[0xe] >> 6) & 1;
|
2002-09-18 10:12:16 +00:00
|
|
|
/* Don't use the last bit, it must be unused to detect
|
|
|
|
an uninitialized entry */
|
2002-07-15 11:02:12 +00:00
|
|
|
}
|
2002-08-06 10:52:51 +00:00
|
|
|
|
2002-10-14 12:50:20 +00:00
|
|
|
if (config_block[0xf] != 0xFF) {
|
2002-10-28 10:37:10 +00:00
|
|
|
global_settings.volume_type = config_block[0xf] & 1;
|
|
|
|
global_settings.battery_type = (config_block[0xf] >> 1) & 1;
|
2002-10-14 12:50:20 +00:00
|
|
|
global_settings.timeformat = (config_block[0xf] >> 2) & 1;
|
|
|
|
global_settings.scroll_speed = config_block[0xf] >> 3;
|
|
|
|
}
|
2002-07-15 11:02:12 +00:00
|
|
|
|
2002-09-04 03:38:37 +00:00
|
|
|
if (config_block[0x10] != 0xFF) {
|
|
|
|
global_settings.ff_rewind_min_step = (config_block[0x10] >> 4) & 15;
|
|
|
|
global_settings.ff_rewind_accel = config_block[0x10] & 15;
|
|
|
|
}
|
2002-08-16 14:41:47 +00:00
|
|
|
|
|
|
|
if (config_block[0x11] != 0xFF)
|
2002-09-09 15:25:54 +00:00
|
|
|
{
|
|
|
|
global_settings.avc = config_block[0x11] & 0x03;
|
2003-02-27 15:02:20 +00:00
|
|
|
global_settings.channel_config = (config_block[0x11] >> 2) & 0x07;
|
2002-09-09 15:25:54 +00:00
|
|
|
}
|
2002-08-16 14:41:47 +00:00
|
|
|
|
|
|
|
if (config_block[0x12] != 0xFF)
|
|
|
|
memcpy(&global_settings.resume_index, &config_block[0x12], 4);
|
|
|
|
|
|
|
|
if (config_block[0x16] != 0xFF)
|
|
|
|
memcpy(&global_settings.resume_offset, &config_block[0x16], 4);
|
|
|
|
|
2002-08-26 13:21:14 +00:00
|
|
|
if (config_block[0x1a] != 0xFF)
|
|
|
|
global_settings.disk_spindown = config_block[0x1a];
|
|
|
|
|
2002-09-18 10:12:16 +00:00
|
|
|
if (config_block[0x1b] != 0xFF) {
|
|
|
|
global_settings.browse_current = (config_block[0x1b]) & 1;
|
|
|
|
global_settings.play_selected = (config_block[0x1b] >> 1) & 1;
|
2003-01-09 00:55:00 +00:00
|
|
|
global_settings.queue_resume = (config_block[0x1b] >> 2) & 3;
|
2002-09-18 10:12:16 +00:00
|
|
|
}
|
|
|
|
|
2003-04-20 22:00:30 +00:00
|
|
|
if (config_block[0x1c] != 0xFF) {
|
2002-09-27 09:31:31 +00:00
|
|
|
global_settings.peak_meter_hold = (config_block[0x1c]) & 0x1f;
|
2003-04-20 22:00:30 +00:00
|
|
|
global_settings.rec_editable =
|
2003-04-28 23:15:54 +00:00
|
|
|
(config_block[0x1c] & 0x80)?true:false;
|
2003-04-20 22:00:30 +00:00
|
|
|
}
|
2002-09-27 09:31:31 +00:00
|
|
|
|
2003-01-09 00:55:00 +00:00
|
|
|
if (config_block[0x1d] != 0xFF)
|
|
|
|
memcpy(&global_settings.queue_resume_index, &config_block[0x1d],
|
|
|
|
4);
|
2002-10-29 12:09:15 +00:00
|
|
|
|
|
|
|
if (config_block[0x21] != 0xFF)
|
2002-11-10 23:18:33 +00:00
|
|
|
{
|
|
|
|
global_settings.repeat_mode = config_block[0x21] & 3;
|
|
|
|
global_settings.rec_channels = (config_block[0x21] >> 2) & 1;
|
|
|
|
global_settings.rec_mic_gain = (config_block[0x21] >> 4) & 0x0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config_block[0x22] != 0xFF)
|
|
|
|
{
|
|
|
|
global_settings.rec_quality = config_block[0x22] & 7;
|
|
|
|
global_settings.rec_source = (config_block[0x22] >> 3) & 3;
|
|
|
|
global_settings.rec_frequency = (config_block[0x22] >> 5) & 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config_block[0x23] != 0xFF)
|
|
|
|
global_settings.rec_left_gain = config_block[0x23] & 0x0f;
|
2002-10-04 08:48:20 +00:00
|
|
|
|
2002-08-16 14:41:47 +00:00
|
|
|
if (config_block[0x24] != 0xFF)
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_right_gain = config_block[0x24] & 0x0f;
|
2002-08-07 10:35:26 +00:00
|
|
|
|
2002-11-28 22:46:19 +00:00
|
|
|
if (config_block[0x25] != 0xFF)
|
2002-12-05 13:09:51 +00:00
|
|
|
{
|
2002-11-28 22:46:19 +00:00
|
|
|
global_settings.disk_poweroff = config_block[0x25] & 1;
|
2002-12-05 13:09:51 +00:00
|
|
|
global_settings.buffer_margin = (config_block[0x25] >> 1) & 7;
|
2002-12-15 00:33:13 +00:00
|
|
|
global_settings.trickle_charge = (config_block[0x25] >> 4) & 1;
|
2002-12-05 13:09:51 +00:00
|
|
|
}
|
2002-11-28 22:46:19 +00:00
|
|
|
|
2002-12-02 16:07:56 +00:00
|
|
|
if (config_block[0x27] != 0xff)
|
|
|
|
global_settings.runtime =
|
|
|
|
config_block[0x26] | (config_block[0x27] << 8);
|
|
|
|
|
|
|
|
if (config_block[0x29] != 0xff)
|
|
|
|
global_settings.topruntime =
|
|
|
|
config_block[0x28] | (config_block[0x29] << 8);
|
|
|
|
|
2003-04-23 09:17:34 +00:00
|
|
|
global_settings.fade_on_stop = config_block[0xae] & 1;
|
2003-04-25 10:23:05 +00:00
|
|
|
global_settings.caption_backlight = (config_block[0xae] >> 1) & 1;
|
2003-04-16 00:12:31 +00:00
|
|
|
|
2003-01-09 00:55:00 +00:00
|
|
|
global_settings.peak_meter_clip_hold = (config_block[0xb0]) & 0x1f;
|
|
|
|
global_settings.peak_meter_performance =
|
|
|
|
(config_block[0xb0] & 0x80) != 0;
|
|
|
|
|
|
|
|
global_settings.peak_meter_release = config_block[0xb1] & 0x7f;
|
|
|
|
global_settings.peak_meter_dbfs = (config_block[0xb1] & 0x80) != 0;
|
|
|
|
|
|
|
|
global_settings.peak_meter_min = config_block[0xb2];
|
|
|
|
global_settings.peak_meter_max = config_block[0xb3];
|
|
|
|
|
2002-12-16 23:33:34 +00:00
|
|
|
global_settings.battery_capacity = config_block[0xb4]*50 + 1000;
|
2002-12-16 22:58:48 +00:00
|
|
|
|
2002-12-12 15:20:37 +00:00
|
|
|
if (config_block[0xb5] != 0xff)
|
|
|
|
global_settings.scroll_step = config_block[0xb5];
|
|
|
|
|
|
|
|
if (config_block[0xb6] != 0xff)
|
|
|
|
global_settings.scroll_delay = config_block[0xb6];
|
|
|
|
|
|
|
|
if (config_block[0xb7] != 0xff)
|
|
|
|
global_settings.bidir_limit = config_block[0xb7];
|
|
|
|
|
2003-04-16 00:12:31 +00:00
|
|
|
if (config_block[0xae] != 0xff)
|
|
|
|
global_settings.fade_on_stop = config_block[0xae];
|
|
|
|
|
2002-10-06 05:50:41 +00:00
|
|
|
memcpy(&global_settings.resume_first_index, &config_block[0xF4], 4);
|
|
|
|
memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
|
|
|
|
|
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);
|
2002-08-16 14:41:47 +00:00
|
|
|
strncpy(global_settings.resume_file, &config_block[0xFC], MAX_PATH);
|
|
|
|
global_settings.resume_file[MAX_PATH]=0;
|
2002-07-15 11:02:12 +00:00
|
|
|
}
|
2002-10-03 09:31:01 +00:00
|
|
|
|
|
|
|
settings_apply();
|
2002-06-27 00:20:00 +00:00
|
|
|
}
|
|
|
|
|
2002-10-29 12:16:36 +00:00
|
|
|
/* Read (up to) a line of text from fd into buffer and return number of bytes
|
|
|
|
* read (which may be larger than the number of bytes stored in buffer). If
|
|
|
|
* an error occurs, -1 is returned (and buffer contains whatever could be
|
|
|
|
* read). A line is terminated by a LF char. Neither LF nor CR chars are
|
|
|
|
* stored in buffer.
|
|
|
|
*/
|
2002-10-02 16:33:26 +00:00
|
|
|
static int read_line(int fd, char* buffer, int buffer_size)
|
|
|
|
{
|
|
|
|
int count = 0;
|
2002-10-29 12:16:36 +00:00
|
|
|
int num_read = 0;
|
|
|
|
|
|
|
|
errno = 0;
|
2002-10-02 16:33:26 +00:00
|
|
|
|
|
|
|
while (count < buffer_size)
|
|
|
|
{
|
|
|
|
unsigned char c;
|
|
|
|
|
|
|
|
if (1 != read(fd, &c, 1))
|
|
|
|
break;
|
|
|
|
|
2002-10-29 12:16:36 +00:00
|
|
|
num_read++;
|
|
|
|
|
2002-10-02 16:33:26 +00:00
|
|
|
if ( c == '\n' )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ( c == '\r' )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
buffer[count++] = c;
|
|
|
|
}
|
|
|
|
|
2002-10-29 12:16:36 +00:00
|
|
|
buffer[MIN(count, buffer_size - 1)] = 0;
|
2002-10-02 16:33:26 +00:00
|
|
|
|
2002-10-29 12:16:36 +00:00
|
|
|
return errno ? -1 : num_read;
|
2002-10-02 16:33:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* parse a line from a configuration file. the line format is:
|
|
|
|
|
|
|
|
setting name: setting value
|
|
|
|
|
|
|
|
Any whitespace before setting name or value (after ':') is ignored.
|
|
|
|
A # as first non-whitespace character discards the whole line.
|
|
|
|
Function sets pointers to null-terminated setting name and value.
|
|
|
|
Returns false if no valid config entry was found.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool settings_parseline(char* line, char** name, char** value)
|
|
|
|
{
|
|
|
|
char* ptr;
|
|
|
|
|
|
|
|
while ( isspace(*line) )
|
|
|
|
line++;
|
|
|
|
|
|
|
|
if ( *line == '#' )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ptr = strchr(line, ':');
|
|
|
|
if ( !ptr )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
*name = line;
|
|
|
|
*ptr = 0;
|
|
|
|
ptr++;
|
|
|
|
while (isspace(*ptr))
|
|
|
|
ptr++;
|
|
|
|
*value = ptr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(ROCKBOX_DIR, filename) || (len-extlen > maxlen))
|
|
|
|
return;
|
|
|
|
|
|
|
|
strncpy(setting, fptr, len-extlen);
|
|
|
|
setting[len-extlen]=0;
|
|
|
|
|
|
|
|
settings_save();
|
|
|
|
}
|
|
|
|
|
2002-10-08 09:40:05 +00:00
|
|
|
static void set_sound(char* value, int type, int* setting)
|
2002-10-02 16:33:26 +00:00
|
|
|
{
|
|
|
|
int num = atoi(value);
|
|
|
|
|
|
|
|
num = mpeg_phys2val(type, num);
|
|
|
|
|
|
|
|
if ((num > mpeg_sound_max(type)) ||
|
|
|
|
(num < mpeg_sound_min(type)))
|
|
|
|
{
|
|
|
|
num = mpeg_sound_default(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
*setting = num;
|
|
|
|
mpeg_sound_set(type, num);
|
2002-10-29 12:16:36 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_MAS3507D
|
|
|
|
/* This is required to actually apply balance */
|
|
|
|
if (SOUND_BALANCE == type)
|
|
|
|
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
|
|
|
|
#endif
|
2002-10-02 16:33:26 +00:00
|
|
|
}
|
|
|
|
|
2003-02-14 14:14:55 +00:00
|
|
|
static void set_cfg_bool(bool* variable, char* value)
|
|
|
|
{
|
|
|
|
/* look for the 'n' in 'on' */
|
|
|
|
if ((value[1] & 0xdf) == 'N')
|
|
|
|
*variable = true;
|
|
|
|
else
|
|
|
|
*variable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_cfg_int(int* variable, char* value, int min, int max )
|
|
|
|
{
|
|
|
|
*variable = atoi(value);
|
|
|
|
|
|
|
|
if (*variable < min)
|
|
|
|
*variable = min;
|
|
|
|
else
|
|
|
|
if (*variable > max)
|
|
|
|
*variable = max;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_cfg_option(int* variable, char* value,
|
|
|
|
char* options[], int numoptions )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<numoptions; i++) {
|
|
|
|
if (!strcasecmp(options[i], value)) {
|
|
|
|
*variable = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-08 09:40:05 +00:00
|
|
|
bool settings_load_config(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;
|
|
|
|
|
|
|
|
if (!settings_parseline(line, &name, &value))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!strcasecmp(name, "volume"))
|
2002-10-08 09:40:05 +00:00
|
|
|
set_sound(value, SOUND_VOLUME, &global_settings.volume);
|
2002-10-02 16:33:26 +00:00
|
|
|
else if (!strcasecmp(name, "bass"))
|
2002-10-08 09:40:05 +00:00
|
|
|
set_sound(value, SOUND_BASS, &global_settings.bass);
|
2002-10-02 16:33:26 +00:00
|
|
|
else if (!strcasecmp(name, "treble"))
|
2002-10-08 09:40:05 +00:00
|
|
|
set_sound(value, SOUND_TREBLE, &global_settings.treble);
|
2002-10-02 16:33:26 +00:00
|
|
|
else if (!strcasecmp(name, "balance"))
|
2002-10-08 09:40:05 +00:00
|
|
|
set_sound(value, SOUND_BALANCE, &global_settings.balance);
|
2003-02-17 09:53:11 +00:00
|
|
|
else if (!strcasecmp(name, "channels")) {
|
|
|
|
static char* options[] = {
|
2003-03-10 14:07:36 +00:00
|
|
|
"stereo","stereo narrow","mono","mono left",
|
|
|
|
"mono right","karaoke","stereo wide"};
|
2003-02-17 09:53:11 +00:00
|
|
|
set_cfg_option(&global_settings.channel_config, value,
|
2003-03-10 14:07:36 +00:00
|
|
|
options, 7);
|
2003-02-17 09:53:11 +00:00
|
|
|
}
|
|
|
|
else 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))
|
|
|
|
set_file(value, global_settings.lang_file, MAX_FILENAME);
|
|
|
|
}
|
2003-02-17 12:08:46 +00:00
|
|
|
else if (!strcasecmp(name, "bidir limit"))
|
|
|
|
set_cfg_int(&global_settings.bidir_limit, value, 0, 200);
|
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);
|
|
|
|
}
|
2003-02-14 14:14:55 +00:00
|
|
|
else if (!strcasecmp(name, "scroll step"))
|
|
|
|
set_cfg_int(&global_settings.scroll_step, value, 1, LCD_WIDTH);
|
|
|
|
else if (!strcasecmp(name, "statusbar"))
|
|
|
|
set_cfg_bool(&global_settings.statusbar, value);
|
|
|
|
else if (!strcasecmp(name, "peak meter release"))
|
|
|
|
set_cfg_int(&global_settings.peak_meter_release, value, 1, 0x7e);
|
|
|
|
else if (!strcasecmp(name, "peak meter hold")) {
|
|
|
|
static char* options[] = {
|
|
|
|
"off","200ms","300ms","500ms",
|
|
|
|
"1","2","3","4","5","6","7","8","9","10",
|
2003-02-25 19:12:14 +00:00
|
|
|
"15","20","30","1min"};
|
2003-02-14 14:14:55 +00:00
|
|
|
set_cfg_option(&global_settings.peak_meter_hold, value,
|
2003-02-25 19:12:14 +00:00
|
|
|
options, 18);
|
2003-02-14 14:14:55 +00:00
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "peak meter clip hold")) {
|
|
|
|
static char* options[] = {
|
|
|
|
"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"};
|
|
|
|
set_cfg_option(&global_settings.peak_meter_clip_hold, value,
|
|
|
|
options, 25);
|
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "peak meter dbfs"))
|
|
|
|
set_cfg_bool(&global_settings.peak_meter_dbfs, value);
|
|
|
|
else if (!strcasecmp(name, "peak meter min"))
|
|
|
|
set_cfg_int(&global_settings.peak_meter_min, value, 0, 100);
|
|
|
|
else if (!strcasecmp(name, "peak meter max"))
|
|
|
|
set_cfg_int(&global_settings.peak_meter_max, value, 0, 100);
|
|
|
|
else if (!strcasecmp(name, "peak meter busy"))
|
|
|
|
set_cfg_bool(&global_settings.peak_meter_performance, value);
|
2003-02-17 09:53:11 +00:00
|
|
|
else if (!strcasecmp(name, "volume display")) {
|
|
|
|
static char* options[] = {"graphic", "numeric"};
|
|
|
|
set_cfg_option(&global_settings.volume_type, value, options, 2);
|
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "battery display")) {
|
|
|
|
static char* options[] = {"graphic", "numeric"};
|
|
|
|
set_cfg_option(&global_settings.battery_type, value, options, 2);
|
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "time format")) {
|
|
|
|
static char* options[] = {"24hour", "12hour"};
|
|
|
|
set_cfg_option(&global_settings.timeformat, value, options, 2);
|
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "scrollbar"))
|
|
|
|
set_cfg_bool(&global_settings.scrollbar, value);
|
2003-03-10 14:07:36 +00:00
|
|
|
else if (!strcasecmp(name, "invert"))
|
|
|
|
set_cfg_bool(&global_settings.invert, value);
|
2003-04-16 00:12:31 +00:00
|
|
|
else if (!strcasecmp(name, "invert cursor"))
|
|
|
|
set_cfg_bool(&global_settings.invert_cursor, value);
|
2003-02-14 14:14:55 +00:00
|
|
|
#endif
|
2003-04-24 12:14:28 +00:00
|
|
|
else if (!strcasecmp(name, "caption backlight"))
|
|
|
|
set_cfg_bool(&global_settings.caption_backlight, value);
|
2003-02-14 14:14:55 +00:00
|
|
|
else if (!strcasecmp(name, "shuffle"))
|
|
|
|
set_cfg_bool(&global_settings.playlist_shuffle, value);
|
|
|
|
else if (!strcasecmp(name, "repeat")) {
|
|
|
|
static char* options[] = {"off", "all", "one"};
|
|
|
|
set_cfg_option(&global_settings.repeat_mode, value, options, 3);
|
|
|
|
}
|
2003-02-17 09:53:11 +00:00
|
|
|
else if (!strcasecmp(name, "resume")) {
|
|
|
|
static char* options[] = {"off", "ask", "ask once", "on"};
|
|
|
|
set_cfg_option(&global_settings.resume, value, options, 4);
|
|
|
|
}
|
2003-02-14 14:14:55 +00:00
|
|
|
else if (!strcasecmp(name, "sort case"))
|
|
|
|
set_cfg_bool(&global_settings.sort_case, value);
|
|
|
|
else if (!strcasecmp(name, "show files")) {
|
2003-02-17 09:53:11 +00:00
|
|
|
static char* options[] = {"all", "supported","music", "playlists"};
|
|
|
|
set_cfg_option(&global_settings.dirfilter, value, options, 4);
|
2003-02-14 14:14:55 +00:00
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "follow playlist"))
|
|
|
|
set_cfg_bool(&global_settings.browse_current, value);
|
|
|
|
else if (!strcasecmp(name, "play selected"))
|
|
|
|
set_cfg_bool(&global_settings.play_selected, value);
|
|
|
|
else if (!strcasecmp(name, "contrast"))
|
|
|
|
set_cfg_int(&global_settings.contrast, value,
|
|
|
|
0, MAX_CONTRAST_SETTING);
|
|
|
|
else if (!strcasecmp(name, "scroll speed"))
|
|
|
|
set_cfg_int(&global_settings.scroll_speed, value, 1, 10);
|
|
|
|
else if (!strcasecmp(name, "scan min step")) {
|
|
|
|
static char* options[] =
|
2003-02-17 09:53:11 +00:00
|
|
|
{"1","2","3","4","5","6","8","10",
|
|
|
|
"15","20","25","30","45","60"};
|
2003-02-14 14:14:55 +00:00
|
|
|
set_cfg_option(&global_settings.ff_rewind_min_step, value,
|
2003-02-17 09:53:11 +00:00
|
|
|
options, 14);
|
2003-02-14 14:14:55 +00:00
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "scan accel"))
|
2003-02-17 09:53:11 +00:00
|
|
|
set_cfg_int(&global_settings.ff_rewind_accel, value, 0, 15);
|
2003-02-14 14:14:55 +00:00
|
|
|
else if (!strcasecmp(name, "scroll delay"))
|
|
|
|
set_cfg_int(&global_settings.scroll_delay, value, 0, 250);
|
|
|
|
else if (!strcasecmp(name, "backlight timeout")) {
|
|
|
|
static char* options[] = {
|
|
|
|
"off","on","1","2","3","4","5","6","7","8","9",
|
2003-02-25 19:12:14 +00:00
|
|
|
"10","15","20","25","30","45","60","90"};
|
2003-02-14 14:14:55 +00:00
|
|
|
set_cfg_option(&global_settings.backlight_timeout, value,
|
2003-02-25 19:12:14 +00:00
|
|
|
options, 19);
|
2003-02-14 14:14:55 +00:00
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "backlight when plugged"))
|
|
|
|
set_cfg_bool(&global_settings.backlight_on_when_charging, value);
|
|
|
|
else if (!strcasecmp(name, "antiskip"))
|
|
|
|
set_cfg_int(&global_settings.buffer_margin, value, 0, 7);
|
|
|
|
else if (!strcasecmp(name, "disk spindown"))
|
|
|
|
set_cfg_int(&global_settings.disk_spindown, value, 3, 254);
|
|
|
|
#ifdef HAVE_ATA_POWER_OFF
|
|
|
|
else if (!strcasecmp(name, "disk poweroff"))
|
|
|
|
set_cfg_bool(&global_settings.disk_poweroff, value);
|
|
|
|
#endif
|
2002-10-02 16:33:26 +00:00
|
|
|
#ifdef HAVE_MAS3587F
|
|
|
|
else if (!strcasecmp(name, "loudness"))
|
2002-10-08 09:40:05 +00:00
|
|
|
set_sound(value, SOUND_LOUDNESS, &global_settings.loudness);
|
2002-10-02 16:33:26 +00:00
|
|
|
else if (!strcasecmp(name, "bass boost"))
|
2002-10-08 09:40:05 +00:00
|
|
|
set_sound(value, SOUND_SUPERBASS, &global_settings.bass_boost);
|
2003-03-10 14:07:36 +00:00
|
|
|
else if (!strcasecmp(name, "auto volume")) {
|
|
|
|
static char* options[] = {"off", "2", "4", "8" };
|
|
|
|
set_cfg_option(&global_settings.avc, value, options, 4);
|
|
|
|
}
|
2003-02-14 14:14:55 +00:00
|
|
|
else if (!strcasecmp(name, "rec mic gain"))
|
|
|
|
set_sound(value, SOUND_MIC_GAIN, &global_settings.rec_mic_gain);
|
|
|
|
else if (!strcasecmp(name, "rec left gain"))
|
|
|
|
set_sound(value, SOUND_LEFT_GAIN, &global_settings.rec_left_gain);
|
|
|
|
else if (!strcasecmp(name, "rec right gain"))
|
|
|
|
set_sound(value, SOUND_RIGHT_GAIN, &global_settings.rec_right_gain);
|
|
|
|
else if (!strcasecmp(name, "rec quality"))
|
|
|
|
set_cfg_int(&global_settings.rec_quality, value, 0, 7);
|
|
|
|
else if (!strcasecmp(name, "rec source")) {
|
|
|
|
static char* options[] = {"mic", "line", "spdif"};
|
|
|
|
set_cfg_option(&global_settings.rec_source, value, options, 3);
|
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "rec frequency")) {
|
|
|
|
static char* options[] = {"44", "48", "32", "22", "24", "16"};
|
|
|
|
set_cfg_option(&global_settings.rec_frequency, value, options, 6);
|
|
|
|
}
|
|
|
|
else if (!strcasecmp(name, "rec channels")) {
|
|
|
|
static char* options[] = {"stereo", "mono"};
|
|
|
|
set_cfg_option(&global_settings.rec_channels, value, options, 2);
|
|
|
|
}
|
2003-04-20 22:00:30 +00:00
|
|
|
else if (!strcasecmp(name, "editable recordings")) {
|
|
|
|
set_cfg_bool(&global_settings.rec_editable, value);
|
|
|
|
}
|
2003-02-14 14:14:55 +00:00
|
|
|
#endif
|
2003-02-17 09:53:11 +00:00
|
|
|
else if (!strcasecmp(name, "idle poweroff")) {
|
|
|
|
static char* options[] = {"off","1","2","3","4","5","6","7","8",
|
|
|
|
"9","10","15","30","45","60"};
|
|
|
|
set_cfg_option(&global_settings.poweroff, value, options, 15);
|
|
|
|
}
|
2003-02-14 14:14:55 +00:00
|
|
|
else if (!strcasecmp(name, "battery capacity"))
|
|
|
|
set_cfg_int(&global_settings.battery_capacity, value,
|
|
|
|
1500, BATTERY_CAPACITY_MAX);
|
|
|
|
#ifdef HAVE_CHARGE_CTRL
|
|
|
|
else if (!strcasecmp(name, "deep discharge"))
|
|
|
|
set_cfg_bool(&global_settings.discharge, value);
|
|
|
|
else if (!strcasecmp(name, "trickle charge"))
|
|
|
|
set_cfg_bool(&global_settings.trickle_charge, value);
|
2002-10-02 16:33:26 +00:00
|
|
|
#endif
|
2003-02-14 15:54:52 +00:00
|
|
|
else if (!strcasecmp(name, "volume fade"))
|
|
|
|
set_cfg_bool(&global_settings.fade_on_stop, value);
|
2002-09-05 01:20:10 +00:00
|
|
|
}
|
2002-10-02 16:33:26 +00:00
|
|
|
|
|
|
|
close(fd);
|
2003-02-14 14:14:55 +00:00
|
|
|
settings_apply();
|
2002-10-02 16:37:05 +00:00
|
|
|
settings_save();
|
2002-10-02 16:33:26 +00:00
|
|
|
return true;
|
2002-09-05 01:20:10 +00:00
|
|
|
}
|
|
|
|
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
bool settings_save_config(void)
|
|
|
|
{
|
|
|
|
bool done = false;
|
|
|
|
int fd, i, value;
|
|
|
|
char filename[MAX_PATH];
|
2003-04-24 12:44:18 +00:00
|
|
|
char* boolopt[] = {"off","on"};
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
/* find unused filename */
|
|
|
|
for (i=0; ; i++) {
|
|
|
|
snprintf(filename, sizeof filename, "/.rockbox/config%02d.cfg", i);
|
|
|
|
fd = open(filename, O_RDONLY);
|
|
|
|
if (fd < 0)
|
|
|
|
break;
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allow user to modify filename */
|
|
|
|
while (!done) {
|
|
|
|
if (!kbd_input(filename, sizeof filename)) {
|
|
|
|
fd = creat(filename,0);
|
|
|
|
if (fd < 0) {
|
|
|
|
lcd_clear_display();
|
|
|
|
lcd_puts(0,0,str(LANG_FAILED));
|
|
|
|
lcd_update();
|
|
|
|
sleep(HZ);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* abort if file couldn't be created */
|
|
|
|
if (!done) {
|
|
|
|
lcd_clear_display();
|
|
|
|
lcd_puts(0,0,str(LANG_RESET_DONE_CANCEL));
|
|
|
|
lcd_update();
|
|
|
|
sleep(HZ);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-04-25 10:33:38 +00:00
|
|
|
fprintf(fd, "# >>> .cfg file created by rockbox %s <<<\r\n", appsversion);
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "# >>> http://rockbox.haxx.se <<<\r\n#\r\n");
|
|
|
|
fprintf(fd, "#\r\n# wps / language / font \r\n#\r\n");
|
2003-03-10 16:31:02 +00:00
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
if (global_settings.wps_file[0] != 0)
|
|
|
|
fprintf(fd, "wps: /.rockbox/%s.wps\r\n", 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)
|
|
|
|
fprintf(fd, "lang: /.rockbox/%s.lng\r\n", 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)
|
|
|
|
fprintf(fd, "font: /.rockbox/%s.fnt\r\n", global_settings.font_file);
|
2003-03-10 16:31:02 +00:00
|
|
|
#endif
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "#\r\n# Sound settings\r\n#\r\n");
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
value = mpeg_val2phys(SOUND_VOLUME, global_settings.volume);
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "volume: %d\r\n", value);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
value = mpeg_val2phys(SOUND_BASS, global_settings.bass);
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "bass: %d\r\n", value);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
value = mpeg_val2phys(SOUND_TREBLE, global_settings.treble);
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "treble: %d\r\n", value);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
value = mpeg_val2phys(SOUND_BALANCE, global_settings.balance);
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "balance: %d\r\n", value);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] =
|
|
|
|
{"stereo","stereo narrow","mono","mono left",
|
|
|
|
"mono right","karaoke","stereo wide"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "channels: %s\r\n",
|
|
|
|
options[global_settings.channel_config]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_MAS3587F
|
|
|
|
value = mpeg_val2phys(SOUND_LOUDNESS, global_settings.loudness);
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "loudness: %d\r\n", value);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
value = mpeg_val2phys(SOUND_SUPERBASS, global_settings.bass_boost);
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "bass boost: %d\r\n", value);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
2003-03-10 20:56:20 +00:00
|
|
|
{
|
|
|
|
static char* options[] = {"off", "2", "4", "8" };
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "auto volume: %s\r\n", options[global_settings.avc]);
|
2003-03-10 20:56:20 +00:00
|
|
|
}
|
2003-03-10 16:31:02 +00:00
|
|
|
#endif
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "#\r\n# Playback\r\n#\r\n");
|
|
|
|
fprintf(fd, "shuffle: %s\r\n", boolopt[global_settings.playlist_shuffle]);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] = {"off", "all", "one"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "repeat: %s\r\n", options[global_settings.repeat_mode]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "play selected: %s\r\n",
|
|
|
|
boolopt[global_settings.play_selected]);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] = {"off", "ask", "ask once", "on"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "resume: %s\r\n", options[global_settings.resume]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] =
|
|
|
|
{"1","2","3","4","5","6","8","10",
|
|
|
|
"15","20","25","30","45","60"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "scan min step: %s\r\n",
|
|
|
|
options[global_settings.ff_rewind_min_step]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "scan accel: %d\r\nantiskip: %d\r\n",
|
|
|
|
global_settings.ff_rewind_accel,
|
|
|
|
global_settings.buffer_margin);
|
|
|
|
fprintf(fd, "volume fade: %s\r\n", boolopt[global_settings.fade_on_stop]);
|
|
|
|
fprintf(fd, "#\r\n# File View\r\n#\r\n");
|
|
|
|
fprintf(fd, "sort case: %s\r\n", boolopt[global_settings.sort_case]);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
{
|
2003-04-24 17:53:17 +00:00
|
|
|
static char* options[] = {"all", "supported","music", "playlists"};
|
|
|
|
fprintf(fd, "show files: %s\r\n", options[global_settings.dirfilter]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "follow playlist: %s\r\n",
|
|
|
|
boolopt[global_settings.browse_current]);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "#\r\n# Display\r\n#\r\n");
|
|
|
|
|
2003-03-10 16:31:02 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "statusbar: %s\r\nscrollbar: %s\r\n",
|
|
|
|
boolopt[global_settings.statusbar],
|
|
|
|
boolopt[global_settings.scrollbar]);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] = {"graphic", "numeric"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "volume display: %s\r\nbattery display: %s\r\n",
|
|
|
|
options[global_settings.volume_type],
|
|
|
|
options[global_settings.battery_type]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "scroll speed: %d\r\nscroll delay: %d\r\n",
|
2003-03-10 16:31:02 +00:00
|
|
|
global_settings.scroll_speed,
|
|
|
|
global_settings.scroll_delay);
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "scroll step: %d\r\n", global_settings.scroll_step);
|
2003-03-10 16:31:02 +00:00
|
|
|
#endif
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "bidir limit: %d\r\n", global_settings.bidir_limit);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] =
|
|
|
|
{"off","on","1","2","3","4","5","6","7","8","9",
|
|
|
|
"10","15","20","25","30","45","60","90"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "backlight timeout: %s\r\n",
|
2003-03-10 16:31:02 +00:00
|
|
|
options[global_settings.backlight_timeout]);
|
|
|
|
}
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "backlight when plugged: %s\r\n",
|
|
|
|
boolopt[global_settings.backlight_on_when_charging]);
|
2003-04-24 12:44:18 +00:00
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "caption backlight: %s\r\n",
|
|
|
|
boolopt[global_settings.caption_backlight]);
|
|
|
|
fprintf(fd, "contrast: %d\r\n", global_settings.contrast);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "invert: %s\r\n", boolopt[global_settings.invert]);
|
|
|
|
|
|
|
|
fprintf(fd, "invert cursor: %s\r\n",
|
|
|
|
boolopt[global_settings.invert_cursor]);
|
2003-03-10 20:56:20 +00:00
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "peak meter release: %d\r\n",
|
|
|
|
global_settings.peak_meter_release);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] =
|
|
|
|
{"off","200ms","300ms","500ms","1","2","3","4","5",
|
|
|
|
"6","7","8","9","10","15","20","30","1min"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "peak meter hold: %s\r\n",
|
|
|
|
options[global_settings.peak_meter_hold]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] =
|
|
|
|
{"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"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "peak meter clip hold: %s\r\n",
|
|
|
|
options[global_settings.peak_meter_clip_hold]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "peak meter busy: %s\r\npeak meter dbfs: %s\r\n",
|
|
|
|
boolopt[global_settings.peak_meter_performance],
|
|
|
|
boolopt[global_settings.peak_meter_dbfs]);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "peak meter min: %d\r\npeak meter max: %d\r\n",
|
|
|
|
global_settings.peak_meter_min,
|
|
|
|
global_settings.peak_meter_max);
|
2003-03-10 16:31:02 +00:00
|
|
|
#endif
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "#\r\n# System\r\n#\r\ndisk spindown: %d\r\n",
|
2003-03-10 16:31:02 +00:00
|
|
|
global_settings.disk_spindown);
|
|
|
|
|
|
|
|
#ifdef HAVE_ATA_POWER_OFF
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "disk poweroff: %s\r\n",
|
|
|
|
boolopt[global_settings.disk_poweroff]);
|
2003-03-10 16:31:02 +00:00
|
|
|
#endif
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "battery capacity: %d\r\n", global_settings.battery_capacity);
|
2003-03-10 16:31:02 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CHARGE_CTRL
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "deep discharge: %s\r\ntrickle charge: %s\r\n",
|
|
|
|
boolopt[global_settings.discharge],
|
|
|
|
boolopt[global_settings.trickle_charge]);
|
2003-03-10 16:31:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
{
|
|
|
|
static char* options[] = {"24hour", "12hour"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "time format: %s\r\n",
|
|
|
|
options[global_settings.timeformat]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] =
|
|
|
|
{"off","1","2","3","4","5","6","7","8",
|
|
|
|
"9","10","15","30","45","60"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "idle poweroff: %s\r\n",
|
|
|
|
options[global_settings.poweroff]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_MAS3587F
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "#\r\n# Recording\r\n#\r\n");
|
|
|
|
fprintf(fd, "rec quality: %d\r\n", global_settings.rec_quality);
|
|
|
|
|
2003-03-10 16:31:02 +00:00
|
|
|
{
|
|
|
|
static char* options[] = {"44", "48", "32", "22", "24", "16"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "rec frequency: %s\r\n",
|
|
|
|
options[global_settings.rec_frequency]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] = {"mic", "line", "spdif"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "rec source: %s\r\n", options[global_settings.rec_source]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
static char* options[] = {"stereo", "mono"};
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "rec channels: %s\r\n",
|
|
|
|
options[global_settings.rec_channels]);
|
2003-03-10 16:31:02 +00:00
|
|
|
}
|
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd,
|
|
|
|
"rec mic gain: %d\r\nrec left gain: %d\r\nrec right gain: %d\r\n",
|
|
|
|
global_settings.rec_mic_gain,
|
|
|
|
global_settings.rec_left_gain,
|
|
|
|
global_settings.rec_right_gain);
|
2003-04-20 22:00:30 +00:00
|
|
|
|
2003-04-24 17:53:17 +00:00
|
|
|
fprintf(fd, "editable recordings: %s\r\n",
|
|
|
|
boolopt[global_settings.rec_editable]);
|
2003-04-20 22:00:30 +00:00
|
|
|
|
2003-03-10 16:31:02 +00:00
|
|
|
#endif
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
lcd_clear_display();
|
|
|
|
lcd_puts(0,0,str(LANG_SETTINGS_SAVED1));
|
|
|
|
lcd_puts(0,1,str(LANG_SETTINGS_SAVED2));
|
|
|
|
lcd_update();
|
|
|
|
sleep(HZ);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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" );
|
|
|
|
|
|
|
|
global_settings.volume = mpeg_sound_default(SOUND_VOLUME);
|
2002-08-14 21:30:06 +00:00
|
|
|
global_settings.balance = mpeg_sound_default(SOUND_BALANCE);
|
2002-07-15 11:02:12 +00:00
|
|
|
global_settings.bass = mpeg_sound_default(SOUND_BASS);
|
|
|
|
global_settings.treble = mpeg_sound_default(SOUND_TREBLE);
|
2002-08-14 21:30:06 +00:00
|
|
|
global_settings.loudness = mpeg_sound_default(SOUND_LOUDNESS);
|
|
|
|
global_settings.bass_boost = mpeg_sound_default(SOUND_SUPERBASS);
|
|
|
|
global_settings.avc = mpeg_sound_default(SOUND_AVC);
|
2002-09-09 15:25:54 +00:00
|
|
|
global_settings.channel_config = mpeg_sound_default(SOUND_CHANNELS);
|
2002-11-10 23:18:33 +00:00
|
|
|
global_settings.rec_quality = 5;
|
|
|
|
global_settings.rec_source = 0; /* 0=mic */
|
|
|
|
global_settings.rec_frequency = 0; /* 0=44.1kHz */
|
|
|
|
global_settings.rec_channels = 0; /* 0=Stereo */
|
|
|
|
global_settings.rec_mic_gain = 8;
|
|
|
|
global_settings.rec_left_gain = 2; /* 0dB */
|
|
|
|
global_settings.rec_right_gain = 2; /* 0dB */
|
2003-04-20 22:00:30 +00:00
|
|
|
global_settings.rec_editable = false;
|
2002-08-19 10:57:55 +00:00
|
|
|
global_settings.resume = RESUME_ASK;
|
2002-07-15 11:02:12 +00:00
|
|
|
global_settings.contrast = DEFAULT_CONTRAST_SETTING;
|
2003-02-27 14:22:30 +00:00
|
|
|
global_settings.invert = DEFAULT_INVERT_SETTING;
|
2002-07-15 11:02:12 +00:00
|
|
|
global_settings.poweroff = DEFAULT_POWEROFF_SETTING;
|
2002-10-01 10:59:36 +00:00
|
|
|
global_settings.backlight_timeout = DEFAULT_BACKLIGHT_TIMEOUT_SETTING;
|
2003-04-16 00:12:31 +00:00
|
|
|
global_settings.invert_cursor = DEFAULT_INVERT_CURSOR_SETTING;
|
2002-10-14 09:11:59 +00:00
|
|
|
global_settings.backlight_on_when_charging =
|
|
|
|
DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING;
|
2002-12-16 22:58:48 +00:00
|
|
|
global_settings.battery_capacity = 1500; /* mAh */
|
2002-12-15 00:33:13 +00:00
|
|
|
global_settings.trickle_charge = true;
|
2002-09-24 19:12:09 +00:00
|
|
|
global_settings.dirfilter = SHOW_MUSIC;
|
2002-07-22 16:39:17 +00:00
|
|
|
global_settings.sort_case = false;
|
2002-08-07 10:35:26 +00:00
|
|
|
global_settings.statusbar = true;
|
2002-08-30 13:49:32 +00:00
|
|
|
global_settings.scrollbar = true;
|
2002-10-04 08:48:20 +00:00
|
|
|
global_settings.repeat_mode = REPEAT_ALL;
|
2002-07-15 11:02:12 +00:00
|
|
|
global_settings.playlist_shuffle = false;
|
2002-08-06 10:52:51 +00:00
|
|
|
global_settings.discharge = 0;
|
2002-10-14 12:50:20 +00:00
|
|
|
global_settings.timeformat = 0;
|
2002-10-26 05:26:23 +00:00
|
|
|
global_settings.volume_type = 0;
|
|
|
|
global_settings.battery_type = 0;
|
2002-07-15 11:02:12 +00:00
|
|
|
global_settings.scroll_speed = 8;
|
2002-12-12 15:20:37 +00:00
|
|
|
global_settings.bidir_limit = 50;
|
2003-01-13 10:30:19 +00:00
|
|
|
global_settings.scroll_delay = 100;
|
2002-12-12 15:20:37 +00:00
|
|
|
global_settings.scroll_step = 6;
|
2002-09-04 03:38:37 +00:00
|
|
|
global_settings.ff_rewind_min_step = DEFAULT_FF_REWIND_MIN_STEP;
|
2002-08-28 19:34:07 +00:00
|
|
|
global_settings.ff_rewind_accel = DEFAULT_FF_REWIND_ACCEL_SETTING;
|
2002-08-16 14:41:47 +00:00
|
|
|
global_settings.resume_index = -1;
|
|
|
|
global_settings.resume_offset = -1;
|
2003-01-09 00:55:00 +00:00
|
|
|
global_settings.save_queue_resume = true;
|
|
|
|
global_settings.queue_resume = 0;
|
|
|
|
global_settings.queue_resume_index = -1;
|
2002-08-26 13:21:14 +00:00
|
|
|
global_settings.disk_spindown = 5;
|
2002-11-28 22:46:19 +00:00
|
|
|
global_settings.disk_poweroff = false;
|
2002-12-05 13:09:51 +00:00
|
|
|
global_settings.buffer_margin = 0;
|
2002-09-09 14:25:39 +00:00
|
|
|
global_settings.browse_current = false;
|
2002-09-18 10:12:16 +00:00
|
|
|
global_settings.play_selected = true;
|
2002-09-27 09:31:31 +00:00
|
|
|
global_settings.peak_meter_release = 8;
|
2002-10-29 12:09:15 +00:00
|
|
|
global_settings.peak_meter_hold = 3;
|
2002-09-27 09:31:31 +00:00
|
|
|
global_settings.peak_meter_clip_hold = 16;
|
2002-10-29 12:09:15 +00:00
|
|
|
global_settings.peak_meter_dbfs = true;
|
|
|
|
global_settings.peak_meter_min = 60;
|
|
|
|
global_settings.peak_meter_max = 0;
|
|
|
|
global_settings.peak_meter_performance = false;
|
2002-10-09 23:13:25 +00:00
|
|
|
global_settings.wps_file[0] = 0;
|
|
|
|
global_settings.font_file[0] = 0;
|
|
|
|
global_settings.lang_file[0] = 0;
|
2002-12-02 16:07:56 +00:00
|
|
|
global_settings.runtime = 0;
|
|
|
|
global_settings.topruntime = 0;
|
2003-02-14 15:54:52 +00:00
|
|
|
global_settings.fade_on_stop = true;
|
2002-06-27 00:20:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dump the list of current settings
|
|
|
|
*/
|
2002-07-15 11:02:12 +00:00
|
|
|
void settings_display(void)
|
2002-06-27 00:20:00 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2002-07-15 11:02:12 +00:00
|
|
|
DEBUGF( "\nsettings_display()\n" );
|
2002-06-27 00:20:00 +00:00
|
|
|
|
2002-10-14 09:11:59 +00:00
|
|
|
DEBUGF( "\nvolume:\t\t%d\nbalance:\t%d\nbass:\t\t%d\ntreble:\t\t%d\n"
|
|
|
|
"loudness:\t%d\nbass boost:\t%d\n",
|
2002-07-15 11:02:12 +00:00
|
|
|
global_settings.volume,
|
|
|
|
global_settings.balance,
|
|
|
|
global_settings.bass,
|
|
|
|
global_settings.treble,
|
|
|
|
global_settings.loudness,
|
|
|
|
global_settings.bass_boost );
|
2002-06-27 00:20:00 +00:00
|
|
|
|
2003-02-27 14:22:30 +00:00
|
|
|
DEBUGF( "contrast:\t%d\ninvert:\t%d\npoweroff:\t%d\nbacklight_timeout:\t%d\n",
|
2002-07-15 11:02:12 +00:00
|
|
|
global_settings.contrast,
|
2003-02-27 14:22:30 +00:00
|
|
|
global_settings.invert,
|
2002-07-15 11:02:12 +00:00
|
|
|
global_settings.poweroff,
|
2002-10-01 10:59:36 +00:00
|
|
|
global_settings.backlight_timeout );
|
2002-06-27 00:20:00 +00:00
|
|
|
#endif
|
|
|
|
}
|
2002-06-27 01:08:11 +00:00
|
|
|
|
2002-09-24 17:22:12 +00:00
|
|
|
bool set_bool(char* string, bool* variable )
|
2002-06-27 01:08:11 +00:00
|
|
|
{
|
2002-10-14 09:11:59 +00:00
|
|
|
return set_bool_options(string, variable, str(LANG_SET_BOOL_YES),
|
|
|
|
str(LANG_SET_BOOL_NO));
|
2002-09-05 04:42:12 +00:00
|
|
|
}
|
2002-08-20 19:37:00 +00:00
|
|
|
|
2002-09-24 17:22:12 +00:00
|
|
|
bool set_bool_options(char* string, bool* variable,
|
|
|
|
char* yes_str, char* no_str )
|
2002-09-05 04:42:12 +00:00
|
|
|
{
|
2002-10-29 12:16:36 +00:00
|
|
|
char* names[] = { no_str, yes_str };
|
|
|
|
int value = *variable;
|
2002-09-24 17:22:12 +00:00
|
|
|
bool result;
|
|
|
|
|
|
|
|
result = set_option(string, &value, names, 2, NULL);
|
2002-10-29 12:16:36 +00:00
|
|
|
*variable = value;
|
2002-09-24 17:22:12 +00:00
|
|
|
return result;
|
2002-06-27 01:08:11 +00:00
|
|
|
}
|
|
|
|
|
2002-09-24 17:22:12 +00:00
|
|
|
bool set_int(char* string,
|
2002-06-27 01:08:11 +00:00
|
|
|
char* unit,
|
|
|
|
int* variable,
|
|
|
|
void (*function)(int),
|
|
|
|
int step,
|
|
|
|
int min,
|
|
|
|
int max )
|
|
|
|
{
|
|
|
|
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;
|
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];
|
|
|
|
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();
|
|
|
|
|
2002-09-19 09:00:25 +00:00
|
|
|
button = button_get_w_tmo(HZ/2);
|
|
|
|
switch(button) {
|
2002-06-27 01:08:11 +00:00
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_UP:
|
2002-07-30 07:50:53 +00:00
|
|
|
case BUTTON_UP | BUTTON_REPEAT:
|
2002-06-27 01:08:11 +00:00
|
|
|
#else
|
|
|
|
case BUTTON_RIGHT:
|
2002-07-30 07:50:53 +00:00
|
|
|
case BUTTON_RIGHT | BUTTON_REPEAT:
|
2002-06-27 01:08:11 +00:00
|
|
|
#endif
|
|
|
|
*variable += step;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_DOWN:
|
2002-07-30 07:50:53 +00:00
|
|
|
case BUTTON_DOWN | BUTTON_REPEAT:
|
2002-06-27 01:08:11 +00:00
|
|
|
#else
|
|
|
|
case BUTTON_LEFT:
|
2002-07-30 07:50:53 +00:00
|
|
|
case BUTTON_LEFT | BUTTON_REPEAT:
|
2002-06-27 01:08:11 +00:00
|
|
|
#endif
|
|
|
|
*variable -= step;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_LEFT:
|
2003-01-14 13:49:28 +00:00
|
|
|
case BUTTON_PLAY:
|
|
|
|
#else
|
|
|
|
case BUTTON_PLAY:
|
|
|
|
#endif
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_OFF:
|
2002-06-27 01:08:11 +00:00
|
|
|
#else
|
|
|
|
case BUTTON_STOP:
|
|
|
|
case BUTTON_MENU:
|
|
|
|
#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
|
|
|
|
|
|
|
case SYS_USB_CONNECTED:
|
|
|
|
usb_screen();
|
|
|
|
return true;
|
2002-12-16 23:33:34 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2002-09-24 17:22:12 +00:00
|
|
|
bool set_option(char* string, int* variable, char* options[],
|
2002-09-10 05:31:12 +00:00
|
|
|
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-01-14 13:49:28 +00:00
|
|
|
int org_value=*variable;
|
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 ) {
|
|
|
|
lcd_puts(0, 1, options[*variable]);
|
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) {
|
2002-06-27 01:08:11 +00:00
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_UP:
|
2002-07-30 07:50:53 +00:00
|
|
|
case BUTTON_UP | BUTTON_REPEAT:
|
2002-06-27 01:08:11 +00:00
|
|
|
#else
|
|
|
|
case BUTTON_RIGHT:
|
2002-07-30 07:50:53 +00:00
|
|
|
case BUTTON_RIGHT | BUTTON_REPEAT:
|
2002-06-27 01:08:11 +00:00
|
|
|
#endif
|
|
|
|
if ( *variable < (numoptions-1) )
|
|
|
|
(*variable)++;
|
2003-04-16 00:12:31 +00:00
|
|
|
else
|
2002-09-14 06:03:51 +00:00
|
|
|
(*variable) -= (numoptions-1);
|
2002-06-27 01:08:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_DOWN:
|
2002-07-30 07:50:53 +00:00
|
|
|
case BUTTON_DOWN | BUTTON_REPEAT:
|
2002-06-27 01:08:11 +00:00
|
|
|
#else
|
|
|
|
case BUTTON_LEFT:
|
2002-07-30 07:50:53 +00:00
|
|
|
case BUTTON_LEFT | BUTTON_REPEAT:
|
2002-06-27 01:08:11 +00:00
|
|
|
#endif
|
|
|
|
if ( *variable > 0 )
|
|
|
|
(*variable)--;
|
2002-09-14 06:03:51 +00:00
|
|
|
else
|
|
|
|
(*variable) += (numoptions-1);
|
2002-06-27 01:08:11 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_LEFT:
|
2003-01-14 13:49:28 +00:00
|
|
|
case BUTTON_PLAY:
|
|
|
|
#else
|
|
|
|
case BUTTON_PLAY:
|
|
|
|
#endif
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_OFF:
|
2002-06-27 01:08:11 +00:00
|
|
|
#else
|
|
|
|
case BUTTON_STOP:
|
|
|
|
case BUTTON_MENU:
|
|
|
|
#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
|
|
|
|
|
|
|
case SYS_USB_CONNECTED:
|
|
|
|
usb_screen();
|
|
|
|
return true;
|
2002-06-27 01:08:11 +00:00
|
|
|
}
|
2002-09-10 05:31:12 +00:00
|
|
|
|
2002-09-19 09:00:25 +00:00
|
|
|
if ( function && button != BUTTON_NONE)
|
2002-09-10 05:31:12 +00:00
|
|
|
function(*variable);
|
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
|
|
|
|
2002-09-21 14:21:31 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-08-09 12:38:45 +00:00
|
|
|
#define INDEX_X 0
|
|
|
|
#define INDEX_Y 1
|
2002-08-09 13:50:58 +00:00
|
|
|
#define INDEX_WIDTH 2
|
2002-09-24 17:22:12 +00:00
|
|
|
bool set_time(char* string, int timedate[])
|
2002-08-09 12:38:45 +00:00
|
|
|
{
|
|
|
|
bool done = false;
|
|
|
|
int button;
|
2002-08-15 06:36:25 +00:00
|
|
|
int min = 0, steps = 0;
|
|
|
|
int cursorpos = 0;
|
|
|
|
int lastcursorpos = !cursorpos;
|
2002-08-09 12:38:45 +00:00
|
|
|
unsigned char buffer[19];
|
|
|
|
int realyear;
|
|
|
|
int julianday;
|
|
|
|
int i;
|
2002-08-15 06:36:25 +00:00
|
|
|
unsigned char reffub[5];
|
|
|
|
unsigned int width, height;
|
|
|
|
unsigned int separator_width, weekday_width;
|
|
|
|
unsigned int line_height, prev_line_height;
|
2003-04-27 01:11:32 +00:00
|
|
|
int dayname[] = {LANG_WEEKDAY_SUNDAY,
|
|
|
|
LANG_WEEKDAY_MONDAY,
|
|
|
|
LANG_WEEKDAY_TUESDAY,
|
|
|
|
LANG_WEEKDAY_WEDNESDAY,
|
|
|
|
LANG_WEEKDAY_THURSDAY,
|
|
|
|
LANG_WEEKDAY_FRIDAY,
|
|
|
|
LANG_WEEKDAY_SATURDAY};
|
|
|
|
int monthname[] = {LANG_MONTH_JANUARY,
|
|
|
|
LANG_MONTH_FEBRUARY,
|
|
|
|
LANG_MONTH_MARCH,
|
|
|
|
LANG_MONTH_APRIL,
|
|
|
|
LANG_MONTH_MAY,
|
|
|
|
LANG_MONTH_JUNE,
|
|
|
|
LANG_MONTH_JULY,
|
|
|
|
LANG_MONTH_AUGUST,
|
|
|
|
LANG_MONTH_SEPTEMBER,
|
|
|
|
LANG_MONTH_OCTOBER,
|
|
|
|
LANG_MONTH_NOVEMBER,
|
|
|
|
LANG_MONTH_DECEMBER};
|
2002-10-14 14:59:24 +00:00
|
|
|
char cursor[][3] = {{ 0, 8, 12}, {18, 8, 12}, {36, 8, 12},
|
|
|
|
{24, 16, 24}, {54, 16, 18}, {78, 16, 12}};
|
|
|
|
char daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
2002-11-30 09:42:13 +00:00
|
|
|
|
|
|
|
int monthname_len = 0, dayname_len = 0;
|
2002-10-14 14:59:24 +00:00
|
|
|
|
2002-08-09 12:38:45 +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-08-09 12:38:45 +00:00
|
|
|
lcd_clear_display();
|
2002-08-15 06:36:25 +00:00
|
|
|
lcd_puts_scroll(0, 0, string);
|
2002-08-09 12:38:45 +00:00
|
|
|
|
|
|
|
while ( !done ) {
|
|
|
|
/* calculate the number of days in febuary */
|
2002-08-15 06:36:25 +00:00
|
|
|
realyear = timedate[3] + 2000;
|
|
|
|
if((realyear % 4 == 0 && !(realyear % 100 == 0)) || realyear % 400 == 0)
|
|
|
|
daysinmonth[1] = 29;
|
2002-08-09 12:38:45 +00:00
|
|
|
else
|
2002-08-15 06:36:25 +00:00
|
|
|
daysinmonth[1] = 28;
|
2002-08-09 12:38:45 +00:00
|
|
|
|
|
|
|
/* fix day if month or year changed */
|
2002-08-15 06:36:25 +00:00
|
|
|
if (timedate[5] > daysinmonth[timedate[4] - 1])
|
|
|
|
timedate[5] = daysinmonth[timedate[4] - 1];
|
2002-08-09 12:38:45 +00:00
|
|
|
|
|
|
|
/* calculate day of week */
|
2002-08-15 06:36:25 +00:00
|
|
|
julianday = 0;
|
|
|
|
for(i = 0; i < timedate[4] - 1; i++) {
|
|
|
|
julianday += daysinmonth[i];
|
2002-08-09 12:38:45 +00:00
|
|
|
}
|
2002-08-15 06:36:25 +00:00
|
|
|
julianday += timedate[5];
|
|
|
|
timedate[6] = (realyear + julianday + (realyear - 1) / 4 -
|
|
|
|
(realyear - 1) / 100 + (realyear - 1) / 400 + 7 - 1) % 7;
|
2002-08-09 12:38:45 +00:00
|
|
|
|
2002-08-15 06:36:25 +00:00
|
|
|
snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d ",
|
2002-11-30 09:42:13 +00:00
|
|
|
timedate[0], timedate[1], timedate[2]);
|
2002-08-15 06:36:25 +00:00
|
|
|
lcd_puts(0, 1, buffer);
|
2002-09-12 13:33:59 +00:00
|
|
|
|
2002-08-15 06:36:25 +00:00
|
|
|
/* recalculate the positions and offsets */
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize(string, &width, &prev_line_height);
|
|
|
|
lcd_getstringsize(buffer, &width, &line_height);
|
|
|
|
lcd_getstringsize(":", &separator_width, &height);
|
2002-08-15 06:36:25 +00:00
|
|
|
|
2002-10-14 14:59:24 +00:00
|
|
|
/* hour */
|
2002-08-15 06:36:25 +00:00
|
|
|
strncpy(reffub, buffer, 2);
|
|
|
|
reffub[2] = '\0';
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize(reffub, &width, &height);
|
2002-08-15 06:36:25 +00:00
|
|
|
cursor[0][INDEX_X] = 0;
|
2002-09-21 14:21:31 +00:00
|
|
|
cursor[0][INDEX_Y] = prev_line_height;
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[0][INDEX_WIDTH] = width;
|
2002-08-15 06:36:25 +00:00
|
|
|
|
2002-10-14 14:59:24 +00:00
|
|
|
/* minute */
|
2002-08-15 06:36:25 +00:00
|
|
|
strncpy(reffub, buffer + 3, 2);
|
|
|
|
reffub[2] = '\0';
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize(reffub, &width, &height);
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[1][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width;
|
2002-09-21 14:21:31 +00:00
|
|
|
cursor[1][INDEX_Y] = prev_line_height;
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[1][INDEX_WIDTH] = width;
|
2002-08-15 06:36:25 +00:00
|
|
|
|
2002-10-14 14:59:24 +00:00
|
|
|
/* second */
|
2002-08-15 06:36:25 +00:00
|
|
|
strncpy(reffub, buffer + 6, 2);
|
|
|
|
reffub[2] = '\0';
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize(reffub, &width, &height);
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[2][INDEX_X] = cursor[0][INDEX_WIDTH] + separator_width +
|
|
|
|
cursor[1][INDEX_WIDTH] + separator_width;
|
2002-09-21 14:21:31 +00:00
|
|
|
cursor[2][INDEX_Y] = prev_line_height;
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[2][INDEX_WIDTH] = width;
|
2002-08-15 06:36:25 +00:00
|
|
|
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize(buffer, &width, &prev_line_height);
|
2002-08-09 12:38:45 +00:00
|
|
|
|
2002-08-15 06:36:25 +00:00
|
|
|
snprintf(buffer, sizeof(buffer), "%s 20%02d %s %02d ",
|
2003-04-27 01:11:32 +00:00
|
|
|
str(dayname[timedate[6]]), timedate[3],
|
|
|
|
str(monthname[timedate[4] - 1]), timedate[5]);
|
2002-08-15 06:36:25 +00:00
|
|
|
lcd_puts(0, 2, buffer);
|
2002-09-12 13:33:59 +00:00
|
|
|
|
2002-08-15 06:36:25 +00:00
|
|
|
/* recalculate the positions and offsets */
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize(buffer, &width, &line_height);
|
2002-10-14 14:59:24 +00:00
|
|
|
|
2002-11-30 09:42:13 +00:00
|
|
|
/* store these 2 to prevent _repeated_ strlen calls */
|
2003-04-27 01:11:32 +00:00
|
|
|
monthname_len = strlen(str(monthname[timedate[4] - 1]));
|
|
|
|
dayname_len = strlen(str(dayname[timedate[6]]));
|
2002-11-30 09:42:13 +00:00
|
|
|
|
2002-10-14 14:59:24 +00:00
|
|
|
/* weekday */
|
2002-11-30 09:42:13 +00:00
|
|
|
strncpy(reffub, buffer, dayname_len);
|
|
|
|
reffub[dayname_len] = '\0';
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize(reffub, &weekday_width, &height);
|
|
|
|
lcd_getstringsize(" ", &separator_width, &height);
|
2002-08-15 06:36:25 +00:00
|
|
|
|
2002-10-14 14:59:24 +00:00
|
|
|
/* year */
|
2002-11-30 09:42:13 +00:00
|
|
|
strncpy(reffub, buffer + dayname_len + 1, 4);
|
2002-08-15 06:36:25 +00:00
|
|
|
reffub[4] = '\0';
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize(reffub, &width, &height);
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[3][INDEX_X] = weekday_width + separator_width;
|
2002-09-21 14:21:31 +00:00
|
|
|
cursor[3][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[3][INDEX_WIDTH] = width;
|
2002-08-15 06:36:25 +00:00
|
|
|
|
2002-10-14 14:59:24 +00:00
|
|
|
/* month */
|
2002-11-30 09:42:13 +00:00
|
|
|
strncpy(reffub, buffer + dayname_len + 6, monthname_len);
|
|
|
|
reffub[monthname_len] = '\0';
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize(reffub, &width, &height);
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[4][INDEX_X] = weekday_width + separator_width +
|
|
|
|
cursor[3][INDEX_WIDTH] + separator_width;
|
2002-09-21 14:21:31 +00:00
|
|
|
cursor[4][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[4][INDEX_WIDTH] = width;
|
2002-08-15 06:36:25 +00:00
|
|
|
|
2002-10-14 14:59:24 +00:00
|
|
|
/* day */
|
2002-11-30 09:42:13 +00:00
|
|
|
strncpy(reffub, buffer + dayname_len + monthname_len + 7, 2);
|
2002-08-15 06:36:25 +00:00
|
|
|
reffub[2] = '\0';
|
2002-09-24 18:04:15 +00:00
|
|
|
lcd_getstringsize(reffub, &width, &height);
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[5][INDEX_X] = weekday_width + separator_width +
|
|
|
|
cursor[3][INDEX_WIDTH] + separator_width +
|
|
|
|
cursor[4][INDEX_WIDTH] + separator_width;
|
2002-09-21 14:21:31 +00:00
|
|
|
cursor[5][INDEX_Y] = cursor[0][INDEX_Y] + prev_line_height;
|
2002-08-21 06:23:23 +00:00
|
|
|
cursor[5][INDEX_WIDTH] = width;
|
2002-08-15 06:36:25 +00:00
|
|
|
|
|
|
|
lcd_invertrect(cursor[cursorpos][INDEX_X],
|
2002-08-20 19:37:00 +00:00
|
|
|
cursor[cursorpos][INDEX_Y] + lcd_getymargin(),
|
2002-08-15 06:36:25 +00:00
|
|
|
cursor[cursorpos][INDEX_WIDTH],
|
|
|
|
line_height);
|
|
|
|
|
2002-09-18 14:08:05 +00:00
|
|
|
lcd_puts(0, 4, str(LANG_TIME_SET));
|
|
|
|
lcd_puts(0, 5, str(LANG_TIME_REVERT));
|
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-08-09 12:38:45 +00:00
|
|
|
lcd_update();
|
|
|
|
|
|
|
|
/* calculate the minimum and maximum for the number under cursor */
|
|
|
|
if(cursorpos!=lastcursorpos) {
|
|
|
|
lastcursorpos=cursorpos;
|
|
|
|
switch(cursorpos) {
|
|
|
|
case 0: /* hour */
|
2002-08-15 06:36:25 +00:00
|
|
|
min = 0;
|
|
|
|
steps = 24;
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
|
|
|
case 1: /* minute */
|
|
|
|
case 2: /* second */
|
2002-08-15 06:36:25 +00:00
|
|
|
min = 0;
|
|
|
|
steps = 60;
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
2002-08-09 13:50:58 +00:00
|
|
|
case 3: /* year */
|
2002-08-15 06:36:25 +00:00
|
|
|
min = 0;
|
|
|
|
steps = 100;
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
|
|
|
case 4: /* month */
|
2002-08-15 06:36:25 +00:00
|
|
|
min = 1;
|
|
|
|
steps = 12;
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
2002-08-09 13:50:58 +00:00
|
|
|
case 5: /* day */
|
2002-08-15 06:36:25 +00:00
|
|
|
min = 1;
|
|
|
|
steps = daysinmonth[timedate[4] - 1];
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-20 19:37:00 +00:00
|
|
|
button = button_get_w_tmo(HZ/2);
|
2002-08-09 12:38:45 +00:00
|
|
|
switch ( button ) {
|
|
|
|
case BUTTON_LEFT:
|
2002-08-15 06:36:25 +00:00
|
|
|
cursorpos = (cursorpos + 6 - 1) % 6;
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
|
|
|
case BUTTON_RIGHT:
|
2002-08-15 06:36:25 +00:00
|
|
|
cursorpos = (cursorpos + 6 + 1) % 6;
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
|
|
|
case BUTTON_UP:
|
2002-08-28 06:12:53 +00:00
|
|
|
case BUTTON_UP | BUTTON_REPEAT:
|
2002-10-14 09:11:59 +00:00
|
|
|
timedate[cursorpos] = (timedate[cursorpos] + steps - min + 1) %
|
|
|
|
steps + min;
|
2002-08-15 06:36:25 +00:00
|
|
|
if(timedate[cursorpos] == 0)
|
|
|
|
timedate[cursorpos] += min;
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
|
|
|
case BUTTON_DOWN:
|
2002-08-28 06:12:53 +00:00
|
|
|
case BUTTON_DOWN | BUTTON_REPEAT:
|
2002-10-14 09:11:59 +00:00
|
|
|
timedate[cursorpos]=(timedate[cursorpos]+steps - min - 1) %
|
|
|
|
steps + min;
|
2002-08-15 06:36:25 +00:00
|
|
|
if(timedate[cursorpos] == 0)
|
|
|
|
timedate[cursorpos] += min;
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
|
|
|
case BUTTON_ON:
|
2002-08-15 06:36:25 +00:00
|
|
|
done = true;
|
|
|
|
if (timedate[6] == 0) /* rtc needs 1 .. 7 */
|
|
|
|
timedate[6] = 7;
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
|
|
|
case BUTTON_OFF:
|
2002-08-15 06:36:25 +00:00
|
|
|
done = true;
|
|
|
|
timedate[0] = -1;
|
2002-08-09 12:38:45 +00:00
|
|
|
break;
|
2002-08-20 19:37:00 +00:00
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_F3:
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
global_settings.statusbar = !global_settings.statusbar;
|
|
|
|
settings_save();
|
|
|
|
if(global_settings.statusbar)
|
|
|
|
lcd_setmargins(0, STATUSBAR_HEIGHT);
|
|
|
|
else
|
|
|
|
lcd_setmargins(0, 0);
|
|
|
|
lcd_clear_display();
|
|
|
|
lcd_puts_scroll(0, 0, string);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
#endif
|
2002-09-24 17:22:12 +00:00
|
|
|
|
|
|
|
case SYS_USB_CONNECTED:
|
|
|
|
usb_screen();
|
|
|
|
return true;
|
2002-08-09 12:38:45 +00:00
|
|
|
}
|
|
|
|
}
|
2002-09-24 17:22:12 +00:00
|
|
|
|
|
|
|
return false;
|
2002-08-09 12:38:45 +00:00
|
|
|
}
|
|
|
|
#endif
|