diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-05-26 17:03:52 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-05-26 17:03:52 +0000 |
commit | 052fc4d9b20905804df0ddfa0018491b1c2169fc (patch) | |
tree | aa471e938f0140775f3c9a31ba3d640082fe1c9b | |
parent | 2ac057241a3b96fc71d9e320ac23e455a0a11368 (diff) | |
download | rockbox-052fc4d9b20905804df0ddfa0018491b1c2169fc.tar.gz rockbox-052fc4d9b20905804df0ddfa0018491b1c2169fc.zip |
Sound settings
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@708 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/sound_menu.c | 116 | ||||
-rw-r--r-- | apps/sound_menu.h | 24 |
2 files changed, 140 insertions, 0 deletions
diff --git a/apps/sound_menu.c b/apps/sound_menu.c new file mode 100644 index 0000000000..39f395cb8f --- /dev/null +++ b/apps/sound_menu.c | |||
@@ -0,0 +1,116 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Björn Stenberg | ||
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 | #include <stdio.h> | ||
20 | #include <stdbool.h> | ||
21 | #include "lcd.h" | ||
22 | #include "menu.h" | ||
23 | #include "sound_menu.h" | ||
24 | #include "mpeg.h" | ||
25 | #include "button.h" | ||
26 | #include "kernel.h" | ||
27 | |||
28 | typedef void (*settingfunc)(int); | ||
29 | enum { Volume, Bass, Treble, numsettings }; | ||
30 | |||
31 | static void soundsetting(int setting) | ||
32 | { | ||
33 | static int savedsettings[numsettings] = { 50, 50, 50 }; | ||
34 | static const char* names[] = { "Volume", "Bass", "Treble" }; | ||
35 | static settingfunc funcs[] = { mpeg_volume, mpeg_bass, mpeg_treble }; | ||
36 | |||
37 | int value = savedsettings[setting]; | ||
38 | char buf[32]; | ||
39 | bool done = false; | ||
40 | |||
41 | lcd_clear_display(); | ||
42 | snprintf(buf,sizeof buf,"[%s]",names[setting]); | ||
43 | lcd_puts(0,0,buf); | ||
44 | |||
45 | while ( !done ) { | ||
46 | int key; | ||
47 | snprintf(buf,sizeof buf,"%d %% ",value); | ||
48 | lcd_puts(0,1,buf); | ||
49 | |||
50 | while ( !(key = button_get()) ) | ||
51 | yield(); | ||
52 | |||
53 | switch ( key ) { | ||
54 | #ifdef HAVE_RECORDER_KEYPAD | ||
55 | case BUTTON_UP: | ||
56 | #else | ||
57 | case BUTTON_RIGHT: | ||
58 | #endif | ||
59 | value += 10; | ||
60 | if ( value >= 100 ) | ||
61 | value = 100; | ||
62 | (funcs[setting])(value); | ||
63 | break; | ||
64 | |||
65 | #ifdef HAVE_RECORDER_KEYPAD | ||
66 | case BUTTON_DOWN: | ||
67 | #else | ||
68 | case BUTTON_LEFT: | ||
69 | #endif | ||
70 | value -= 10; | ||
71 | if ( value <= 0 ) | ||
72 | value = 0; | ||
73 | (funcs[setting])(value); | ||
74 | break; | ||
75 | |||
76 | #ifdef HAVE_RECORDER_KEYPAD | ||
77 | case BUTTON_LEFT: | ||
78 | #else | ||
79 | case BUTTON_STOP: | ||
80 | #endif | ||
81 | savedsettings[setting] = value; | ||
82 | done = true; | ||
83 | break; | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | |||
88 | static void volume(void) | ||
89 | { | ||
90 | soundsetting(Volume); | ||
91 | } | ||
92 | |||
93 | static void bass(void) | ||
94 | { | ||
95 | soundsetting(Bass); | ||
96 | }; | ||
97 | |||
98 | static void treble(void) | ||
99 | { | ||
100 | soundsetting(Treble); | ||
101 | } | ||
102 | |||
103 | void sound_menu(void) | ||
104 | { | ||
105 | int m; | ||
106 | struct menu_items items[] = { | ||
107 | { Volume, "Volume", volume }, | ||
108 | { Bass, "Bass", bass }, | ||
109 | { Treble, "Treble", treble } | ||
110 | }; | ||
111 | |||
112 | m=menu_init( items, sizeof items / sizeof(struct menu_items) ); | ||
113 | menu_run(m); | ||
114 | menu_exit(m); | ||
115 | } | ||
116 | |||
diff --git a/apps/sound_menu.h b/apps/sound_menu.h new file mode 100644 index 0000000000..db40c120aa --- /dev/null +++ b/apps/sound_menu.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Björn Stenberg | ||
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 | #ifndef _SOUND_MENU_H | ||
20 | #define _SOUND_MENU_H | ||
21 | |||
22 | void sound_menu(void); | ||
23 | |||
24 | #endif | ||