summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-06-27 00:20:00 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-06-27 00:20:00 +0000
commitf80d8a704d7955ec2c1cca41ebc5975130e69f64 (patch)
tree8165095647f0dc71a3f856a79c94f8952b0a727e
parent2d98ae3d03b128b6449f388134aefbd56daede3d (diff)
downloadrockbox-f80d8a704d7955ec2c1cca41ebc5975130e69f64.tar.gz
rockbox-f80d8a704d7955ec2c1cca41ebc5975130e69f64.zip
Moved settings.c/h to apps/
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1215 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/main.c4
-rw-r--r--apps/settings.c103
-rw-r--r--apps/settings.h86
-rw-r--r--firmware/backlight.c10
-rw-r--r--firmware/backlight.h1
-rw-r--r--firmware/mpeg.c10
-rw-r--r--firmware/mpeg.h2
7 files changed, 206 insertions, 10 deletions
diff --git a/apps/main.c b/apps/main.c
index 5821ee8fbf..6cf99d7ce4 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -103,7 +103,9 @@ void init(void)
103 backlight_init(); 103 backlight_init();
104 104
105 button_init(); 105 button_init();
106 mpeg_init(); 106 mpeg_init( DEFAULT_VOLUME_SETTING,
107 DEFAULT_BASS_SETTING,
108 DEFAULT_TREBLE_SETTING );
107} 109}
108 110
109int main(void) 111int main(void)
diff --git a/apps/settings.c b/apps/settings.c
new file mode 100644
index 0000000000..f6566f41a1
--- /dev/null
+++ b/apps/settings.c
@@ -0,0 +1,103 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by wavey@wavey.org
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <stdio.h>
21#include "config.h"
22#include "settings.h"
23#include "disk.h"
24#include "panic.h"
25#include "debug.h"
26
27struct user_settings global_settings;
28
29/*
30 * persist all runtime user settings to disk
31 */
32int persist_all_settings( void )
33{
34 return 1;
35}
36
37/*
38 * persist all the playlist information to disk
39 */
40int persist_all_playlist_info( void )
41{
42 return 1;
43}
44
45/*
46 * load settings from disk
47 */
48void reload_all_settings( struct user_settings *settings )
49{
50 DEBUGF( "reload_all_settings()\n" );
51
52 /* this is a TEMP stub version */
53
54 /* populate settings with default values */
55
56 reset_settings( settings );
57}
58
59/*
60 * reset all settings to their default value
61 */
62void reset_settings( struct user_settings *settings ) {
63
64 DEBUGF( "reset_settings()\n" );
65
66 settings->volume = DEFAULT_VOLUME_SETTING;
67 settings->balance = DEFAULT_BALANCE_SETTING;
68 settings->bass = DEFAULT_BASS_SETTING;
69 settings->treble = DEFAULT_TREBLE_SETTING;
70 settings->loudness = DEFAULT_LOUDNESS_SETTING;
71 settings->bass_boost = DEFAULT_BASS_BOOST_SETTING;
72 settings->contrast = DEFAULT_CONTRAST_SETTING;
73 settings->poweroff = DEFAULT_POWEROFF_SETTING;
74 settings->backlight = DEFAULT_BACKLIGHT_SETTING;
75 settings->wps_display = DEFAULT_WPS_DISPLAY;
76}
77
78
79/*
80 * dump the list of current settings
81 */
82void display_current_settings( struct user_settings *settings )
83{
84#ifdef DEBUG
85 DEBUGF( "\ndisplay_current_settings()\n" );
86
87 DEBUGF( "\nvolume:\t\t%d\nbalance:\t%d\nbass:\t\t%d\ntreble:\t\t%d\nloudness:\t%d\nbass boost:\t%d\n",
88 settings->volume,
89 settings->balance,
90 settings->bass,
91 settings->treble,
92 settings->loudness,
93 settings->bass_boost );
94
95 DEBUGF( "contrast:\t%d\npoweroff:\t%d\nbacklight:\t%d\n",
96 settings->contrast,
97 settings->poweroff,
98 settings->backlight );
99#else
100 /* Get rid of warning */
101 settings = settings;
102#endif
103}
diff --git a/apps/settings.h b/apps/settings.h
new file mode 100644
index 0000000000..b4a8fde56e
--- /dev/null
+++ b/apps/settings.h
@@ -0,0 +1,86 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by wavey@wavey.org
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef __SETTINGS_H__
21#define __SETTINGS_H__
22
23#include <stdbool.h>
24
25/* data structures */
26
27#define RESUME_NONE 0
28#define RESUME_SONG 1 /* resume song at startup */
29#define RESUME_PLAYLIST 2 /* resume playlist at startup */
30
31struct user_settings
32{
33 /* audio settings */
34
35 int volume; /* audio output volume: 0-100 0=off 100=max */
36 int balance; /* stereo balance: 0-100 0=left 50=bal 100=right */
37 int bass; /* bass eq: 0-100 0=off 100=max */
38 int treble; /* treble eq: 0-100 0=low 100=high */
39 int loudness; /* loudness eq: 0-100 0=off 100=max */
40 int bass_boost; /* bass boost eq: 0-100 0=off 100=max */
41
42 /* device settings */
43
44 int contrast; /* lcd contrast: 0-100 0=low 100=high */
45 int poweroff; /* power off timer: 0-100 0=never:each 1% = 60 secs */
46 int backlight; /* backlight off timer: 0-100 0=never:each 1% = 10 secs */
47
48 /* resume settings */
49
50 int resume; /* power-on song resume: 0=no. 1=yes song. 2=yes pl */
51 int track_time; /* number of seconds into the track to resume */
52
53 /* misc options */
54
55 int loop_playlist; /* do we return to top of playlist at end? */
56 bool mp3filter;
57
58 /* while playing screen settings */
59 int wps_display;
60
61};
62
63/* prototypes */
64
65int persist_all_settings( void );
66void reload_all_settings( struct user_settings *settings );
67void reset_settings( struct user_settings *settings );
68void display_current_settings( struct user_settings *settings );
69
70/* global settings */
71extern struct user_settings global_settings;
72
73/* system defines */
74
75#define DEFAULT_VOLUME_SETTING 70
76#define DEFAULT_BALANCE_SETTING 50
77#define DEFAULT_BASS_SETTING 50
78#define DEFAULT_TREBLE_SETTING 50
79#define DEFAULT_LOUDNESS_SETTING 0
80#define DEFAULT_BASS_BOOST_SETTING 0
81#define DEFAULT_CONTRAST_SETTING 0
82#define DEFAULT_POWEROFF_SETTING 0
83#define DEFAULT_BACKLIGHT_SETTING 5
84#define DEFAULT_WPS_DISPLAY 0
85
86#endif /* __SETTINGS_H__ */
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 729b22b7c2..e47a58adbf 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -24,7 +24,6 @@
24#include "i2c.h" 24#include "i2c.h"
25#include "debug.h" 25#include "debug.h"
26#include "rtc.h" 26#include "rtc.h"
27#include "settings.h"
28 27
29#define BACKLIGHT_ON 1 28#define BACKLIGHT_ON 1
30#define BACKLIGHT_OFF 2 29#define BACKLIGHT_OFF 2
@@ -34,6 +33,7 @@ static char backlight_stack[0x100];
34static struct event_queue backlight_queue; 33static struct event_queue backlight_queue;
35 34
36static int backlight_timer; 35static int backlight_timer;
36static int backlight_timeout = 5;
37 37
38void backlight_thread(void) 38void backlight_thread(void)
39{ 39{
@@ -45,7 +45,7 @@ void backlight_thread(void)
45 switch(ev.id) 45 switch(ev.id)
46 { 46 {
47 case BACKLIGHT_ON: 47 case BACKLIGHT_ON:
48 backlight_timer = HZ*global_settings.backlight; 48 backlight_timer = HZ*backlight_timeout;
49 if(backlight_timer) 49 if(backlight_timer)
50 { 50 {
51#ifdef HAVE_RTC 51#ifdef HAVE_RTC
@@ -76,6 +76,12 @@ void backlight_off(void)
76 queue_post(&backlight_queue, BACKLIGHT_OFF, NULL); 76 queue_post(&backlight_queue, BACKLIGHT_OFF, NULL);
77} 77}
78 78
79void backlight_time(int seconds)
80{
81 backlight_timeout = seconds;
82 backlight_on();
83}
84
79void backlight_tick(void) 85void backlight_tick(void)
80{ 86{
81 if(backlight_timer) 87 if(backlight_timer)
diff --git a/firmware/backlight.h b/firmware/backlight.h
index 2a59800918..dca1f214f3 100644
--- a/firmware/backlight.h
+++ b/firmware/backlight.h
@@ -23,5 +23,6 @@ void backlight_init(void);
23void backlight_on(void); 23void backlight_on(void);
24void backlight_off(void); 24void backlight_off(void);
25void backlight_tick(void); 25void backlight_tick(void);
26void backlight_time(int seconds);
26 27
27#endif 28#endif
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 31e50caed3..8523e7f337 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -27,7 +27,6 @@
27#include "thread.h" 27#include "thread.h"
28#include "panic.h" 28#include "panic.h"
29#include "file.h" 29#include "file.h"
30#include "settings.h"
31#include "id3.h" 30#include "id3.h"
32 31
33#define MPEG_STACK_SIZE 0x2000 32#define MPEG_STACK_SIZE 0x2000
@@ -672,7 +671,7 @@ void mpeg_treble(int percent)
672#endif 671#endif
673} 672}
674 673
675void mpeg_init(void) 674void mpeg_init(int volume, int bass, int treble)
676{ 675{
677#ifdef ARCHOS_RECORDER 676#ifdef ARCHOS_RECORDER
678 int rc; 677 int rc;
@@ -737,8 +736,7 @@ void mpeg_init(void)
737 dac_config(0x04); /* DAC on, all else off */ 736 dac_config(0x04); /* DAC on, all else off */
738#endif 737#endif
739 738
740 mpeg_bass(DEFAULT_BASS_SETTING); 739 mpeg_bass(bass);
741 mpeg_treble(DEFAULT_TREBLE_SETTING); 740 mpeg_treble(treble);
742 mpeg_volume(DEFAULT_VOLUME_SETTING); 741 mpeg_volume(volume);
743
744} 742}
diff --git a/firmware/mpeg.h b/firmware/mpeg.h
index 063ab3f2e9..908eabcda7 100644
--- a/firmware/mpeg.h
+++ b/firmware/mpeg.h
@@ -19,7 +19,7 @@
19#ifndef _MPEG_H_ 19#ifndef _MPEG_H_
20#define _MPEG_H_ 20#define _MPEG_H_
21 21
22void mpeg_init(void); 22void mpeg_init(int volume, int bass, int treble);
23void mpeg_play(char* trackname); 23void mpeg_play(char* trackname);
24void mpeg_stop(void); 24void mpeg_stop(void);
25void mpeg_pause(void); 25void mpeg_pause(void);