Added note about 2.5 being Archos only
[kugel-rb.git] / apps / eq_menu.c
blob82639a54dac4daee497774a4fac1598d3e643462
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 Dan Everton
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "config.h"
21 #include <stdio.h>
22 #include <stdbool.h>
23 #include <string.h>
24 #include "eq_menu.h"
25 #include "system.h"
26 #include "kernel.h"
27 #include "lcd.h"
28 #include "menu.h"
29 #include "button.h"
30 #include "mp3_playback.h"
31 #include "settings.h"
32 #include "statusbar.h"
33 #include "screens.h"
34 #include "icons.h"
35 #include "font.h"
36 #include "lang.h"
37 #include "sprintf.h"
38 #include "talk.h"
39 #include "misc.h"
40 #include "sound.h"
41 #include "splash.h"
42 #include "dsp.h"
43 #include "tree.h"
44 #include "talk.h"
45 #include "screen_access.h"
46 #include "keyboard.h"
47 #include "gui/scrollbar.h"
49 /* Key definitions */
50 #if (CONFIG_KEYPAD == IRIVER_H100_PAD || \
51 CONFIG_KEYPAD == IRIVER_H300_PAD)
53 #define EQ_BTN_MODIFIER BUTTON_ON
54 #define EQ_BTN_DECREMENT BUTTON_LEFT
55 #define EQ_BTN_INCREMENT BUTTON_RIGHT
56 #define EQ_BTN_NEXT_BAND BUTTON_DOWN
57 #define EQ_BTN_PREV_BAND BUTTON_UP
58 #define EQ_BTN_CHANGE_MODE BUTTON_SELECT
59 #define EQ_BTN_EXIT BUTTON_OFF
61 #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
62 (CONFIG_KEYPAD == IPOD_3G_PAD)
64 #define EQ_BTN_DECREMENT BUTTON_SCROLL_BACK
65 #define EQ_BTN_INCREMENT BUTTON_SCROLL_FWD
66 #define EQ_BTN_NEXT_BAND BUTTON_RIGHT
67 #define EQ_BTN_PREV_BAND BUTTON_LEFT
68 #define EQ_BTN_CHANGE_MODE BUTTON_SELECT
69 #define EQ_BTN_EXIT BUTTON_MENU
71 #elif CONFIG_KEYPAD == IAUDIO_X5_PAD
73 #define EQ_BTN_DECREMENT BUTTON_LEFT
74 #define EQ_BTN_INCREMENT BUTTON_RIGHT
75 #define EQ_BTN_NEXT_BAND BUTTON_DOWN
76 #define EQ_BTN_PREV_BAND BUTTON_UP
77 #define EQ_BTN_CHANGE_MODE BUTTON_REC
78 #define EQ_BTN_EXIT BUTTON_SELECT
80 #elif (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD)
82 #define EQ_BTN_DECREMENT BUTTON_LEFT
83 #define EQ_BTN_INCREMENT BUTTON_RIGHT
84 #define EQ_BTN_NEXT_BAND BUTTON_DOWN
85 #define EQ_BTN_PREV_BAND BUTTON_UP
86 #define EQ_BTN_CHANGE_MODE BUTTON_SELECT
87 #define EQ_BTN_EXIT BUTTON_PLAY
89 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
91 #define EQ_BTN_DECREMENT BUTTON_LEFT
92 #define EQ_BTN_INCREMENT BUTTON_RIGHT
93 #define EQ_BTN_NEXT_BAND BUTTON_DOWN
94 #define EQ_BTN_PREV_BAND BUTTON_UP
95 #define EQ_BTN_CHANGE_MODE BUTTON_SELECT
96 #define EQ_BTN_EXIT BUTTON_A
98 #endif
101 #define EQ_CUTOFF_MIN 20
102 #define EQ_CUTOFF_MAX 22040
103 #define EQ_CUTOFF_STEP 10
104 #define EQ_CUTOFF_FAST_STEP 100
105 #define EQ_GAIN_MIN (-240)
106 #define EQ_GAIN_MAX 240
107 #define EQ_GAIN_STEP 1
108 #define EQ_GAIN_FAST_STEP 10
109 #define EQ_Q_MIN 5
110 #define EQ_Q_MAX 64
111 #define EQ_Q_STEP 1
112 #define EQ_Q_FAST_STEP 10
114 #define EQ_USER_DIVISOR 10
116 static bool eq_enabled(void)
118 int i;
120 bool result = set_bool(str(LANG_EQUALIZER_ENABLED),
121 &global_settings.eq_enabled);
123 /* Update all bands */
124 for(i = 0; i < 5; i++) {
125 dsp_eq_update_data(global_settings.eq_enabled, i);
128 return result;
131 static void eq_gain_format(char* buffer, int buffer_size, int value, const char* unit)
133 int v = abs(value);
135 snprintf(buffer, buffer_size, "%s%d.%d %s", value < 0 ? "-" : "",
136 v / EQ_USER_DIVISOR, v % EQ_USER_DIVISOR, unit);
139 static void eq_q_format(char* buffer, int buffer_size, int value, const char* unit)
141 snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
144 /* Possibly dodgy way of simplifying the code a bit. */
145 #define eq_make_gain_label(buf, bufsize, frequency) snprintf((buf), \
146 (bufsize), str(LANG_EQUALIZER_GAIN_ITEM), (frequency))
148 #define eq_set_center(band) \
149 static bool eq_set_band ## band ## _center(void) \
151 bool result = set_int(str(LANG_EQUALIZER_BAND_CENTER), "Hertz", UNIT_HERTZ, \
152 &global_settings.eq_band ## band ## _cutoff, NULL, \
153 EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \
154 dsp_eq_update_data(global_settings.eq_enabled, band); \
155 return result; \
158 #define eq_set_cutoff(band) \
159 static bool eq_set_band ## band ## _cutoff(void) \
161 bool result = set_int(str(LANG_EQUALIZER_BAND_CUTOFF), "Hertz", UNIT_HERTZ, \
162 &global_settings.eq_band ## band ## _cutoff, NULL, \
163 EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \
164 dsp_eq_update_data(global_settings.eq_enabled, band); \
165 return result; \
168 #define eq_set_q(band) \
169 static bool eq_set_band ## band ## _q(void) \
171 bool result = set_int(str(LANG_EQUALIZER_BAND_Q), "Q", UNIT_INT, \
172 &global_settings.eq_band ## band ## _q, NULL, \
173 EQ_Q_STEP, EQ_Q_MIN, EQ_Q_MAX, eq_q_format); \
174 dsp_eq_update_data(global_settings.eq_enabled, band); \
175 return result; \
178 #define eq_set_gain(band) \
179 static bool eq_set_band ## band ## _gain(void) \
181 bool result = set_int("Band " #band, str(LANG_UNIT_DB), UNIT_DB, \
182 &global_settings.eq_band ## band ## _gain, NULL, \
183 EQ_GAIN_STEP, EQ_GAIN_MIN, EQ_GAIN_MAX, eq_gain_format); \
184 dsp_eq_update_data(global_settings.eq_enabled, band); \
185 return result; \
188 eq_set_cutoff(0);
189 eq_set_center(1);
190 eq_set_center(2);
191 eq_set_center(3);
192 eq_set_cutoff(4);
194 eq_set_q(0);
195 eq_set_q(1);
196 eq_set_q(2);
197 eq_set_q(3);
198 eq_set_q(4);
200 eq_set_gain(0);
201 eq_set_gain(1);
202 eq_set_gain(2);
203 eq_set_gain(3);
204 eq_set_gain(4);
206 static bool eq_gain_menu(void)
208 int m, i;
209 int *setting;
210 bool result;
211 char gain_label[5][24];
212 static struct menu_item items[5] = {
213 { NULL, eq_set_band0_gain },
214 { NULL, eq_set_band1_gain },
215 { NULL, eq_set_band2_gain },
216 { NULL, eq_set_band3_gain },
217 { NULL, eq_set_band4_gain },
220 setting = &global_settings.eq_band0_cutoff;
222 /* Construct menu labels */
223 for(i = 0; i < 5; i++) {
224 eq_make_gain_label(gain_label[i], sizeof(gain_label[i]),
225 *setting);
226 items[i].desc = gain_label[i];
228 /* Skip to next band */
229 setting += 3;
232 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
233 NULL, NULL, NULL);
234 result = menu_run(m);
235 menu_exit(m);
237 return result;
240 static bool eq_set_band0(void)
242 int m;
243 bool result;
244 static const struct menu_item items[] = {
245 { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_set_band0_cutoff },
246 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band0_q },
247 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band0_gain },
250 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
251 NULL, NULL, NULL);
252 result = menu_run(m);
253 menu_exit(m);
255 return result;
258 static bool eq_set_band1(void)
260 int m;
261 bool result;
262 static const struct menu_item items[] = {
263 { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_set_band1_center },
264 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band1_q },
265 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band1_gain },
268 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
269 NULL, NULL, NULL);
270 result = menu_run(m);
271 menu_exit(m);
273 return result;
276 static bool eq_set_band2(void)
278 int m;
279 bool result;
280 static const struct menu_item items[] = {
281 { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_set_band2_center },
282 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band2_q },
283 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band2_gain },
286 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
287 NULL, NULL, NULL);
288 result = menu_run(m);
289 menu_exit(m);
291 return result;
294 static bool eq_set_band3(void)
296 int m;
297 bool result;
298 static const struct menu_item items[] = {
299 { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_set_band3_center },
300 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band3_q },
301 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band3_gain },
304 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
305 NULL, NULL, NULL);
306 result = menu_run(m);
307 menu_exit(m);
309 return result;
312 static bool eq_set_band4(void)
314 int m;
315 bool result;
316 static const struct menu_item items[] = {
317 { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_set_band4_cutoff },
318 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band4_q },
319 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band4_gain },
322 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
323 NULL, NULL, NULL);
324 result = menu_run(m);
325 menu_exit(m);
327 return result;
330 static bool eq_advanced_menu(void)
332 int m, i;
333 bool result;
334 char peak_band_label[3][32];
335 static struct menu_item items[] = {
336 { ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), eq_set_band0 },
337 { NULL, eq_set_band1 },
338 { NULL, eq_set_band2 },
339 { NULL, eq_set_band3 },
340 { ID2P(LANG_EQUALIZER_BAND_HIGH_SHELF), eq_set_band4 },
343 /* Construct menu labels */
344 for(i = 1; i < 4; i++) {
345 snprintf(peak_band_label[i-1], sizeof(peak_band_label[i-1]),
346 str(LANG_EQUALIZER_BAND_PEAK), i);
347 items[i].desc = peak_band_label[i-1];
350 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
351 NULL, NULL, NULL);
352 result = menu_run(m);
353 menu_exit(m);
355 return result;
358 enum eq_slider_mode {
359 GAIN,
360 CUTOFF,
364 enum eq_type {
365 LOW_SHELF,
366 PEAK,
367 HIGH_SHELF
370 /* Draw the UI for a whole EQ band */
371 static int draw_eq_slider(struct screen * screen, int x, int y,
372 int width, int cutoff, int q, int gain, bool selected,
373 enum eq_slider_mode mode, enum eq_type type)
375 char buf[26];
376 const char separator[2] = " ";
377 int steps, min_item, max_item;
378 int abs_gain = abs(gain);
379 int current_x, total_height, separator_width, separator_height;
380 int w, h;
381 const int slider_height = 6;
383 switch(mode) {
384 case Q:
385 steps = EQ_Q_MAX - EQ_Q_MIN;
386 min_item = q - EQ_Q_STEP - EQ_Q_MIN;
387 max_item = q + EQ_Q_STEP - EQ_Q_MIN;
388 break;
389 case CUTOFF:
390 steps = EQ_CUTOFF_MAX - EQ_CUTOFF_MIN;
391 min_item = cutoff - EQ_CUTOFF_FAST_STEP * 2;
392 max_item = cutoff + EQ_CUTOFF_FAST_STEP * 2;
393 break;
394 case GAIN:
395 default:
396 steps = EQ_GAIN_MAX - EQ_GAIN_MIN;
397 min_item = abs(EQ_GAIN_MIN) + gain - EQ_GAIN_STEP * 5;
398 max_item = abs(EQ_GAIN_MIN) + gain + EQ_GAIN_STEP * 5;
399 break;
402 /* Start two pixels in, one for border, one for margin */
403 current_x = x + 2;
405 /* Figure out how large our separator string is */
406 screen->getstringsize(separator, &separator_width, &separator_height);
408 /* Total height includes margins, text, and line selector */
409 total_height = separator_height + slider_height + 2 + 3;
411 /* Print out the band label */
412 if (type == LOW_SHELF) {
413 screen->putsxy(current_x, y + 2, "LS:");
414 screen->getstringsize("LS:", &w, &h);
415 } else if (type == HIGH_SHELF) {
416 screen->putsxy(current_x, y + 2, "HS:");
417 screen->getstringsize("HS:", &w, &h);
418 } else {
419 screen->putsxy(current_x, y + 2, "PK:");
420 screen->getstringsize("PK:", &w, &h);
422 current_x += w;
424 /* Print separator */
425 screen->set_drawmode(DRMODE_SOLID);
426 screen->putsxy(current_x, y + 2, separator);
427 current_x += separator_width;
429 /* Print out gain part of status line */
430 snprintf(buf, sizeof(buf), "%s%2d.%ddB", gain < 0 ? "-" : " ",
431 abs_gain / EQ_USER_DIVISOR, abs_gain % EQ_USER_DIVISOR);
433 if (mode == GAIN && selected)
434 screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
436 screen->putsxy(current_x, y + 2, buf);
437 screen->getstringsize(buf, &w, &h);
438 current_x += w;
440 /* Print separator */
441 screen->set_drawmode(DRMODE_SOLID);
442 screen->putsxy(current_x, y + 2, separator);
443 current_x += separator_width;
445 /* Print out cutoff part of status line */
446 snprintf(buf, sizeof(buf), "%5dHz", cutoff);
448 if (mode == CUTOFF && selected)
449 screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
451 screen->putsxy(current_x, y + 2, buf);
452 screen->getstringsize(buf, &w, &h);
453 current_x += w;
455 /* Print separator */
456 screen->set_drawmode(DRMODE_SOLID);
457 screen->putsxy(current_x, y + 2, separator);
458 current_x += separator_width;
460 /* Print out Q part of status line */
461 snprintf(buf, sizeof(buf), "%d.%d Q", q / EQ_USER_DIVISOR,
462 q % EQ_USER_DIVISOR);
464 if (mode == Q && selected)
465 screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
467 screen->putsxy(current_x, y + 2, buf);
468 screen->getstringsize(buf, &w, &h);
469 current_x += w;
471 screen->set_drawmode(DRMODE_SOLID);
473 /* Draw selection box */
474 if (selected) {
475 screen->drawrect(x, y, width, total_height);
478 /* Draw horizontal slider. Reuse scrollbar for this */
479 gui_scrollbar_draw(screen, x + 3, y + h + 3, width - 6, slider_height, steps,
480 min_item, max_item, HORIZONTAL);
482 return total_height;
485 /* Draw's all the EQ sliders. Returns the total height of the sliders drawn */
486 static int draw_eq_sliders(int current_band, enum eq_slider_mode mode)
488 int i, gain, q, cutoff;
489 int height = 2; /* Two pixel margin */
490 int slider_width = screens[SCREEN_MAIN].width - 4; /* two pixel margin on each side */
491 int *setting = &global_settings.eq_band0_cutoff;
492 enum eq_type type;
494 for( i = 0; i < 5; ++i) {
495 cutoff = *setting++;
496 q = *setting++;
497 gain = *setting++;
499 if (i == 0) {
500 type = LOW_SHELF;
501 } else if (i == 4) {
502 type = HIGH_SHELF;
503 } else {
504 type = PEAK;
507 height += draw_eq_slider(&(screens[SCREEN_MAIN]), 2, height,
508 slider_width, cutoff, q, gain, i == current_band, mode, type);
510 /* add a margin */
511 height += 2;
514 return height;
517 /* Provides a graphical means of editing the EQ settings */
518 bool eq_menu_graphical(void)
520 bool exit_request = false;
521 bool result = true;
522 bool has_changed = false;
523 int button;
524 int *setting;
525 int current_band, y, step, fast_step, min, max, voice_unit;
526 enum eq_slider_mode mode;
527 enum eq_type current_type;
528 char buf[24];
530 screens[SCREEN_MAIN].setfont(FONT_SYSFIXED);
531 screens[SCREEN_MAIN].clear_display();
533 /* Start off editing gain on the first band */
534 mode = GAIN;
535 current_type = LOW_SHELF;
536 current_band = 0;
538 while (!exit_request) {
539 /* Clear the screen. The drawing routines expect this */
540 screens[SCREEN_MAIN].clear_display();
542 /* Draw equalizer band details */
543 y = draw_eq_sliders(current_band, mode);
545 /* Set pointer to the band data currently editable */
546 if (mode == GAIN) {
547 /* gain */
548 setting = &global_settings.eq_band0_gain;
549 setting += current_band * 3;
551 step = EQ_GAIN_STEP;
552 fast_step = EQ_GAIN_FAST_STEP;
553 min = EQ_GAIN_MIN;
554 max = EQ_GAIN_MAX;
555 voice_unit = UNIT_DB;
557 snprintf(buf, sizeof(buf), str(LANG_EQUALIZER_EDIT_MODE),
558 str(LANG_EQUALIZER_BAND_GAIN));
560 screens[SCREEN_MAIN].putsxy(2, y, buf);
561 } else if (mode == CUTOFF) {
562 /* cutoff */
563 setting = &global_settings.eq_band0_cutoff;
564 setting += current_band * 3;
566 step = EQ_CUTOFF_STEP;
567 fast_step = EQ_CUTOFF_FAST_STEP;
568 min = EQ_CUTOFF_MIN;
569 max = EQ_CUTOFF_MAX;
570 voice_unit = UNIT_HERTZ;
572 snprintf(buf, sizeof(buf), str(LANG_EQUALIZER_EDIT_MODE),
573 str(LANG_EQUALIZER_BAND_CUTOFF));
575 screens[SCREEN_MAIN].putsxy(2, y, buf);
576 } else {
577 /* Q */
578 setting = &global_settings.eq_band0_q;
579 setting += current_band * 3;
581 step = EQ_Q_STEP;
582 fast_step = EQ_Q_FAST_STEP;
583 min = EQ_Q_MIN;
584 max = EQ_Q_MAX;
585 voice_unit = UNIT_INT;
587 snprintf(buf, sizeof(buf), str(LANG_EQUALIZER_EDIT_MODE),
588 str(LANG_EQUALIZER_BAND_Q));
590 screens[SCREEN_MAIN].putsxy(2, y, buf);
593 screens[SCREEN_MAIN].update();
595 button = button_get(true);
597 switch (button) {
598 case EQ_BTN_DECREMENT:
599 case EQ_BTN_DECREMENT | BUTTON_REPEAT:
600 *(setting) -= step;
601 has_changed = true;
602 if (*(setting) < min)
603 *(setting) = min;
604 break;
606 case EQ_BTN_INCREMENT:
607 case EQ_BTN_INCREMENT | BUTTON_REPEAT:
608 *(setting) += step;
609 has_changed = true;
610 if (*(setting) > max)
611 *(setting) = max;
612 break;
614 #ifdef EQ_BTN_MODIFIER
615 case EQ_BTN_MODIFIER | EQ_BTN_INCREMENT:
616 case EQ_BTN_MODIFIER | EQ_BTN_INCREMENT | BUTTON_REPEAT:
617 *(setting) += fast_step;
618 has_changed = true;
619 if (*(setting) > max)
620 *(setting) = max;
621 break;
623 case EQ_BTN_MODIFIER | EQ_BTN_DECREMENT:
624 case EQ_BTN_MODIFIER | EQ_BTN_DECREMENT | BUTTON_REPEAT:
625 *(setting) -= fast_step;
626 has_changed = true;
627 if (*(setting) < min)
628 *(setting) = min;
629 break;
630 #endif
632 case EQ_BTN_PREV_BAND:
633 case EQ_BTN_PREV_BAND | BUTTON_REPEAT:
634 current_band--;
635 if (current_band < 0)
636 current_band = 4; /* wrap around */
637 break;
639 case EQ_BTN_NEXT_BAND:
640 case EQ_BTN_NEXT_BAND | BUTTON_REPEAT:
641 current_band++;
642 if (current_band > 4)
643 current_band = 0; /* wrap around */
644 break;
646 case EQ_BTN_CHANGE_MODE:
647 case EQ_BTN_CHANGE_MODE | BUTTON_REPEAT:
648 mode++;
649 if (mode > Q)
650 mode = GAIN; /* wrap around */
651 break;
653 case EQ_BTN_EXIT:
654 case EQ_BTN_EXIT | BUTTON_REPEAT:
655 exit_request = true;
656 result = false;
657 break;
659 default:
660 if(default_event_handler(button) == SYS_USB_CONNECTED) {
661 exit_request = true;
662 result = true;
664 break;
667 /* Update the filter if the user changed something */
668 if (has_changed) {
669 dsp_eq_update_data(global_settings.eq_enabled, current_band);
670 has_changed = false;
674 /* Reset screen settings */
675 screens[SCREEN_MAIN].setfont(FONT_UI);
676 screens[SCREEN_MAIN].clear_display();
678 return result;
681 /* Preset saver.
682 * TODO: Can the settings system be used to do this instead?
684 static bool eq_save_preset(void)
686 int fd, i;
687 char filename[MAX_PATH];
688 int *setting;
690 create_numbered_filename(filename, EQS_DIR, "eq", ".cfg", 2);
692 /* allow user to modify filename */
693 while (true) {
694 if (!kbd_input(filename, sizeof filename)) {
695 fd = creat(filename,0);
696 if (fd < 0)
697 gui_syncsplash(HZ, true, str(LANG_FAILED));
698 else
699 break;
701 else {
702 gui_syncsplash(HZ, true, str(LANG_MENU_SETTING_CANCEL));
703 return false;
707 /* TODO: Should we really do this? */
708 fdprintf(fd, "eq enabled: on\r\n");
710 setting = &global_settings.eq_band0_cutoff;
712 for(i = 0; i < 5; ++i) {
713 fdprintf(fd, "eq band %d cutoff: %d\r\n", i, *setting++);
714 fdprintf(fd, "eq band %d q: %d\r\n", i, *setting++);
715 fdprintf(fd, "eq band %d gain: %d\r\n", i, *setting++);
718 close(fd);
720 gui_syncsplash(HZ, true, (unsigned char *)"%s %s", str(LANG_SETTINGS_SAVED1),
721 str(LANG_SETTINGS_SAVED2));
723 return true;
726 /* Allows browsing of preset files */
727 bool eq_browse_presets(void)
729 return rockbox_browse(EQS_DIR, SHOW_CFG);
732 /* Full equalizer menu */
733 bool eq_menu(void)
735 int m;
736 bool result;
737 static const struct menu_item items[] = {
738 { ID2P(LANG_EQUALIZER_ENABLED), eq_enabled },
739 { ID2P(LANG_EQUALIZER_GRAPHICAL), eq_menu_graphical },
740 { ID2P(LANG_EQUALIZER_GAIN), eq_gain_menu },
741 { ID2P(LANG_EQUALIZER_ADVANCED), eq_advanced_menu },
742 { ID2P(LANG_EQUALIZER_SAVE), eq_save_preset },
743 { ID2P(LANG_EQUALIZER_BROWSE), eq_browse_presets },
746 m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
747 NULL, NULL, NULL);
748 result = menu_run(m);
749 menu_exit(m);
751 return result;