summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/SOURCES4
-rw-r--r--apps/eq_menu.c1182
-rw-r--r--apps/menu.c232
-rw-r--r--apps/menu.h31
-rw-r--r--apps/menus/eq_menu.c787
-rw-r--r--apps/menus/eq_menu.h (renamed from apps/eq_menu.h)30
-rw-r--r--apps/menus/exported_menus.h7
-rw-r--r--apps/menus/sound_menu.c11
-rw-r--r--apps/onplay.c2
-rw-r--r--apps/recorder/icons.c1
-rw-r--r--apps/recorder/icons.h1
-rw-r--r--apps/settings.c2
-rw-r--r--apps/settings_list.c159
-rw-r--r--apps/sound_menu.c2
14 files changed, 1083 insertions, 1368 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index c186614733..83f41cda3a 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -12,6 +12,9 @@ main.c
main_menu.c
menu.c
menus/display_menu.c
+#if CONFIG_CODEC == SWCODEC
+menus/eq_menu.c
+#endif
menus/main_menu.c
menus/playback_menu.c
menus/playlist_menu.c
@@ -94,7 +97,6 @@ eq_cf.S
dsp_arm.S
eq_arm.S
#endif
-eq_menu.c
#endif
metadata.c
#ifdef HAVE_TAGCACHE
diff --git a/apps/eq_menu.c b/apps/eq_menu.c
deleted file mode 100644
index beaf385366..0000000000
--- a/apps/eq_menu.c
+++ /dev/null
@@ -1,1182 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 Dan Everton
- *
- * 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 "config.h"
-#include <stdio.h>
-#include <stdbool.h>
-#include <string.h>
-#include "eq_menu.h"
-#include "system.h"
-#include "kernel.h"
-#include "lcd.h"
-#include "menu.h"
-#include "action.h"
-#include "mp3_playback.h"
-#include "settings.h"
-#include "statusbar.h"
-#include "screens.h"
-#include "icons.h"
-#include "font.h"
-#include "lang.h"
-#include "sprintf.h"
-#include "talk.h"
-#include "misc.h"
-#include "sound.h"
-#include "splash.h"
-#include "dsp.h"
-#include "tree.h"
-#include "talk.h"
-#include "screen_access.h"
-#include "keyboard.h"
-#include "gui/scrollbar.h"
-#ifdef HAVE_WM8758
-#include "wm8758.h"
-#endif
-
-/* Various user interface limits and sizes */
-#define EQ_CUTOFF_MIN 20
-#define EQ_CUTOFF_MAX 22040
-#define EQ_CUTOFF_STEP 10
-#define EQ_CUTOFF_FAST_STEP 100
-#define EQ_GAIN_MIN (-240)
-#define EQ_GAIN_MAX 240
-#define EQ_GAIN_STEP 5
-#define EQ_GAIN_FAST_STEP 10
-#define EQ_Q_MIN 5
-#define EQ_Q_MAX 64
-#define EQ_Q_STEP 1
-#define EQ_Q_FAST_STEP 10
-
-#define EQ_USER_DIVISOR 10
-
-/*
- * Utility functions
- */
-
-static void eq_gain_format(char* buffer, int buffer_size, int value, const char* unit)
-{
- int v = abs(value);
-
- snprintf(buffer, buffer_size, "%s%d.%d %s", value < 0 ? "-" : "",
- v / EQ_USER_DIVISOR, v % EQ_USER_DIVISOR, unit);
-}
-
-static void eq_q_format(char* buffer, int buffer_size, int value, const char* unit)
-{
- snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
-}
-
-static void eq_precut_format(char* buffer, int buffer_size, int value, const char* unit)
-{
- snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-",
- value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
-}
-
-/*
- * Settings functions
- */
-
-static bool eq_enabled(void)
-{
- int i;
-
- bool result = set_bool(str(LANG_EQUALIZER_ENABLED),
- &global_settings.eq_enabled);
-
- dsp_set_eq(global_settings.eq_enabled);
-
- dsp_set_eq_precut(global_settings.eq_precut);
-
- /* Update all bands */
- for(i = 0; i < 5; i++) {
- dsp_set_eq_coefs(i);
- }
-
- return result;
-}
-
-static bool eq_precut(void)
-{
- bool result = set_int(str(LANG_EQUALIZER_PRECUT), str(LANG_UNIT_DB),
- UNIT_DB, &global_settings.eq_precut, dsp_set_eq_precut, 5, 0, 240,
- eq_precut_format);
-
- return result;
-}
-
-/* Possibly dodgy way of simplifying the code a bit. */
-#define eq_make_gain_label(buf, bufsize, frequency) snprintf((buf), \
- (bufsize), str(LANG_EQUALIZER_GAIN_ITEM), (frequency))
-
-#define eq_set_center(band) \
-static bool eq_set_band ## band ## _center(void) \
-{ \
- bool result = set_int(str(LANG_EQUALIZER_BAND_CENTER), "Hertz", \
- UNIT_HERTZ, &global_settings.eq_band ## band ## _cutoff, NULL, \
- EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \
- dsp_set_eq_coefs(band); \
- return result; \
-}
-
-#define eq_set_cutoff(band) \
-static bool eq_set_band ## band ## _cutoff(void) \
-{ \
- bool result = set_int(str(LANG_EQUALIZER_BAND_CUTOFF), "Hertz", \
- UNIT_HERTZ, &global_settings.eq_band ## band ## _cutoff, NULL, \
- EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \
- dsp_set_eq_coefs(band); \
- return result; \
-}
-
-#define eq_set_q(band) \
-static bool eq_set_band ## band ## _q(void) \
-{ \
- bool result = set_int(str(LANG_EQUALIZER_BAND_Q), "Q", UNIT_INT, \
- &global_settings.eq_band ## band ## _q, NULL, \
- EQ_Q_STEP, EQ_Q_MIN, EQ_Q_MAX, eq_q_format); \
- dsp_set_eq_coefs(band); \
- return result; \
-}
-
-#define eq_set_gain(band) \
-static bool eq_set_band ## band ## _gain(void) \
-{ \
- bool result = set_int("Band " #band, str(LANG_UNIT_DB), UNIT_DB, \
- &global_settings.eq_band ## band ## _gain, NULL, \
- EQ_GAIN_STEP, EQ_GAIN_MIN, EQ_GAIN_MAX, eq_gain_format); \
- dsp_set_eq_coefs(band); \
- return result; \
-}
-
-eq_set_cutoff(0);
-eq_set_center(1);
-eq_set_center(2);
-eq_set_center(3);
-eq_set_cutoff(4);
-
-eq_set_q(0);
-eq_set_q(1);
-eq_set_q(2);
-eq_set_q(3);
-eq_set_q(4);
-
-eq_set_gain(0);
-eq_set_gain(1);
-eq_set_gain(2);
-eq_set_gain(3);
-eq_set_gain(4);
-
-static bool eq_gain_menu(void)
-{
- int m, i;
- int *setting;
- bool result;
- char gain_label[5][32];
- static struct menu_item items[5] = {
- { NULL, eq_set_band0_gain },
- { NULL, eq_set_band1_gain },
- { NULL, eq_set_band2_gain },
- { NULL, eq_set_band3_gain },
- { NULL, eq_set_band4_gain },
- };
-
- setting = &global_settings.eq_band0_cutoff;
-
- /* Construct menu labels */
- for(i = 0; i < 5; i++) {
- eq_make_gain_label(gain_label[i], sizeof(gain_label[i]),
- *setting);
- items[i].desc = gain_label[i];
-
- /* Skip to next band */
- setting += 3;
- }
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-static bool eq_set_band0(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_set_band0_cutoff },
- { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band0_q },
- { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band0_gain },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-static bool eq_set_band1(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_set_band1_center },
- { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band1_q },
- { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band1_gain },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-static bool eq_set_band2(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_set_band2_center },
- { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band2_q },
- { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band2_gain },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-static bool eq_set_band3(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_set_band3_center },
- { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band3_q },
- { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band3_gain },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-static bool eq_set_band4(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_set_band4_cutoff },
- { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band4_q },
- { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band4_gain },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-static bool eq_advanced_menu(void)
-{
- int m, i;
- bool result;
- char peak_band_label[3][32];
- static struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), eq_set_band0 },
- { NULL, eq_set_band1 },
- { NULL, eq_set_band2 },
- { NULL, eq_set_band3 },
- { ID2P(LANG_EQUALIZER_BAND_HIGH_SHELF), eq_set_band4 },
- };
-
- /* Construct menu labels */
- for(i = 1; i < 4; i++) {
- snprintf(peak_band_label[i-1], sizeof(peak_band_label[i-1]),
- str(LANG_EQUALIZER_BAND_PEAK), i);
- items[i].desc = peak_band_label[i-1];
- }
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-enum eq_slider_mode {
- GAIN,
- CUTOFF,
- Q,
-};
-
-enum eq_type {
- LOW_SHELF,
- PEAK,
- HIGH_SHELF
-};
-
-/* Draw the UI for a whole EQ band */
-static int draw_eq_slider(struct screen * screen, int x, int y,
- int width, int cutoff, int q, int gain, bool selected,
- enum eq_slider_mode mode, enum eq_type type)
-{
- char buf[26];
- const char separator[2] = " ";
- int steps, min_item, max_item;
- int abs_gain = abs(gain);
- int current_x, total_height, separator_width, separator_height;
- int w, h;
- const int slider_height = 6;
-
- switch(mode) {
- case Q:
- steps = EQ_Q_MAX - EQ_Q_MIN;
- min_item = q - EQ_Q_STEP - EQ_Q_MIN;
- max_item = q + EQ_Q_STEP - EQ_Q_MIN;
- break;
- case CUTOFF:
- steps = EQ_CUTOFF_MAX - EQ_CUTOFF_MIN;
- min_item = cutoff - EQ_CUTOFF_FAST_STEP * 2;
- max_item = cutoff + EQ_CUTOFF_FAST_STEP * 2;
- break;
- case GAIN:
- default:
- steps = EQ_GAIN_MAX - EQ_GAIN_MIN;
- min_item = abs(EQ_GAIN_MIN) + gain - EQ_GAIN_STEP * 5;
- max_item = abs(EQ_GAIN_MIN) + gain + EQ_GAIN_STEP * 5;
- break;
- }
-
- /* Start two pixels in, one for border, one for margin */
- current_x = x + 2;
-
- /* Figure out how large our separator string is */
- screen->getstringsize(separator, &separator_width, &separator_height);
-
- /* Total height includes margins, text, and line selector */
- total_height = separator_height + slider_height + 2 + 3;
-
- /* Print out the band label */
- if (type == LOW_SHELF) {
- screen->putsxy(current_x, y + 2, "LS:");
- screen->getstringsize("LS:", &w, &h);
- } else if (type == HIGH_SHELF) {
- screen->putsxy(current_x, y + 2, "HS:");
- screen->getstringsize("HS:", &w, &h);
- } else {
- screen->putsxy(current_x, y + 2, "PK:");
- screen->getstringsize("PK:", &w, &h);
- }
- current_x += w;
-
- /* Print separator */
- screen->set_drawmode(DRMODE_SOLID);
- screen->putsxy(current_x, y + 2, separator);
- current_x += separator_width;
-#if NB_SCREENS > 1
- if (screen->screen_type == SCREEN_REMOTE) {
- if (mode == GAIN) {
- screen->putsxy(current_x, y + 2, str(LANG_EQUALIZER_BAND_GAIN));
- screen->getstringsize(str(LANG_EQUALIZER_BAND_GAIN), &w, &h);
- } else if (mode == CUTOFF) {
- screen->putsxy(current_x, y + 2, str(LANG_EQUALIZER_BAND_CUTOFF));
- screen->getstringsize(str(LANG_EQUALIZER_BAND_CUTOFF), &w, &h);
- } else {
- screen->putsxy(current_x, y + 2, str(LANG_EQUALIZER_BAND_Q));
- screen->getstringsize(str(LANG_EQUALIZER_BAND_Q), &w, &h);
- }
-
- /* Draw horizontal slider. Reuse scrollbar for this */
- gui_scrollbar_draw(screen, x + 3, y + h + 3, width - 6, slider_height, steps,
- min_item, max_item, HORIZONTAL);
-
- /* Print out cutoff part */
- snprintf(buf, sizeof(buf), "%sGain %s%2d.%ddB",mode==GAIN?" > ":" ", gain < 0 ? "-" : " ",
- abs_gain / EQ_USER_DIVISOR, abs_gain % EQ_USER_DIVISOR);
- screen->getstringsize(buf, &w, &h);
- y = 3*h;
- screen->putsxy(0, y, buf);
- /* Print out cutoff part */
- snprintf(buf, sizeof(buf), "%sCutoff %5dHz",mode==CUTOFF?" > ":" ", cutoff);
- y += h;
- screen->putsxy(0, y, buf);
- snprintf(buf, sizeof(buf), "%sQ setting %d.%d Q",mode==Q?" > ":" ", q / EQ_USER_DIVISOR,
- q % EQ_USER_DIVISOR);
- y += h;
- screen->putsxy(0, y, buf);
- return y;
- }
-#endif
-
- /* Print out gain part of status line */
- snprintf(buf, sizeof(buf), "%s%2d.%ddB", gain < 0 ? "-" : " ",
- abs_gain / EQ_USER_DIVISOR, abs_gain % EQ_USER_DIVISOR);
-
- if (mode == GAIN && selected)
- screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
-
- screen->putsxy(current_x, y + 2, buf);
- screen->getstringsize(buf, &w, &h);
- current_x += w;
-
- /* Print separator */
- screen->set_drawmode(DRMODE_SOLID);
- screen->putsxy(current_x, y + 2, separator);
- current_x += separator_width;
-
- /* Print out cutoff part of status line */
- snprintf(buf, sizeof(buf), "%5dHz", cutoff);
-
- if (mode == CUTOFF && selected)
- screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
-
- screen->putsxy(current_x, y + 2, buf);
- screen->getstringsize(buf, &w, &h);
- current_x += w;
-
- /* Print separator */
- screen->set_drawmode(DRMODE_SOLID);
- screen->putsxy(current_x, y + 2, separator);
- current_x += separator_width;
-
- /* Print out Q part of status line */
- snprintf(buf, sizeof(buf), "%d.%d Q", q / EQ_USER_DIVISOR,
- q % EQ_USER_DIVISOR);
-
- if (mode == Q && selected)
- screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
-
- screen->putsxy(current_x, y + 2, buf);
- screen->getstringsize(buf, &w, &h);
- current_x += w;
-
- screen->set_drawmode(DRMODE_SOLID);
-
- /* Draw selection box */
- if (selected) {
- screen->drawrect(x, y, width, total_height);
- }
-
- /* Draw horizontal slider. Reuse scrollbar for this */
- gui_scrollbar_draw(screen, x + 3, y + h + 3, width - 6, slider_height, steps,
- min_item, max_item, HORIZONTAL);
-
- return total_height;
-}
-
-/* Draw's all the EQ sliders. Returns the total height of the sliders drawn */
-static int draw_eq_sliders(int current_band, enum eq_slider_mode mode)
-{
- int i, gain, q, cutoff;
- int height = 2; /* Two pixel margin */
- int slider_width[NB_SCREENS];
- int *setting = &global_settings.eq_band0_cutoff;
- enum eq_type type;
-
- FOR_NB_SCREENS(i)
- slider_width[i] = screens[i].width - 4; /* two pixel margin on each side */
-
- for (i=0; i<5; i++) {
- cutoff = *setting++;
- q = *setting++;
- gain = *setting++;
-
- if (i == 0) {
- type = LOW_SHELF;
- } else if (i == 4) {
- type = HIGH_SHELF;
- } else {
- type = PEAK;
- }
- height += draw_eq_slider(&(screens[SCREEN_MAIN]), 2, height,
- slider_width[SCREEN_MAIN], cutoff, q, gain,
- i == current_band, mode, type);
-#if NB_SCREENS > 1
- if (i == current_band)
- draw_eq_slider(&(screens[SCREEN_REMOTE]), 2, 0,
- slider_width[SCREEN_REMOTE], cutoff, q, gain,1, mode, type);
-#endif
- /* add a margin */
- height += 2;
- }
-
- return height;
-}
-
-/* Provides a graphical means of editing the EQ settings */
-bool eq_menu_graphical(void)
-{
- bool exit_request = false;
- bool result = true;
- bool has_changed = false;
- int button;
- int *setting;
- int current_band, y, step, fast_step, min, max, voice_unit;
- enum eq_slider_mode mode;
- enum eq_type current_type;
- char buf[24];
- int i;
-
- FOR_NB_SCREENS(i) {
- screens[i].setfont(FONT_SYSFIXED);
- screens[i].clear_display();
- }
-
- /* Start off editing gain on the first band */
- mode = GAIN;
- current_type = LOW_SHELF;
- current_band = 0;
-
- while (!exit_request) {
-
- FOR_NB_SCREENS(i) {
- /* Clear the screen. The drawing routines expect this */
- screens[i].clear_display();
- /* Draw equalizer band details */
- y = draw_eq_sliders(current_band, mode);
- }
-
- /* Set pointer to the band data currently editable */
- if (mode == GAIN) {
- /* gain */
- setting = &global_settings.eq_band0_gain;
- setting += current_band * 3;
-
- step = EQ_GAIN_STEP;
- fast_step = EQ_GAIN_FAST_STEP;
- min = EQ_GAIN_MIN;
- max = EQ_GAIN_MAX;
- voice_unit = UNIT_DB;
-
- snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
- str(LANG_SYSFONT_EQUALIZER_BAND_GAIN));
-
- screens[SCREEN_MAIN].putsxy(2, y, buf);
- } else if (mode == CUTOFF) {
- /* cutoff */
- setting = &global_settings.eq_band0_cutoff;
- setting += current_band * 3;
-
- step = EQ_CUTOFF_STEP;
- fast_step = EQ_CUTOFF_FAST_STEP;
- min = EQ_CUTOFF_MIN;
- max = EQ_CUTOFF_MAX;
- voice_unit = UNIT_HERTZ;
-
- snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
- str(LANG_SYSFONT_EQUALIZER_BAND_CUTOFF));
-
- screens[SCREEN_MAIN].putsxy(2, y, buf);
- } else {
- /* Q */
- setting = &global_settings.eq_band0_q;
- setting += current_band * 3;
-
- step = EQ_Q_STEP;
- fast_step = EQ_Q_FAST_STEP;
- min = EQ_Q_MIN;
- max = EQ_Q_MAX;
- voice_unit = UNIT_INT;
-
- snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
- str(LANG_EQUALIZER_BAND_Q));
-
- screens[SCREEN_MAIN].putsxy(2, y, buf);
- }
-
- FOR_NB_SCREENS(i) {
- screens[i].update();
- }
-
- button = get_action(CONTEXT_SETTINGS_EQ,TIMEOUT_BLOCK);
-
- switch (button) {
- case ACTION_SETTINGS_DEC:
- case ACTION_SETTINGS_DECREPEAT:
- *(setting) -= step;
- has_changed = true;
- if (*(setting) < min)
- *(setting) = min;
- break;
-
- case ACTION_SETTINGS_INC:
- case ACTION_SETTINGS_INCREPEAT:
- *(setting) += step;
- has_changed = true;
- if (*(setting) > max)
- *(setting) = max;
- break;
-
- case ACTION_SETTINGS_INCBIGSTEP:
- *(setting) += fast_step;
- has_changed = true;
- if (*(setting) > max)
- *(setting) = max;
- break;
-
- case ACTION_SETTINGS_DECBIGSTEP:
- *(setting) -= fast_step;
- has_changed = true;
- if (*(setting) < min)
- *(setting) = min;
- break;
-
- case ACTION_STD_PREV:
- case ACTION_STD_PREVREPEAT:
- current_band--;
- if (current_band < 0)
- current_band = 4; /* wrap around */
- break;
-
- case ACTION_STD_NEXT:
- case ACTION_STD_NEXTREPEAT:
- current_band++;
- if (current_band > 4)
- current_band = 0; /* wrap around */
- break;
-
- case ACTION_STD_OK:
- mode++;
- if (mode > Q)
- mode = GAIN; /* wrap around */
- break;
-
- case ACTION_STD_CANCEL:
- exit_request = true;
- result = false;
- break;
-
- default:
- if(default_event_handler(button) == SYS_USB_CONNECTED) {
- exit_request = true;
- result = true;
- }
- break;
- }
-
- /* Update the filter if the user changed something */
- if (has_changed) {
- dsp_set_eq_coefs(current_band);
- has_changed = false;
- }
- }
-
- action_signalscreenchange();
- /* Reset screen settings */
- FOR_NB_SCREENS(i) {
- screens[i].setfont(FONT_UI);
- screens[i].clear_display();
- }
- return result;
-}
-
-/* Preset saver.
- * TODO: Can the settings system be used to do this instead?
- */
-static bool eq_save_preset(void)
-{
- int fd, i;
- char filename[MAX_PATH];
- int *setting;
-
- create_numbered_filename(filename, EQS_DIR, "eq", ".cfg", 2
- IF_CNFN_NUM_(, NULL));
-
- /* allow user to modify filename */
- while (true) {
- if (!kbd_input(filename, sizeof filename)) {
- fd = creat(filename);
- if (fd < 0)
- gui_syncsplash(HZ, true, str(LANG_FAILED));
- else
- break;
- }
- else {
- gui_syncsplash(HZ, true, str(LANG_MENU_SETTING_CANCEL));
- return false;
- }
- }
-
- /* TODO: Should we really do this? */
- fdprintf(fd, "eq enabled: on\r\n");
- fdprintf(fd, "eq precut: %d\r\n", global_settings.eq_precut);
-
- setting = &global_settings.eq_band0_cutoff;
-
- for(i = 0; i < 5; ++i) {
- fdprintf(fd, "eq band %d cutoff: %d\r\n", i, *setting++);
- fdprintf(fd, "eq band %d q: %d\r\n", i, *setting++);
- fdprintf(fd, "eq band %d gain: %d\r\n", i, *setting++);
- }
-
- close(fd);
-
- gui_syncsplash(HZ, true, str(LANG_SETTINGS_SAVED));
-
- return true;
-}
-
-/* Allows browsing of preset files */
-bool eq_browse_presets(void)
-{
- return rockbox_browse(EQS_DIR, SHOW_CFG);
-}
-
-#ifdef HAVE_WM8758
-
-/* WM8758 equalizer supports -12 to +12 dB gain in 1 dB increments. */
-#define EQ_HW_GAIN_STEP 1
-#define EQ_HW_GAIN_MIN -12
-#define EQ_HW_GAIN_MAX 12
-
-static const struct opt_items BANDWIDTH_NAMES[] = {
- { STR(LANG_EQUALIZER_HARDWARE_BANDWIDTH_NARROW) },
- { STR(LANG_EQUALIZER_HARDWARE_BANDWIDTH_WIDE) },
-};
-
-static const int BANDWIDTH_NAMES_SIZE = sizeof(BANDWIDTH_NAMES) /
- sizeof(*BANDWIDTH_NAMES);
-
-static void eq_hw_gain_format(char* buffer, int buffer_size, int value,
- const char* unit)
-{
- snprintf(buffer, buffer_size, "%d %s", value, unit);
-}
-
-static bool eq_hw_set_band0_cutoff(void)
-{
- static const struct opt_items names[] = {
- { (unsigned char *)"80 Hz", TALK_ID(80, UNIT_HERTZ) },
- { (unsigned char *)"105 Hz", TALK_ID(105, UNIT_HERTZ) },
- { (unsigned char *)"135 Hz", TALK_ID(135, UNIT_HERTZ) },
- { (unsigned char *)"175 Hz", TALK_ID(175, UNIT_HERTZ) },
- };
-
- bool result = set_option(str(LANG_EQUALIZER_BANDWIDTH),
- &global_settings.eq_hw_band0_cutoff, INT, names,
- sizeof(names) / sizeof(*names), NULL);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff, 0,
- global_settings.eq_hw_band0_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band0_gain(void)
-{
- bool result = set_int(str(LANG_EQUALIZER_BAND_GAIN), str(LANG_UNIT_DB), UNIT_DB,
- &global_settings.eq_hw_band0_gain, NULL,
- EQ_HW_GAIN_STEP, EQ_HW_GAIN_MIN, EQ_HW_GAIN_MAX,
- eq_hw_gain_format);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff, 0,
- global_settings.eq_hw_band0_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band1_center(void)
-{
- static const struct opt_items names[] = {
- { (unsigned char *)"230 Hz", TALK_ID(230, UNIT_HERTZ) },
- { (unsigned char *)"300 Hz", TALK_ID(300, UNIT_HERTZ) },
- { (unsigned char *)"385 Hz", TALK_ID(385, UNIT_HERTZ) },
- { (unsigned char *)"500 Hz", TALK_ID(500, UNIT_HERTZ) },
- };
-
- bool result = set_option(str(LANG_EQUALIZER_BAND_CENTER),
- &global_settings.eq_hw_band1_center, INT, names,
- sizeof(names) / sizeof(*names), NULL);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(1, global_settings.eq_hw_band1_center,
- global_settings.eq_hw_band1_bandwidth,
- global_settings.eq_hw_band1_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band1_bandwidth(void)
-{
- bool result = set_option(str(LANG_EQUALIZER_BANDWIDTH),
- &global_settings.eq_hw_band1_bandwidth, INT, BANDWIDTH_NAMES,
- BANDWIDTH_NAMES_SIZE, NULL);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(1, global_settings.eq_hw_band1_center,
- global_settings.eq_hw_band1_bandwidth,
- global_settings.eq_hw_band1_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band1_gain(void)
-{
- bool result = set_int(str(LANG_EQUALIZER_BAND_GAIN), str(LANG_UNIT_DB), UNIT_DB,
- &global_settings.eq_hw_band1_gain, NULL,
- EQ_HW_GAIN_STEP, EQ_HW_GAIN_MIN, EQ_HW_GAIN_MAX,
- eq_hw_gain_format);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(1, global_settings.eq_hw_band1_center,
- global_settings.eq_hw_band1_bandwidth,
- global_settings.eq_hw_band1_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band2_center(void)
-{
- static const struct opt_items names[] = {
- { (unsigned char *)"650 Hz", TALK_ID(650, UNIT_HERTZ) },
- { (unsigned char *)"850 Hz", TALK_ID(850, UNIT_HERTZ) },
- { (unsigned char *)"1.1 kHz", TALK_ID(1100, UNIT_HERTZ) },
- { (unsigned char *)"1.4 kHz", TALK_ID(1400, UNIT_HERTZ) },
- };
-
- bool result = set_option(str(LANG_EQUALIZER_BAND_CENTER),
- &global_settings.eq_hw_band2_center, INT, names,
- sizeof(names) / sizeof(*names), NULL);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(2, global_settings.eq_hw_band2_center,
- global_settings.eq_hw_band2_bandwidth,
- global_settings.eq_hw_band2_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band2_bandwidth(void)
-{
- bool result = set_option(str(LANG_EQUALIZER_BANDWIDTH),
- &global_settings.eq_hw_band2_bandwidth, INT, BANDWIDTH_NAMES,
- BANDWIDTH_NAMES_SIZE, NULL);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(2, global_settings.eq_hw_band2_center,
- global_settings.eq_hw_band2_bandwidth,
- global_settings.eq_hw_band2_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band2_gain(void)
-{
- bool result = set_int(str(LANG_EQUALIZER_BAND_GAIN), str(LANG_UNIT_DB), UNIT_DB,
- &global_settings.eq_hw_band2_gain, NULL,
- EQ_HW_GAIN_STEP, EQ_HW_GAIN_MIN, EQ_HW_GAIN_MAX,
- eq_hw_gain_format);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(2, global_settings.eq_hw_band2_center,
- global_settings.eq_hw_band2_bandwidth,
- global_settings.eq_hw_band2_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band3_center(void)
-{
- static const struct opt_items names[] = {
- { (unsigned char *)"1.8 kHz", TALK_ID(1800, UNIT_HERTZ) },
- { (unsigned char *)"2.4 kHz", TALK_ID(2400, UNIT_HERTZ) },
- { (unsigned char *)"3.2 kHz", TALK_ID(3200, UNIT_HERTZ) },
- { (unsigned char *)"4.1 kHz", TALK_ID(4100, UNIT_HERTZ) },
- };
-
- bool result = set_option(str(LANG_EQUALIZER_BAND_CENTER),
- &global_settings.eq_hw_band3_center, INT, names,
- sizeof(names) / sizeof(*names), NULL);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(3, global_settings.eq_hw_band3_center,
- global_settings.eq_hw_band3_bandwidth,
- global_settings.eq_hw_band3_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band3_bandwidth(void)
-{
- bool result = set_option(str(LANG_EQUALIZER_BANDWIDTH),
- &global_settings.eq_hw_band3_bandwidth, INT, BANDWIDTH_NAMES,
- BANDWIDTH_NAMES_SIZE, NULL);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(3, global_settings.eq_hw_band3_center,
- global_settings.eq_hw_band3_bandwidth,
- global_settings.eq_hw_band3_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band3_gain(void)
-{
- bool result = set_int(str(LANG_EQUALIZER_BAND_GAIN), str(LANG_UNIT_DB), UNIT_DB,
- &global_settings.eq_hw_band3_gain, NULL,
- EQ_HW_GAIN_STEP, EQ_HW_GAIN_MIN, EQ_HW_GAIN_MAX,
- eq_hw_gain_format);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(3, global_settings.eq_hw_band3_center,
- global_settings.eq_hw_band3_bandwidth,
- global_settings.eq_hw_band3_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band4_cutoff(void)
-{
- static const struct opt_items names[] = {
- { (unsigned char *)"5.3 kHz", TALK_ID(5300, UNIT_HERTZ) },
- { (unsigned char *)"6.9 kHz", TALK_ID(6900, UNIT_HERTZ) },
- { (unsigned char *)"9.0 kHz", TALK_ID(9000, UNIT_HERTZ) },
- { (unsigned char *)"11.7 kHz", TALK_ID(11700, UNIT_HERTZ) },
- };
-
- bool result = set_option(str(LANG_EQUALIZER_BAND_CUTOFF),
- &global_settings.eq_hw_band4_cutoff, INT, names,
- sizeof(names) / sizeof(*names), NULL);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff, 0,
- global_settings.eq_hw_band4_gain);
-#endif
-
- return result;
-}
-
-static bool eq_hw_set_band4_gain(void)
-{
- bool result = set_int(str(LANG_EQUALIZER_BAND_GAIN), str(LANG_UNIT_DB), UNIT_DB,
- &global_settings.eq_hw_band4_gain, NULL,
- EQ_HW_GAIN_STEP, EQ_HW_GAIN_MIN, EQ_HW_GAIN_MAX,
- eq_hw_gain_format);
-
-#ifndef SIMULATOR
- audiohw_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff, 0,
- global_settings.eq_hw_band4_gain);
-#endif
-
- return result;
-}
-
-void eq_hw_enable(bool enable)
-{
-#ifdef SIMULATOR
- (void) enable;
-#else
- if (enable) {
- audiohw_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff,
- 0, global_settings.eq_hw_band0_gain);
- audiohw_set_equalizer_band(1, global_settings.eq_hw_band1_center,
- global_settings.eq_hw_band1_bandwidth,
- global_settings.eq_hw_band1_gain);
- audiohw_set_equalizer_band(2, global_settings.eq_hw_band2_center,
- global_settings.eq_hw_band2_bandwidth,
- global_settings.eq_hw_band2_gain);
- audiohw_set_equalizer_band(3, global_settings.eq_hw_band3_center,
- global_settings.eq_hw_band3_bandwidth,
- global_settings.eq_hw_band3_gain);
- audiohw_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff,
- 0, global_settings.eq_hw_band4_gain);
- } else {
- audiohw_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff, 0, 0);
- audiohw_set_equalizer_band(1, global_settings.eq_hw_band1_center,
- global_settings.eq_hw_band1_bandwidth, 0);
- audiohw_set_equalizer_band(2, global_settings.eq_hw_band2_center,
- global_settings.eq_hw_band2_bandwidth, 0);
- audiohw_set_equalizer_band(3, global_settings.eq_hw_band3_center,
- global_settings.eq_hw_band3_bandwidth, 0);
- audiohw_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff, 0, 0);
- }
-#endif
-}
-
-static bool eq_hw_enabled(void)
-{
- bool result = set_bool(str(LANG_EQUALIZER_HARDWARE_ENABLED),
- &global_settings.eq_hw_enabled);
-
- eq_hw_enable(global_settings.eq_hw_enabled);
-
- return result;
-}
-
-static bool eq_hw_set_band0(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_hw_set_band0_cutoff },
- { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_hw_set_band0_gain },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-static bool eq_hw_set_band1(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_hw_set_band1_center },
- { ID2P(LANG_EQUALIZER_BANDWIDTH), eq_hw_set_band1_bandwidth },
- { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_hw_set_band1_gain },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-static bool eq_hw_set_band2(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_hw_set_band2_center },
- { ID2P(LANG_EQUALIZER_BANDWIDTH), eq_hw_set_band2_bandwidth },
- { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_hw_set_band2_gain },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-static bool eq_hw_set_band3(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_hw_set_band3_center },
- { ID2P(LANG_EQUALIZER_BANDWIDTH), eq_hw_set_band3_bandwidth },
- { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_hw_set_band3_gain },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-static bool eq_hw_set_band4(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_hw_set_band4_cutoff },
- { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_hw_set_band4_gain },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
-bool eq_hw_menu(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_HARDWARE_ENABLED), eq_hw_enabled },
- { ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), eq_hw_set_band0 },
- { "Peak Filter 1", eq_hw_set_band1 },
- { "Peak Filter 2", eq_hw_set_band2 },
- { "Peak Filter 3", eq_hw_set_band3 },
- { ID2P(LANG_EQUALIZER_BAND_HIGH_SHELF), eq_hw_set_band4 },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-#endif
-
-/* Full equalizer menu */
-bool eq_menu(void)
-{
- int m;
- bool result;
- static const struct menu_item items[] = {
- { ID2P(LANG_EQUALIZER_ENABLED), eq_enabled },
- { ID2P(LANG_EQUALIZER_GRAPHICAL), eq_menu_graphical },
- { ID2P(LANG_EQUALIZER_PRECUT), eq_precut },
- { ID2P(LANG_EQUALIZER_GAIN), eq_gain_menu },
- { ID2P(LANG_EQUALIZER_ADVANCED), eq_advanced_menu },
- { ID2P(LANG_EQUALIZER_SAVE), eq_save_preset },
- { ID2P(LANG_EQUALIZER_BROWSE), eq_browse_presets },
- };
-
- m = menu_init( items, sizeof(items) / sizeof(*items), NULL,
- NULL, NULL, NULL);
- result = menu_run(m);
- menu_exit(m);
-
- return result;
-}
-
diff --git a/apps/menu.c b/apps/menu.c
index 6728481a9f..a45567415d 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -290,7 +290,7 @@ static int current_subitems_count = 0;
void get_menu_callback(const struct menu_item_ex *m,
menu_callback_type *menu_callback)
{
- if (m->flags&MENU_HAS_DESC)
+ if (m->flags&(MENU_HAS_DESC|MENU_DYNAMIC_DESC))
*menu_callback= m->callback_and_desc->menu_callback;
else
*menu_callback = m->menu_callback;
@@ -318,6 +318,11 @@ static char * get_menu_item_name(int selected_item,void * data, char *buffer)
}
menu = menu->submenus[selected_item];
+
+ if (menu->flags&MENU_DYNAMIC_DESC)
+ return menu->menu_get_name_and_icon->list_get_name(selected_item,
+ menu->menu_get_name_and_icon->list_get_name_data, buffer);
+
type = (menu->flags&MENU_TYPE_MASK);
if (type == MT_SETTING)
{
@@ -333,26 +338,32 @@ static char * get_menu_item_name(int selected_item,void * data, char *buffer)
static void menu_get_icon(int selected_item, void * data, ICON * icon)
{
const struct menu_item_ex *menu = (const struct menu_item_ex *)data;
+ ICON menu_icon = NOICON;
selected_item = get_menu_selection(selected_item, menu);
menu = menu->submenus[selected_item];
+ if (menu->flags&MENU_HAS_DESC)
+ menu_icon = menu->callback_and_desc->icon;
+ else if (menu->flags&MENU_DYNAMIC_DESC)
+ menu_icon = menu->menu_get_name_and_icon->icon;
+
switch (menu->flags&MENU_TYPE_MASK)
{
case MT_SETTING:
*icon = bitmap_icons_6x8[Icon_Menu_setting];
break;
case MT_MENU:
- if (menu->callback_and_desc->icon == NOICON)
+ if (menu_icon == NOICON)
*icon = bitmap_icons_6x8[Icon_Submenu];
- else
- *icon = menu->callback_and_desc->icon;
+ else
+ *icon = menu_icon;
break;
case MT_FUNCTION_CALL:
case MT_FUNCTION_WITH_PARAM:
- if (menu->callback_and_desc->icon == NOICON)
+ if (menu_icon == NOICON)
*icon = bitmap_icons_6x8[Icon_Menu_functioncall];
else
- *icon = menu->callback_and_desc->icon;
+ *icon = menu_icon;
break;
default:
*icon = NOICON;
@@ -432,6 +443,113 @@ static void talk_menu_item(const struct menu_item_ex *menu,
}
}
#define MAX_OPTIONS 32
+/* returns true if the menu needs to be redrwan */
+bool do_setting_from_menu(const struct menu_item_ex *temp)
+{
+ int setting_id;
+ const struct settings_list *setting = find_setting(
+ temp->variable,
+ &setting_id);
+ bool ret_val = false;
+ if (setting)
+ {
+ if ((setting->flags&F_BOOL_SETTING) == F_BOOL_SETTING)
+ {
+ bool temp_var, *var;
+ bool show_icons = global_settings.show_icons;
+ if (setting->flags&F_TEMPVAR)
+ {
+ temp_var = *(bool*)setting->setting;
+ var = &temp_var;
+ }
+ else
+ {
+ var = (bool*)setting->setting;
+ }
+ set_bool_options(str(setting->lang_id),var,
+ STR(setting->bool_setting->lang_yes),
+ STR(setting->bool_setting->lang_no),
+ setting->bool_setting->option_callback);
+ if (setting->flags&F_TEMPVAR)
+ *(bool*)setting->setting = temp_var;
+ if (show_icons != global_settings.show_icons)
+ ret_val = true;
+ }
+ else if (setting->flags&F_T_SOUND)
+ {
+ set_sound(str(setting->lang_id), setting->setting,
+ setting->sound_setting->setting);
+ }
+ else /* other setting, must be an INT type */
+ {
+ int temp_var, *var;
+ if (setting->flags&F_TEMPVAR)
+ {
+ temp_var = *(int*)setting->setting;
+ var = &temp_var;
+ }
+ else
+ {
+ var = (int*)setting->setting;
+ }
+ if (setting->flags&F_INT_SETTING)
+ {
+ set_int_ex(str(setting->lang_id),
+ NULL,
+ setting->int_setting->unit,var,
+ setting->int_setting->option_callback,
+ setting->int_setting->step,
+ setting->int_setting->min,
+ setting->int_setting->max,
+ setting->int_setting->formatter,
+ setting->int_setting->get_talk_id);
+ }
+ else if (setting->flags&F_CHOICE_SETTING)
+ {
+ static struct opt_items options[MAX_OPTIONS];
+ char buffer[256];
+ char *buf_start = buffer;
+ int buf_free = 256;
+ int i,j, count = setting->choice_setting->count;
+ for (i=0, j=0; i<count && i<MAX_OPTIONS; i++)
+ {
+ if (setting->flags&F_CHOICETALKS)
+ {
+ if (cfg_int_to_string(setting_id, i,
+ buf_start, buf_free))
+ {
+ int len = strlen(buf_start) +1;
+ options[j].string = buf_start;
+ buf_start += len;
+ buf_free -= len;
+ options[j].voice_id =
+ setting->choice_setting->talks[i];
+ j++;
+ }
+ }
+ else
+ {
+ options[j].string =
+ P2STR(setting->
+ choice_setting->desc[i]);
+ options[j].voice_id =
+ P2ID(setting->
+ choice_setting->desc[i]);
+ j++;
+ }
+ }
+ set_option(str(setting->lang_id), var, INT,
+ options,j,
+ setting->
+ choice_setting->option_callback);
+ }
+ if (setting->flags&F_TEMPVAR)
+ *(int*)setting->setting = temp_var;
+ }
+ }
+ return ret_val;
+}
+
int do_menu(const struct menu_item_ex *start_menu)
{
int action;
@@ -551,106 +669,8 @@ int do_menu(const struct menu_item_ex *start_menu)
break;
case MT_SETTING:
{
- int setting_id;
- const struct settings_list *setting = find_setting(
- temp->variable,
- &setting_id);
- if (setting)
- {
- if ((setting->flags&F_BOOL_SETTING) == F_BOOL_SETTING)
- {
- bool temp_var, *var;
- bool show_icons = global_settings.show_icons;
- if (setting->flags&F_TEMPVAR)
- {
- temp_var = *(bool*)setting->setting;
- var = &temp_var;
- }
- else
- {
- var = (bool*)setting->setting;
- }
- set_bool_options(str(setting->lang_id),var,
- STR(setting->bool_setting->lang_yes),
- STR(setting->bool_setting->lang_no),
- setting->bool_setting->option_callback);
- if (setting->flags&F_TEMPVAR)
- *(bool*)setting->setting = temp_var;
- if (show_icons != global_settings.show_icons)
- init_menu_lists(menu, &lists, 0, true);
- }
- else if (setting->flags&F_T_SOUND)
- {
- set_sound(str(setting->lang_id), setting->setting,
- setting->sound_setting->setting);
- }
- else /* other setting, must be an INT type */
- {
- int temp_var, *var;
- if (setting->flags&F_TEMPVAR)
- {
- temp_var = *(int*)setting->setting;
- var = &temp_var;
- }
- else
- {
- var = (int*)setting->setting;
- }
- if (setting->flags&F_INT_SETTING)
- {
- set_int_ex(str(setting->lang_id),
- NULL,
- setting->int_setting->unit,var,
- setting->int_setting->option_callback,
- setting->int_setting->step,
- setting->int_setting->min,
- setting->int_setting->max,
- setting->int_setting->formatter,
- setting->int_setting->get_talk_id);
- }
- else if (setting->flags&F_CHOICE_SETTING)
- {
- static struct opt_items options[MAX_OPTIONS];
- char buffer[256];
- char *buf_start = buffer;
- int buf_free = 256;
- int i,j, count = setting->choice_setting->count;
- for (i=0, j=0; i<count && i<MAX_OPTIONS; i++)
- {
- if (setting->flags&F_CHOICETALKS)
- {
- if (cfg_int_to_string(setting_id, i,
- buf_start, buf_free))
- {
- int len = strlen(buf_start) +1;
- options[j].string = buf_start;
- buf_start += len;
- buf_free -= len;
- options[j].voice_id =
- setting->choice_setting->talks[i];
- j++;
- }
- }
- else
- {
- options[j].string =
- P2STR(setting->
- choice_setting->desc[i]);
- options[j].voice_id =
- P2ID(setting->
- choice_setting->desc[i]);
- j++;
- }
- }
- set_option(str(setting->lang_id), var, INT,
- options,j,
- setting->
- choice_setting->option_callback);
- }
- if (setting->flags&F_TEMPVAR)
- *(int*)setting->setting = temp_var;
- }
- }
+ if (do_setting_from_menu(temp))
+ init_menu_lists(menu, &lists, 0, true);
break;
}
case MT_RETURN_ID:
diff --git a/apps/menu.h b/apps/menu.h
index 3555cd2de6..c7d6cdbeed 100644
--- a/apps/menu.h
+++ b/apps/menu.h
@@ -72,9 +72,12 @@ struct menu_func_with_param {
};
#define MENU_TYPE_MASK 0xF /* MT_* type */
+/* these next two are mutually exclusive */
#define MENU_HAS_DESC 0x10
-#define MENU_COUNT_MASK (~(MENU_TYPE_MASK|MENU_HAS_DESC)) /* unless we need more flags*/
-#define MENU_COUNT_SHIFT 5
+#define MENU_DYNAMIC_DESC 0x20
+/* unless we need more flags*/
+#define MENU_COUNT_MASK (~(MENU_TYPE_MASK|MENU_HAS_DESC|MENU_DYNAMIC_DESC))
+#define MENU_COUNT_SHIFT 6
struct menu_item_ex {
int flags; /* above defines */
@@ -88,7 +91,9 @@ struct menu_item_ex {
const char **strings; /* used with MT_RETURN_ID */
};
union {
+ /* For settings */
int (*menu_callback)(int action, const struct menu_item_ex *this_item);
+ /* For everything else, except if the text is dynamic */
const struct menu_callback_with_desc {
int (*menu_callback)(int action,
const struct menu_item_ex *this_item);
@@ -97,12 +102,23 @@ struct menu_item_ex {
ICON icon; /* Icon to display */
#endif
} *callback_and_desc;
+ /* For when the item text is dynamic */
+ const struct menu_get_name_and_icon {
+ int (*menu_callback)(int action,
+ const struct menu_item_ex *this_item);
+ char *(*list_get_name)(int selected_item, void * data, char *buffer);
+ void *list_get_name_data;
+#ifdef HAVE_LCD_BITMAP
+ ICON icon; /* Icon to display */
+#endif
+ } *menu_get_name_and_icon;
};
};
typedef int (*menu_callback_type)(int action,
const struct menu_item_ex *this_item);
int do_menu(const struct menu_item_ex *menu);
+bool do_setting_from_menu(const struct menu_item_ex *temp);
#define MENU_ITEM_COUNT(c) (c<<MENU_COUNT_SHIFT)
/* In all the following macros the argument names are as follows:
@@ -152,6 +168,17 @@ int do_menu(const struct menu_item_ex *menu);
{ MT_FUNCTION_WITH_PARAM|MENU_HAS_DESC, \
{ .func_with_param = &name##__}, \
{.callback_and_desc = & name##_}};
+
+/* As above, except the text is dynamic */
+#define MENUITEM_FUNCTION_WPARAM_DYNTEXT(name, func, param, callback, \
+ text_callback, text_cb_data, icon) \
+ static const struct menu_get_name_and_icon name##_ \
+ = {callback,text_callback,text_cb_data,icon};\
+ static const struct menu_func_with_param name##__ = {func, param}; \
+ static const struct menu_item_ex name = \
+ { MT_FUNCTION_WITH_PARAM|MENU_DYNAMIC_DESC, \
+ { .func_with_param = &name##__}, \
+ {.menu_get_name_and_icon = & name##_}};
/* Use this to actually create a menu. the ... argument is a list of pointers
to any of the above macro'd variables. (It can also have other menus in the list. */
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
new file mode 100644
index 0000000000..8473b6b233
--- /dev/null
+++ b/apps/menus/eq_menu.c
@@ -0,0 +1,787 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id: eq_menu.c 12179 2007-02-01 23:08:15Z amiconn $
+ *
+ * Copyright (C) 2006 Dan Everton
+ *
+ * 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 "config.h"
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+#include "eq_menu.h"
+#include "system.h"
+#include "kernel.h"
+#include "lcd.h"
+#include "menu.h"
+#include "action.h"
+#include "mp3_playback.h"
+#include "settings.h"
+#include "statusbar.h"
+#include "screens.h"
+#include "icons.h"
+#include "font.h"
+#include "lang.h"
+#include "sprintf.h"
+#include "talk.h"
+#include "misc.h"
+#include "sound.h"
+#include "splash.h"
+#include "dsp.h"
+#include "tree.h"
+#include "talk.h"
+#include "screen_access.h"
+#include "keyboard.h"
+#include "gui/scrollbar.h"
+#include "eq_menu.h"
+#ifdef HAVE_WM8758
+#include "wm8758.h"
+#endif
+
+
+
+/*
+ * Utility functions
+ */
+
+void eq_gain_format(char* buffer, int buffer_size, int value, const char* unit)
+{
+ int v = abs(value);
+
+ snprintf(buffer, buffer_size, "%s%d.%d %s", value < 0 ? "-" : "",
+ v / EQ_USER_DIVISOR, v % EQ_USER_DIVISOR, unit);
+}
+
+void eq_q_format(char* buffer, int buffer_size, int value, const char* unit)
+{
+ snprintf(buffer, buffer_size, "%d.%d %s", value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
+}
+
+void eq_precut_format(char* buffer, int buffer_size, int value, const char* unit)
+{
+ snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-",
+ value / EQ_USER_DIVISOR, value % EQ_USER_DIVISOR, unit);
+}
+
+/*
+ * Settings functions
+ */
+int enable_callback(int action, const struct menu_item_ex *this_item)
+{
+ int i;
+ (void)this_item;
+ if (action == ACTION_EXIT_MENUITEM)
+ {
+ dsp_set_eq(global_settings.eq_enabled);
+ dsp_set_eq_precut(global_settings.eq_precut);
+ /* Update all bands */
+ for(i = 0; i < 5; i++) {
+ dsp_set_eq_coefs(i);
+ }
+ }
+ return action;
+}
+MENUITEM_SETTING(eq_enable, &global_settings.eq_enabled, enable_callback);
+MENUITEM_SETTING(eq_precut, &global_settings.eq_precut, NULL);
+
+int dsp_set_coefs_callback(int action, const struct menu_item_ex *this_item)
+{
+ (void)this_item;
+ if (action == ACTION_EXIT_MENUITEM)
+ {
+ /* for now, set every band... figure out a better way later */
+ int i=0;
+ for (i=0; i<5; i++)
+ dsp_set_eq_coefs(i);
+ }
+ return action;
+}
+
+char* gainitem_get_name(int selected_item, void * data, char *buffer)
+{
+ (void)selected_item;
+ int *setting = (int*)data;
+ snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_GAIN_ITEM), *setting);
+ return buffer;
+}
+
+int do_option(void* param)
+{
+ const struct menu_item_ex *setting = (const struct menu_item_ex*)param;
+ do_setting_from_menu(setting);
+ return 0;
+}
+
+MENUITEM_SETTING(cutoff_0, &global_settings.eq_band0_cutoff, dsp_set_coefs_callback);
+MENUITEM_SETTING(cutoff_1, &global_settings.eq_band1_cutoff, dsp_set_coefs_callback);
+MENUITEM_SETTING(cutoff_2, &global_settings.eq_band2_cutoff, dsp_set_coefs_callback);
+MENUITEM_SETTING(cutoff_3, &global_settings.eq_band3_cutoff, dsp_set_coefs_callback);
+MENUITEM_SETTING(cutoff_4, &global_settings.eq_band4_cutoff, dsp_set_coefs_callback);
+
+MENUITEM_SETTING(q_0, &global_settings.eq_band0_q, dsp_set_coefs_callback);
+MENUITEM_SETTING(q_1, &global_settings.eq_band1_q, dsp_set_coefs_callback);
+MENUITEM_SETTING(q_2, &global_settings.eq_band2_q, dsp_set_coefs_callback);
+MENUITEM_SETTING(q_3, &global_settings.eq_band3_q, dsp_set_coefs_callback);
+MENUITEM_SETTING(q_4, &global_settings.eq_band4_q, dsp_set_coefs_callback);
+
+MENUITEM_SETTING(gain_0, &global_settings.eq_band0_gain, dsp_set_coefs_callback);
+MENUITEM_SETTING(gain_1, &global_settings.eq_band1_gain, dsp_set_coefs_callback);
+MENUITEM_SETTING(gain_2, &global_settings.eq_band2_gain, dsp_set_coefs_callback);
+MENUITEM_SETTING(gain_3, &global_settings.eq_band3_gain, dsp_set_coefs_callback);
+MENUITEM_SETTING(gain_4, &global_settings.eq_band4_gain, dsp_set_coefs_callback);
+
+MENUITEM_FUNCTION_WPARAM_DYNTEXT(gain_item_0, do_option, (void*)&gain_0, NULL,
+ gainitem_get_name,
+ &global_settings.eq_band0_cutoff, NOICON);
+MENUITEM_FUNCTION_WPARAM_DYNTEXT(gain_item_1, do_option, (void*)&gain_1, NULL,
+ gainitem_get_name,
+ &global_settings.eq_band1_cutoff, NOICON);
+MENUITEM_FUNCTION_WPARAM_DYNTEXT(gain_item_2, do_option, (void*)&gain_2, NULL,
+ gainitem_get_name,
+ &global_settings.eq_band2_cutoff, NOICON);
+MENUITEM_FUNCTION_WPARAM_DYNTEXT(gain_item_3, do_option, (void*)&gain_3, NULL,
+ gainitem_get_name,
+ &global_settings.eq_band3_cutoff, NOICON);
+MENUITEM_FUNCTION_WPARAM_DYNTEXT(gain_item_4, do_option, (void*)&gain_4, NULL,
+ gainitem_get_name,
+ &global_settings.eq_band4_cutoff, NOICON);
+
+MAKE_MENU(gain_menu, ID2P(LANG_EQUALIZER_GAIN), NULL, NOICON, &gain_item_0,
+ &gain_item_1, &gain_item_2, &gain_item_3, &gain_item_4);
+
+static const struct menu_item_ex *band_items[3][3] = {
+ { &cutoff_1, &q_1, &gain_1 },
+ { &cutoff_2, &q_2, &gain_2 },
+ { &cutoff_3, &q_3, &gain_3 }
+};
+char* centerband_get_name(int selected_item, void * data, char *buffer)
+{
+ (void)selected_item;
+ int band = (int)data;
+ snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_BAND_PEAK), band);
+ return buffer;
+}
+int do_center_band_menu(void* param)
+{
+ int band = (int)param;
+ struct menu_item_ex menu;
+ struct menu_callback_with_desc cb_and_desc;
+ char desc[MAX_PATH];
+
+ cb_and_desc.menu_callback = NULL;
+ snprintf(desc, MAX_PATH, str(LANG_EQUALIZER_BAND_PEAK), band);
+ cb_and_desc.desc = desc;
+ cb_and_desc.icon = bitmap_icons_6x8[Icon_EQ];
+ menu.flags = MT_MENU|(3<<MENU_COUNT_SHIFT)|MENU_HAS_DESC;
+ menu.submenus = band_items[band-1];
+ menu.callback_and_desc = &cb_and_desc;
+ do_menu(&menu);
+ return 0;
+}
+MAKE_MENU(band_0_menu, ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), NULL,
+ bitmap_icons_6x8[Icon_EQ], &cutoff_0, &q_0, &gain_0);
+MENUITEM_FUNCTION_WPARAM_DYNTEXT(band_1_menu, do_center_band_menu, (void*)1, NULL,
+ centerband_get_name, (void*)1, bitmap_icons_6x8[Icon_EQ]);
+MENUITEM_FUNCTION_WPARAM_DYNTEXT(band_2_menu, do_center_band_menu, (void*)2, NULL,
+ centerband_get_name, (void*)2, bitmap_icons_6x8[Icon_EQ]);
+MENUITEM_FUNCTION_WPARAM_DYNTEXT(band_3_menu, do_center_band_menu, (void*)3, NULL,
+ centerband_get_name, (void*)3, bitmap_icons_6x8[Icon_EQ]);
+MAKE_MENU(band_4_menu, ID2P(LANG_EQUALIZER_BAND_HIGH_SHELF), NULL,
+ bitmap_icons_6x8[Icon_EQ], &cutoff_4, &q_4, &gain_4);
+
+MAKE_MENU(advanced_eq_menu_, ID2P(LANG_EQUALIZER_ADVANCED), NULL, bitmap_icons_6x8[Icon_EQ],
+ &band_0_menu, &band_1_menu, &band_2_menu, &band_3_menu, &band_4_menu);
+
+
+enum eq_slider_mode {
+ GAIN,
+ CUTOFF,
+ Q,
+};
+
+enum eq_type {
+ LOW_SHELF,
+ PEAK,
+ HIGH_SHELF
+};
+
+/* Draw the UI for a whole EQ band */
+static int draw_eq_slider(struct screen * screen, int x, int y,
+ int width, int cutoff, int q, int gain, bool selected,
+ enum eq_slider_mode mode, enum eq_type type)
+{
+ char buf[26];
+ const char separator[2] = " ";
+ int steps, min_item, max_item;
+ int abs_gain = abs(gain);
+ int current_x, total_height, separator_width, separator_height;
+ int w, h;
+ const int slider_height = 6;
+
+ switch(mode) {
+ case Q:
+ steps = EQ_Q_MAX - EQ_Q_MIN;
+ min_item = q - EQ_Q_STEP - EQ_Q_MIN;
+ max_item = q + EQ_Q_STEP - EQ_Q_MIN;
+ break;
+ case CUTOFF:
+ steps = EQ_CUTOFF_MAX - EQ_CUTOFF_MIN;
+ min_item = cutoff - EQ_CUTOFF_FAST_STEP * 2;
+ max_item = cutoff + EQ_CUTOFF_FAST_STEP * 2;
+ break;
+ case GAIN:
+ default:
+ steps = EQ_GAIN_MAX - EQ_GAIN_MIN;
+ min_item = abs(EQ_GAIN_MIN) + gain - EQ_GAIN_STEP * 5;
+ max_item = abs(EQ_GAIN_MIN) + gain + EQ_GAIN_STEP * 5;
+ break;
+ }
+
+ /* Start two pixels in, one for border, one for margin */
+ current_x = x + 2;
+
+ /* Figure out how large our separator string is */
+ screen->getstringsize(separator, &separator_width, &separator_height);
+
+ /* Total height includes margins, text, and line selector */
+ total_height = separator_height + slider_height + 2 + 3;
+
+ /* Print out the band label */
+ if (type == LOW_SHELF) {
+ screen->putsxy(current_x, y + 2, "LS:");
+ screen->getstringsize("LS:", &w, &h);
+ } else if (type == HIGH_SHELF) {
+ screen->putsxy(current_x, y + 2, "HS:");
+ screen->getstringsize("HS:", &w, &h);
+ } else {
+ screen->putsxy(current_x, y + 2, "PK:");
+ screen->getstringsize("PK:", &w, &h);
+ }
+ current_x += w;
+
+ /* Print separator */
+ screen->set_drawmode(DRMODE_SOLID);
+ screen->putsxy(current_x, y + 2, separator);
+ current_x += separator_width;
+#if NB_SCREENS > 1
+ if (screen->screen_type == SCREEN_REMOTE) {
+ if (mode == GAIN) {
+ screen->putsxy(current_x, y + 2, str(LANG_EQUALIZER_BAND_GAIN));
+ screen->getstringsize(str(LANG_EQUALIZER_BAND_GAIN), &w, &h);
+ } else if (mode == CUTOFF) {
+ screen->putsxy(current_x, y + 2, str(LANG_EQUALIZER_BAND_CUTOFF));
+ screen->getstringsize(str(LANG_EQUALIZER_BAND_CUTOFF), &w, &h);
+ } else {
+ screen->putsxy(current_x, y + 2, str(LANG_EQUALIZER_BAND_Q));
+ screen->getstringsize(str(LANG_EQUALIZER_BAND_Q), &w, &h);
+ }
+
+ /* Draw horizontal slider. Reuse scrollbar for this */
+ gui_scrollbar_draw(screen, x + 3, y + h + 3, width - 6, slider_height, steps,
+ min_item, max_item, HORIZONTAL);
+
+ /* Print out cutoff part */
+ snprintf(buf, sizeof(buf), "%sGain %s%2d.%ddB",mode==GAIN?" > ":" ", gain < 0 ? "-" : " ",
+ abs_gain / EQ_USER_DIVISOR, abs_gain % EQ_USER_DIVISOR);
+ screen->getstringsize(buf, &w, &h);
+ y = 3*h;
+ screen->putsxy(0, y, buf);
+ /* Print out cutoff part */
+ snprintf(buf, sizeof(buf), "%sCutoff %5dHz",mode==CUTOFF?" > ":" ", cutoff);
+ y += h;
+ screen->putsxy(0, y, buf);
+ snprintf(buf, sizeof(buf), "%sQ setting %d.%d Q",mode==Q?" > ":" ", q / EQ_USER_DIVISOR,
+ q % EQ_USER_DIVISOR);
+ y += h;
+ screen->putsxy(0, y, buf);
+ return y;
+ }
+#endif
+
+ /* Print out gain part of status line */
+ snprintf(buf, sizeof(buf), "%s%2d.%ddB", gain < 0 ? "-" : " ",
+ abs_gain / EQ_USER_DIVISOR, abs_gain % EQ_USER_DIVISOR);
+
+ if (mode == GAIN && selected)
+ screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
+
+ screen->putsxy(current_x, y + 2, buf);
+ screen->getstringsize(buf, &w, &h);
+ current_x += w;
+
+ /* Print separator */
+ screen->set_drawmode(DRMODE_SOLID);
+ screen->putsxy(current_x, y + 2, separator);
+ current_x += separator_width;
+
+ /* Print out cutoff part of status line */
+ snprintf(buf, sizeof(buf), "%5dHz", cutoff);
+
+ if (mode == CUTOFF && selected)
+ screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
+
+ screen->putsxy(current_x, y + 2, buf);
+ screen->getstringsize(buf, &w, &h);
+ current_x += w;
+
+ /* Print separator */
+ screen->set_drawmode(DRMODE_SOLID);
+ screen->putsxy(current_x, y + 2, separator);
+ current_x += separator_width;
+
+ /* Print out Q part of status line */
+ snprintf(buf, sizeof(buf), "%d.%d Q", q / EQ_USER_DIVISOR,
+ q % EQ_USER_DIVISOR);
+
+ if (mode == Q && selected)
+ screen->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
+
+ screen->putsxy(current_x, y + 2, buf);
+ screen->getstringsize(buf, &w, &h);
+ current_x += w;
+
+ screen->set_drawmode(DRMODE_SOLID);
+
+ /* Draw selection box */
+ if (selected) {
+ screen->drawrect(x, y, width, total_height);
+ }
+
+ /* Draw horizontal slider. Reuse scrollbar for this */
+ gui_scrollbar_draw(screen, x + 3, y + h + 3, width - 6, slider_height, steps,
+ min_item, max_item, HORIZONTAL);
+
+ return total_height;
+}
+
+/* Draw's all the EQ sliders. Returns the total height of the sliders drawn */
+static int draw_eq_sliders(int current_band, enum eq_slider_mode mode)
+{
+ int i, gain, q, cutoff;
+ int height = 2; /* Two pixel margin */
+ int slider_width[NB_SCREENS];
+ int *setting = &global_settings.eq_band0_cutoff;
+ enum eq_type type;
+
+ FOR_NB_SCREENS(i)
+ slider_width[i] = screens[i].width - 4; /* two pixel margin on each side */
+
+ for (i=0; i<5; i++) {
+ cutoff = *setting++;
+ q = *setting++;
+ gain = *setting++;
+
+ if (i == 0) {
+ type = LOW_SHELF;
+ } else if (i == 4) {
+ type = HIGH_SHELF;
+ } else {
+ type = PEAK;
+ }
+ height += draw_eq_slider(&(screens[SCREEN_MAIN]), 2, height,
+ slider_width[SCREEN_MAIN], cutoff, q, gain,
+ i == current_band, mode, type);
+#if NB_SCREENS > 1
+ if (i == current_band)
+ draw_eq_slider(&(screens[SCREEN_REMOTE]), 2, 0,
+ slider_width[SCREEN_REMOTE], cutoff, q, gain,1, mode, type);
+#endif
+ /* add a margin */
+ height += 2;
+ }
+
+ return height;
+}
+
+/* Provides a graphical means of editing the EQ settings */
+bool eq_menu_graphical(void)
+{
+ bool exit_request = false;
+ bool result = true;
+ bool has_changed = false;
+ int button;
+ int *setting;
+ int current_band, y, step, fast_step, min, max, voice_unit;
+ enum eq_slider_mode mode;
+ enum eq_type current_type;
+ char buf[24];
+ int i;
+
+ FOR_NB_SCREENS(i) {
+ screens[i].setfont(FONT_SYSFIXED);
+ screens[i].clear_display();
+ }
+
+ /* Start off editing gain on the first band */
+ mode = GAIN;
+ current_type = LOW_SHELF;
+ current_band = 0;
+
+ while (!exit_request) {
+
+ FOR_NB_SCREENS(i) {
+ /* Clear the screen. The drawing routines expect this */
+ screens[i].clear_display();
+ /* Draw equalizer band details */
+ y = draw_eq_sliders(current_band, mode);
+ }
+
+ /* Set pointer to the band data currently editable */
+ if (mode == GAIN) {
+ /* gain */
+ setting = &global_settings.eq_band0_gain;
+ setting += current_band * 3;
+
+ step = EQ_GAIN_STEP;
+ fast_step = EQ_GAIN_FAST_STEP;
+ min = EQ_GAIN_MIN;
+ max = EQ_GAIN_MAX;
+ voice_unit = UNIT_DB;
+
+ snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
+ str(LANG_SYSFONT_EQUALIZER_BAND_GAIN));
+
+ screens[SCREEN_MAIN].putsxy(2, y, buf);
+ } else if (mode == CUTOFF) {
+ /* cutoff */
+ setting = &global_settings.eq_band0_cutoff;
+ setting += current_band * 3;
+
+ step = EQ_CUTOFF_STEP;
+ fast_step = EQ_CUTOFF_FAST_STEP;
+ min = EQ_CUTOFF_MIN;
+ max = EQ_CUTOFF_MAX;
+ voice_unit = UNIT_HERTZ;
+
+ snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
+ str(LANG_SYSFONT_EQUALIZER_BAND_CUTOFF));
+
+ screens[SCREEN_MAIN].putsxy(2, y, buf);
+ } else {
+ /* Q */
+ setting = &global_settings.eq_band0_q;
+ setting += current_band * 3;
+
+ step = EQ_Q_STEP;
+ fast_step = EQ_Q_FAST_STEP;
+ min = EQ_Q_MIN;
+ max = EQ_Q_MAX;
+ voice_unit = UNIT_INT;
+
+ snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
+ str(LANG_EQUALIZER_BAND_Q));
+
+ screens[SCREEN_MAIN].putsxy(2, y, buf);
+ }
+
+ FOR_NB_SCREENS(i) {
+ screens[i].update();
+ }
+
+ button = get_action(CONTEXT_SETTINGS_EQ,TIMEOUT_BLOCK);
+
+ switch (button) {
+ case ACTION_SETTINGS_DEC:
+ case ACTION_SETTINGS_DECREPEAT:
+ *(setting) -= step;
+ has_changed = true;
+ if (*(setting) < min)
+ *(setting) = min;
+ break;
+
+ case ACTION_SETTINGS_INC:
+ case ACTION_SETTINGS_INCREPEAT:
+ *(setting) += step;
+ has_changed = true;
+ if (*(setting) > max)
+ *(setting) = max;
+ break;
+
+ case ACTION_SETTINGS_INCBIGSTEP:
+ *(setting) += fast_step;
+ has_changed = true;
+ if (*(setting) > max)
+ *(setting) = max;
+ break;
+
+ case ACTION_SETTINGS_DECBIGSTEP:
+ *(setting) -= fast_step;
+ has_changed = true;
+ if (*(setting) < min)
+ *(setting) = min;
+ break;
+
+ case ACTION_STD_PREV:
+ case ACTION_STD_PREVREPEAT:
+ current_band--;
+ if (current_band < 0)
+ current_band = 4; /* wrap around */
+ break;
+
+ case ACTION_STD_NEXT:
+ case ACTION_STD_NEXTREPEAT:
+ current_band++;
+ if (current_band > 4)
+ current_band = 0; /* wrap around */
+ break;
+
+ case ACTION_STD_OK:
+ mode++;
+ if (mode > Q)
+ mode = GAIN; /* wrap around */
+ break;
+
+ case ACTION_STD_CANCEL:
+ exit_request = true;
+ result = false;
+ break;
+
+ default:
+ if(default_event_handler(button) == SYS_USB_CONNECTED) {
+ exit_request = true;
+ result = true;
+ }
+ break;
+ }
+
+ /* Update the filter if the user changed something */
+ if (has_changed) {
+ dsp_set_eq_coefs(current_band);
+ has_changed = false;
+ }
+ }
+
+ action_signalscreenchange();
+ /* Reset screen settings */
+ FOR_NB_SCREENS(i) {
+ screens[i].setfont(FONT_UI);
+ screens[i].clear_display();
+ }
+ return result;
+}
+
+/* Preset saver.
+ * TODO: Can the settings system be used to do this instead?
+ */
+static bool eq_save_preset(void)
+{
+ int fd, i;
+ char filename[MAX_PATH];
+ int *setting;
+
+ create_numbered_filename(filename, EQS_DIR, "eq", ".cfg", 2
+ IF_CNFN_NUM_(, NULL));
+
+ /* allow user to modify filename */
+ while (true) {
+ if (!kbd_input(filename, sizeof filename)) {
+ fd = creat(filename);
+ if (fd < 0)
+ gui_syncsplash(HZ, true, str(LANG_FAILED));
+ else
+ break;
+ }
+ else {
+ gui_syncsplash(HZ, true, str(LANG_MENU_SETTING_CANCEL));
+ return false;
+ }
+ }
+
+ /* TODO: Should we really do this? */
+ fdprintf(fd, "eq enabled: on\r\n");
+ fdprintf(fd, "eq precut: %d\r\n", global_settings.eq_precut);
+
+ setting = &global_settings.eq_band0_cutoff;
+
+ for(i = 0; i < 5; ++i) {
+ fdprintf(fd, "eq band %d cutoff: %d\r\n", i, *setting++);
+ fdprintf(fd, "eq band %d q: %d\r\n", i, *setting++);
+ fdprintf(fd, "eq band %d gain: %d\r\n", i, *setting++);
+ }
+
+ close(fd);
+
+ gui_syncsplash(HZ, true, str(LANG_SETTINGS_SAVED));
+
+ return true;
+}
+
+/* Allows browsing of preset files */
+bool eq_browse_presets(void)
+{
+ return rockbox_browse(EQS_DIR, SHOW_CFG);
+}
+
+
+MENUITEM_FUNCTION(eq_graphical, ID2P(LANG_EQUALIZER_GRAPHICAL),
+ (int(*)(void))eq_menu_graphical, NULL,
+ bitmap_icons_6x8[Icon_EQ]);
+MENUITEM_FUNCTION(eq_save, ID2P(LANG_EQUALIZER_SAVE),
+ (int(*)(void))eq_save_preset, NULL, NOICON);
+MENUITEM_FUNCTION(eq_browse, ID2P(LANG_EQUALIZER_BROWSE),
+ (int(*)(void))eq_browse_presets, NULL, NOICON);
+
+MAKE_MENU(equalizer_menu, ID2P(LANG_EQUALIZER), NULL, bitmap_icons_6x8[Icon_EQ],
+ &eq_enable, &eq_graphical, &eq_precut, &gain_menu,
+ &advanced_eq_menu_, &eq_save, &eq_browse);
+
+
+#ifdef HAVE_WM8758
+
+void eq_hw_gain_format(char* buffer, int buffer_size, int value,
+ const char* unit)
+{
+ snprintf(buffer, buffer_size, "%d %s", value, unit);
+}
+
+static int band0_callback(int action, const struct menu_item_ex *this_item)
+{
+ (void)this_item;
+ if (action == ACTION_EXIT_MENUITEM)
+ {
+#ifndef SIMULATOR
+ audiohw_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff, 0,
+ global_settings.eq_hw_band0_gain);
+#endif
+ }
+ return action;
+}
+static int band1_callback(int action, const struct menu_item_ex *this_item)
+{
+ (void)this_item;
+ if (action == ACTION_EXIT_MENUITEM)
+ {
+#ifndef SIMULATOR
+ audiohw_set_equalizer_band(1, global_settings.eq_hw_band1_center,
+ global_settings.eq_hw_band1_bandwidth,
+ global_settings.eq_hw_band1_gain);
+#endif
+ }
+ return action;
+}
+static int band2_callback(int action, const struct menu_item_ex *this_item)
+{
+ (void)this_item;
+ if (action == ACTION_EXIT_MENUITEM)
+ {
+#ifndef SIMULATOR
+ audiohw_set_equalizer_band(2, global_settings.eq_hw_band2_center,
+ global_settings.eq_hw_band2_bandwidth,
+ global_settings.eq_hw_band2_gain);
+#endif
+ }
+ return action;
+}
+static int band3_callback(int action, const struct menu_item_ex *this_item)
+{
+ (void)this_item;
+ if (action == ACTION_EXIT_MENUITEM)
+ {
+#ifndef SIMULATOR
+ audiohw_set_equalizer_band(3, global_settings.eq_hw_band3_center,
+ global_settings.eq_hw_band3_bandwidth,
+ global_settings.eq_hw_band3_gain);
+#endif
+ }
+ return action;
+}
+static int band4_callback(int action, const struct menu_item_ex *this_item)
+{
+ (void)this_item;
+ if (action == ACTION_EXIT_MENUITEM)
+ {
+#ifndef SIMULATOR
+ audiohw_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff, 0,
+ global_settings.eq_hw_band4_gain);
+#endif
+ }
+ return action;
+}
+void eq_hw_enable(bool enable)
+{
+#ifdef SIMULATOR
+ (void) enable;
+#else
+ if (enable) {
+ audiohw_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff,
+ 0, global_settings.eq_hw_band0_gain);
+ audiohw_set_equalizer_band(1, global_settings.eq_hw_band1_center,
+ global_settings.eq_hw_band1_bandwidth,
+ global_settings.eq_hw_band1_gain);
+ audiohw_set_equalizer_band(2, global_settings.eq_hw_band2_center,
+ global_settings.eq_hw_band2_bandwidth,
+ global_settings.eq_hw_band2_gain);
+ audiohw_set_equalizer_band(3, global_settings.eq_hw_band3_center,
+ global_settings.eq_hw_band3_bandwidth,
+ global_settings.eq_hw_band3_gain);
+ audiohw_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff,
+ 0, global_settings.eq_hw_band4_gain);
+ } else {
+ audiohw_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff, 0, 0);
+ audiohw_set_equalizer_band(1, global_settings.eq_hw_band1_center,
+ global_settings.eq_hw_band1_bandwidth, 0);
+ audiohw_set_equalizer_band(2, global_settings.eq_hw_band2_center,
+ global_settings.eq_hw_band2_bandwidth, 0);
+ audiohw_set_equalizer_band(3, global_settings.eq_hw_band3_center,
+ global_settings.eq_hw_band3_bandwidth, 0);
+ audiohw_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff, 0, 0);
+ }
+#endif
+}
+static int hweq_enable_callback(int action, const struct menu_item_ex *this_item)
+{
+ (void)this_item;
+ if (action == ACTION_EXIT_MENUITEM)
+ {
+ eq_hw_enable(global_settings.eq_hw_enabled);
+ }
+ return action;
+}
+MENUITEM_SETTING(hw_eq_enable, &global_settings.eq_hw_enabled, hweq_enable_callback);
+
+MENUITEM_SETTING(hw_eq_cutoff_0, &global_settings.eq_hw_band0_cutoff, band0_callback);
+MENUITEM_SETTING(hw_eq_gain_0, &global_settings.eq_hw_band0_gain, band0_callback);
+MAKE_MENU(hw_eq_band0, ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), NULL, NOICON,
+ &hw_eq_cutoff_0, &hw_eq_gain_0);
+
+MENUITEM_SETTING(hw_eq_cutoff_1, &global_settings.eq_hw_band1_center, band1_callback);
+MENUITEM_SETTING(hw_eq_bandwidth_1, &global_settings.eq_hw_band1_bandwidth, band1_callback);
+MENUITEM_SETTING(hw_eq_gain_1, &global_settings.eq_hw_band1_gain, band1_callback);
+MAKE_MENU(hw_eq_band1, "Peak Filter 1", NULL, NOICON,
+ &hw_eq_cutoff_1, &hw_eq_bandwidth_1, &hw_eq_gain_1);
+
+MENUITEM_SETTING(hw_eq_cutoff_2, &global_settings.eq_hw_band2_center, band2_callback);
+MENUITEM_SETTING(hw_eq_bandwidth_2, &global_settings.eq_hw_band2_bandwidth, band2_callback);
+MENUITEM_SETTING(hw_eq_gain_2, &global_settings.eq_hw_band2_gain, band2_callback);
+MAKE_MENU(hw_eq_band2, "Peak Filter 2", NULL, NOICON,
+ &hw_eq_cutoff_2, &hw_eq_bandwidth_2, &hw_eq_gain_2);
+
+MENUITEM_SETTING(hw_eq_cutoff_3, &global_settings.eq_hw_band3_center, band3_callback);
+MENUITEM_SETTING(hw_eq_bandwidth_3, &global_settings.eq_hw_band3_bandwidth, band3_callback);
+MENUITEM_SETTING(hw_eq_gain_3, &global_settings.eq_hw_band3_gain, band3_callback);
+MAKE_MENU(hw_eq_band3, "Peak Filter 3", NULL, NOICON,
+ &hw_eq_cutoff_3, &hw_eq_bandwidth_3, &hw_eq_gain_3);
+
+MENUITEM_SETTING(hw_eq_cutoff_4, &global_settings.eq_hw_band4_cutoff, band4_callback);
+MENUITEM_SETTING(hw_eq_gain_4, &global_settings.eq_hw_band4_gain, band4_callback);
+MAKE_MENU(hw_eq_band4, ID2P(LANG_EQUALIZER_BAND_HIGH_SHELF), NULL, NOICON,
+ &hw_eq_cutoff_4, &hw_eq_gain_4);
+
+MAKE_MENU(hw_eq_menu, ID2P(LANG_EQUALIZER_HARDWARE), NULL, bitmap_icons_6x8[Icon_EQ],
+ &hw_eq_enable, &hw_eq_band0, &hw_eq_band1,
+ &hw_eq_band2, &hw_eq_band3, &hw_eq_band4);
+
+
+#endif
diff --git a/apps/eq_menu.h b/apps/menus/eq_menu.h
index e432ea91e3..8f3cb834d8 100644
--- a/apps/eq_menu.h
+++ b/apps/menus/eq_menu.h
@@ -5,7 +5,7 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
- * $Id$
+ * $Id: eq_menu.h 10888 2006-09-05 11:48:17Z dan $
*
* Copyright (C) 2006 Dan Everton
*
@@ -21,11 +21,37 @@
#include "menu.h"
#include "config.h"
+/* Various user interface limits and sizes */
+#define EQ_CUTOFF_MIN 20
+#define EQ_CUTOFF_MAX 22040
+#define EQ_CUTOFF_STEP 10
+#define EQ_CUTOFF_FAST_STEP 100
+#define EQ_GAIN_MIN (-240)
+#define EQ_GAIN_MAX 240
+#define EQ_GAIN_STEP 5
+#define EQ_GAIN_FAST_STEP 10
+#define EQ_Q_MIN 5
+#define EQ_Q_MAX 64
+#define EQ_Q_STEP 1
+#define EQ_Q_FAST_STEP 10
+
+#define EQ_USER_DIVISOR 10
bool eq_browse_presets(void);
bool eq_menu_graphical(void);
-bool eq_menu(void);
+
+/* utility functions for settings_list.c */
+void eq_gain_format(char* buffer, int buffer_size, int value, const char* unit);
+void eq_q_format(char* buffer, int buffer_size, int value, const char* unit);
+void eq_precut_format(char* buffer, int buffer_size, int value, const char* unit);
#ifdef HAVE_WM8758
+void eq_hw_gain_format(char* buffer, int buffer_size, int value,
+ const char* unit);
+/* WM8758 equalizer supports -12 to +12 dB gain in 1 dB increments. */
+#define EQ_HW_GAIN_STEP 1
+#define EQ_HW_GAIN_MIN -12
+#define EQ_HW_GAIN_MAX 12
+
bool eq_hw_menu(void);
void eq_hw_enable(bool enable);
#endif
diff --git a/apps/menus/exported_menus.h b/apps/menus/exported_menus.h
index d2023771a8..ec5a28af21 100644
--- a/apps/menus/exported_menus.h
+++ b/apps/menus/exported_menus.h
@@ -32,7 +32,12 @@ extern const struct menu_item_ex
#endif
sound_settings, /* sound_menu.c */
settings_menu_item, /* settings_menu.c */
- playlist_menu_item; /* playlist_menu.c */
+ playlist_menu_item, /* playlist_menu.c */
+ equalizer_menu; /* eq_menu.c */
+
+#ifdef HAVE_WM8758
+extern const struct menu_item_ex hw_eq_menu; /* eq_menu.c */
+#endif
diff --git a/apps/menus/sound_menu.c b/apps/menus/sound_menu.c
index a8e86a7eed..fd366f1176 100644
--- a/apps/menus/sound_menu.c
+++ b/apps/menus/sound_menu.c
@@ -31,6 +31,7 @@
#if CONFIG_CODEC == SWCODEC
#include "pcmbuf.h"
#endif
+#include "exported_menus.h"
/***********************************/
/* SOUND MENU */
@@ -79,14 +80,8 @@ MENUITEM_SETTING(stereo_width, &global_settings.stereo_width, soundmenu_callback
&crossfeed, &crossfeed_direct_gain, &crossfeed_cross_gain,
&crossfeed_hf_attenuation, &crossfeed_hf_cutoff);
- MENUITEM_FUNCTION(equalizer_menu, ID2P(LANG_EQUALIZER),
- (int(*)(void))eq_menu, NULL, NOICON);
MENUITEM_SETTING(dithering_enabled,
&global_settings.dithering_enabled, soundmenu_callback);
-#ifdef HAVE_WM8758
- MENUITEM_FUNCTION(hw_equalizer_menu, ID2P(LANG_EQUALIZER_HARDWARE),
- (int(*)(void))eq_hw_menu, NULL, NOICON);
-#endif
#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
@@ -109,10 +104,10 @@ MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, bitmap_icons_6x8[Icon
#endif
&balance,&channel_config,&stereo_width
#if CONFIG_CODEC == SWCODEC
- ,&crossfeed_menu, &equalizer_menu,&dithering_enabled
+ ,&crossfeed_menu, &equalizer_menu, &dithering_enabled
#endif
#ifdef HAVE_WM8758
- ,&hw_equalizer_menu
+ ,&hw_eq_menu
#endif
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
,&loudness,&avc,&superbass,&mdb_enable,&mdb_strength
diff --git a/apps/onplay.c b/apps/onplay.c
index 14fbdb8a17..18a0ff6e63 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -59,7 +59,7 @@
#include "main_menu.h"
#include "sound_menu.h"
#if CONFIG_CODEC == SWCODEC
-#include "eq_menu.h"
+#include "menus/eq_menu.h"
#endif
#include "playlist_menu.h"
#include "playlist_catalog.h"
diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c
index 3c66fbd129..8f2ecc4b80 100644
--- a/apps/recorder/icons.c
+++ b/apps/recorder/icons.c
@@ -78,6 +78,7 @@ const unsigned char bitmap_icons_6x8[][6] =
{ 0x03, 0x05, 0x7f, 0x05, 0x03, 0x00 }, /* radio */
#endif
{ 0x1f, 0x11, 0x7d, 0x46, 0x44, 0x78 }, /* File View Menu */
+ { 0x06, 0x7f, 0x06, 0x18, 0x7f, 0x18 }, /* EQ menu */
};
const unsigned char bitmap_icons_7x8[][7] =
diff --git a/apps/recorder/icons.h b/apps/recorder/icons.h
index a2a0e95aa6..782dc9a1e3 100644
--- a/apps/recorder/icons.h
+++ b/apps/recorder/icons.h
@@ -82,6 +82,7 @@ enum icons_6x8 {
Icon_Radio_screen,
#endif
Icon_file_view_menu,
+ Icon_EQ,
Icon6x8Last,
};
diff --git a/apps/settings.c b/apps/settings.c
index 2001c354d3..cb969e7fdf 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -89,7 +89,7 @@ const char rec_base_directory[] = REC_BASE_DIR;
#endif /* CONFIG_CODEC == SWCODEC */
#ifdef HAVE_WM8758
-#include "eq_menu.h"
+#include "menus/eq_menu.h"
#endif
#define NVRAM_BLOCK_SIZE 44
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 9f24c63a84..a505232643 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -42,6 +42,7 @@
#ifdef HAVE_LCD_BITMAP
#include "peakmeter.h"
#endif
+#include "menus/eq_menu.h"
/* some sets of values which are used more than once, to save memory */
static const char off_on[] = "off,on";
@@ -349,6 +350,7 @@ static long jumpscroll_getlang(int value)
return -1;
}
#endif /* HAVE_LCD_CHARCELLS */
+
const struct settings_list settings[] = {
/* sound settings */
@@ -857,41 +859,56 @@ const struct settings_list settings[] = {
crossfeed_format, NULL, crossfeed_hf_cutoff_helper),
/* equalizer */
OFFON_SETTING(0,eq_enabled,LANG_EQUALIZER_ENABLED,false,"eq enabled",NULL),
- {F_T_INT,&global_settings.eq_precut,LANG_EQUALIZER_PRECUT,INT(0),
- "eq precut",NULL,UNUSED},
+ INT_SETTING(0, eq_precut, LANG_EQUALIZER_PRECUT, 0, "eq precut",
+ UNIT_DB, 0, 240, 5, eq_precut_format, NULL, dsp_set_eq_precut),
/* 0..32768 Hz */
- {F_T_INT,&global_settings.eq_band0_cutoff,LANG_EQUALIZER_BAND_CUTOFF,INT(60),
- "eq band 0 cutoff",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band1_cutoff,LANG_EQUALIZER_BAND_CUTOFF,INT(200),
- "eq band 1 cutoff",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band2_cutoff,LANG_EQUALIZER_BAND_CUTOFF,INT(800),
- "eq band 2 cutoff",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band3_cutoff,LANG_EQUALIZER_BAND_CUTOFF,INT(4000),
- "eq band 3 cutoff",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band4_cutoff,LANG_EQUALIZER_BAND_CUTOFF,INT(12000),
- "eq band 4 cutoff",NULL,UNUSED},
+ INT_SETTING(0, eq_band0_cutoff, LANG_EQUALIZER_BAND_CUTOFF, 60, "eq band 0 cutoff",
+ UNIT_HERTZ, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, EQ_CUTOFF_STEP,
+ NULL, NULL, NULL),
+ INT_SETTING(0, eq_band1_cutoff, LANG_EQUALIZER_BAND_CENTER, 200, "eq band 1 cutoff",
+ UNIT_HERTZ, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, EQ_CUTOFF_STEP,
+ NULL, NULL, NULL),
+ INT_SETTING(0, eq_band2_cutoff, LANG_EQUALIZER_BAND_CENTER, 800, "eq band 2 cutoff",
+ UNIT_HERTZ, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, EQ_CUTOFF_STEP,
+ NULL, NULL, NULL),
+ INT_SETTING(0, eq_band3_cutoff, LANG_EQUALIZER_BAND_CENTER, 4000, "eq band 3 cutoff",
+ UNIT_HERTZ, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, EQ_CUTOFF_STEP,
+ NULL, NULL, NULL),
+ INT_SETTING(0, eq_band4_cutoff, LANG_EQUALIZER_BAND_CUTOFF, 12000, "eq band 4 cutoff",
+ UNIT_HERTZ, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, EQ_CUTOFF_STEP,
+ NULL, NULL, NULL),
/* 0..64 (or 0.0 to 6.4) */
- {F_T_INT,&global_settings.eq_band0_q,LANG_EQUALIZER_BAND_Q,INT(7),
- "eq band 0 q",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band1_q,LANG_EQUALIZER_BAND_Q,INT(10),
- "eq band 1 q",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band2_q,LANG_EQUALIZER_BAND_Q,INT(10),
- "eq band 2 q",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band3_q,LANG_EQUALIZER_BAND_Q,INT(10),
- "eq band 3 q",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band4_q,LANG_EQUALIZER_BAND_Q,INT(7),
- "eq band 4 q",NULL,UNUSED},
+ INT_SETTING(0, eq_band0_q, LANG_EQUALIZER_BAND_Q, 7, "eq band 0 q",
+ UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
+ eq_q_format, NULL, NULL),
+ INT_SETTING(0, eq_band1_q, LANG_EQUALIZER_BAND_Q, 10, "eq band 1 q",
+ UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
+ eq_q_format, NULL, NULL),
+ INT_SETTING(0, eq_band2_q, LANG_EQUALIZER_BAND_Q, 10, "eq band 2 q",
+ UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
+ eq_q_format, NULL, NULL),
+ INT_SETTING(0, eq_band3_q, LANG_EQUALIZER_BAND_Q, 10, "eq band 3 q",
+ UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
+ eq_q_format, NULL, NULL),
+ INT_SETTING(0, eq_band4_q, LANG_EQUALIZER_BAND_Q, 7, "eq band 4 q",
+ UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
+ eq_q_format, NULL, NULL),
/* -240..240 (or -24db to +24db) */
- {F_T_INT,&global_settings.eq_band0_gain,LANG_EQUALIZER_BAND_GAIN,INT(0),
- "eq band 0 gain",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band1_gain,LANG_EQUALIZER_BAND_GAIN,INT(0),
- "eq band 1 gain",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band2_gain,LANG_EQUALIZER_BAND_GAIN,INT(0),
- "eq band 2 gain",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band3_gain,LANG_EQUALIZER_BAND_GAIN,INT(0),
- "eq band 3 gain",NULL,UNUSED},
- {F_T_INT,&global_settings.eq_band4_gain,LANG_EQUALIZER_BAND_GAIN,INT(0),
- "eq band 4 gain",NULL,UNUSED},
+ INT_SETTING(0, eq_band0_gain, LANG_EQUALIZER_BAND_GAIN, 0, "eq band 0 gain",
+ UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
+ eq_gain_format, NULL, NULL),
+ INT_SETTING(0, eq_band1_gain, LANG_EQUALIZER_BAND_GAIN, 0, "eq band 1 gain",
+ UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
+ eq_gain_format, NULL, NULL),
+ INT_SETTING(0, eq_band2_gain, LANG_EQUALIZER_BAND_GAIN, 0, "eq band 2 gain",
+ UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
+ eq_gain_format, NULL, NULL),
+ INT_SETTING(0, eq_band3_gain, LANG_EQUALIZER_BAND_GAIN, 0, "eq band 3 gain",
+ UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
+ eq_gain_format, NULL, NULL),
+ INT_SETTING(0, eq_band4_gain, LANG_EQUALIZER_BAND_GAIN, 0, "eq band 4 gain",
+ UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
+ eq_gain_format, NULL, NULL),
/* dithering */
OFFON_SETTING(0, dithering_enabled, LANG_DITHERING,
@@ -949,41 +966,57 @@ const struct settings_list settings[] = {
OFFON_SETTING(0,eq_hw_enabled,LANG_EQUALIZER_HARDWARE_ENABLED,false,
"eq hardware enabled",NULL),
- {F_T_INT,&global_settings.eq_hw_band0_cutoff,LANG_EQUALIZER_BAND_CUTOFF,INT(1),
- "eq hardware band 0 cutoff",
- "80Hz,105Hz,135Hz,175Hz",UNUSED},
- {F_T_INT,&global_settings.eq_hw_band0_gain,LANG_EQUALIZER_BAND_GAIN,INT(0),
- "eq hardware band 0 gain",NULL,UNUSED},
+ STRINGCHOICE_SETTING(0, eq_hw_band0_cutoff, LANG_EQUALIZER_BAND_CUTOFF, 1,
+ "eq hardware band 0 cutoff", "80Hz,105Hz,135Hz,175Hz", NULL, 4,
+ TALK_ID(80, UNIT_HERTZ), TALK_ID(105, UNIT_HERTZ),
+ TALK_ID(135, UNIT_HERTZ), TALK_ID(175, UNIT_HERTZ)),
+ INT_SETTING(0, eq_hw_band0_gain, LANG_EQUALIZER_BAND_GAIN, 0,
+ "eq hardware band 0 gain", UNIT_DB, EQ_HW_GAIN_MIN,
+ EQ_HW_GAIN_MAX, EQ_HW_GAIN_STEP, eq_hw_gain_format, NULL, NULL),
- {F_T_INT,&global_settings.eq_hw_band1_center,LANG_EQUALIZER_BAND_CENTER,INT(1),
- "eq hardware band 1 center",
- "230Hz,300Hz,385Hz,500Hz",UNUSED},
- {F_T_INT,&global_settings.eq_hw_band1_bandwidth,LANG_EQUALIZER_BANDWIDTH,INT(0),
- "eq hardware band 1 bandwidth","narrow,wide",UNUSED},
- {F_T_INT,&global_settings.eq_hw_band1_gain,LANG_EQUALIZER_BAND_GAIN,INT(0),
- "eq hardware band 1 gain",NULL,UNUSED},
+ STRINGCHOICE_SETTING(0, eq_hw_band1_center, LANG_EQUALIZER_BAND_CENTER, 1,
+ "eq hardware band 1 center", "230Hz,300Hz,385Hz,500Hz", NULL, 4,
+ TALK_ID(230, UNIT_HERTZ), TALK_ID(300, UNIT_HERTZ),
+ TALK_ID(385, UNIT_HERTZ), TALK_ID(500, UNIT_HERTZ)),
+ CHOICE_SETTING(0, eq_hw_band1_bandwidth, LANG_EQUALIZER_BANDWIDTH, 0,
+ "eq hardware band 1 bandwidth", "narrow,wide", NULL, 2,
+ ID2P(LANG_EQUALIZER_HARDWARE_BANDWIDTH_NARROW),
+ ID2P(LANG_EQUALIZER_HARDWARE_BANDWIDTH_WIDE)),
+ INT_SETTING(0, eq_hw_band1_gain, LANG_EQUALIZER_BAND_GAIN, 0,
+ "eq hardware band 1 gain", UNIT_DB, EQ_HW_GAIN_MIN,
+ EQ_HW_GAIN_MAX, EQ_HW_GAIN_STEP, eq_hw_gain_format, NULL, NULL),
- {F_T_INT,&global_settings.eq_hw_band2_center,LANG_EQUALIZER_BAND_CENTER,INT(1),
- "eq hardware band 2 center",
- "650Hz,850Hz,1.1kHz,1.4kHz",UNUSED},
- {F_T_INT,&global_settings.eq_hw_band2_bandwidth,LANG_EQUALIZER_BANDWIDTH,INT(0),
- "eq hardware band 2 bandwidth","narrow,wide",UNUSED},
- {F_T_INT,&global_settings.eq_hw_band2_gain,LANG_EQUALIZER_BAND_GAIN,INT(0),
- "eq hardware band 2 gain",NULL,UNUSED},
+ STRINGCHOICE_SETTING(0, eq_hw_band2_center, LANG_EQUALIZER_BAND_CENTER, 1,
+ "eq hardware band 2 center", "650Hz,850Hz,1.1kHz,1.4kHz", NULL, 4,
+ TALK_ID(650, UNIT_HERTZ), TALK_ID(850, UNIT_HERTZ),
+ TALK_ID(1100, UNIT_HERTZ), TALK_ID(1400, UNIT_HERTZ)),
+ CHOICE_SETTING(0, eq_hw_band2_bandwidth, LANG_EQUALIZER_BANDWIDTH, 0,
+ "eq hardware band 2 bandwidth", "narrow,wide", NULL, 2,
+ ID2P(LANG_EQUALIZER_HARDWARE_BANDWIDTH_NARROW),
+ ID2P(LANG_EQUALIZER_HARDWARE_BANDWIDTH_WIDE)),
+ INT_SETTING(0, eq_hw_band2_gain, LANG_EQUALIZER_BAND_GAIN, 0,
+ "eq hardware band 2 gain", UNIT_DB, EQ_HW_GAIN_MIN,
+ EQ_HW_GAIN_MAX, EQ_HW_GAIN_STEP, eq_hw_gain_format, NULL, NULL),
- {F_T_INT,&global_settings.eq_hw_band3_center,LANG_EQUALIZER_BAND_CENTER,INT(1),
- "eq hardware band 3 center",
- "1.8kHz,2.4kHz,3.2kHz,4.1kHz",UNUSED},
- {F_T_INT,&global_settings.eq_hw_band3_bandwidth,LANG_EQUALIZER_BANDWIDTH,INT(0),
- "eq hardware band 3 bandwidth","narrow,wide",UNUSED},
- {F_T_INT,&global_settings.eq_hw_band3_gain,LANG_EQUALIZER_BAND_GAIN,INT(0),
- "eq hardware band 3 gain",NULL,UNUSED},
+ STRINGCHOICE_SETTING(0, eq_hw_band3_center, LANG_EQUALIZER_BAND_CENTER, 1,
+ "eq hardware band 3 center", "1.8kHz,2.4kHz,3.2kHz,4.1kHz", NULL, 4,
+ TALK_ID(1800, UNIT_HERTZ), TALK_ID(2400, UNIT_HERTZ),
+ TALK_ID(3200, UNIT_HERTZ), TALK_ID(4100, UNIT_HERTZ)),
+ CHOICE_SETTING(0, eq_hw_band3_bandwidth, LANG_EQUALIZER_BANDWIDTH, 0,
+ "eq hardware band 3 bandwidth", "narrow,wide", NULL, 2,
+ ID2P(LANG_EQUALIZER_HARDWARE_BANDWIDTH_NARROW),
+ ID2P(LANG_EQUALIZER_HARDWARE_BANDWIDTH_WIDE)),
+ INT_SETTING(0, eq_hw_band3_gain, LANG_EQUALIZER_BAND_GAIN, 0,
+ "eq hardware band 3 gain", UNIT_DB, EQ_HW_GAIN_MIN,
+ EQ_HW_GAIN_MAX, EQ_HW_GAIN_STEP, eq_hw_gain_format, NULL, NULL),
- {F_T_INT,&global_settings.eq_hw_band4_cutoff,LANG_EQUALIZER_BAND_CUTOFF,INT(1),
- "eq hardware band 4 cutoff",
- "5.3kHz,6.9kHz,9kHz,11.7kHz",UNUSED},
- {F_T_INT,&global_settings.eq_hw_band4_gain,LANG_EQUALIZER_BAND_GAIN,INT(0),
- "eq hardware band 4 gain",NULL,UNUSED},
+ STRINGCHOICE_SETTING(0, eq_hw_band4_cutoff, LANG_EQUALIZER_BAND_CUTOFF, 1,
+ "eq hardware band 4 cutoff", "5.3kHz,6.9kHz,9kHz,11.7kHz", NULL, 4,
+ TALK_ID(5300, UNIT_HERTZ), TALK_ID(6900, UNIT_HERTZ),
+ TALK_ID(9000, UNIT_HERTZ), TALK_ID(11700, UNIT_HERTZ)),
+ INT_SETTING(0, eq_hw_band4_gain, LANG_EQUALIZER_BAND_GAIN, 0,
+ "eq hardware band 4 gain", UNIT_DB, EQ_HW_GAIN_MIN,
+ EQ_HW_GAIN_MAX, EQ_HW_GAIN_STEP, eq_hw_gain_format, NULL, NULL),
#endif
OFFON_SETTING(0,hold_lr_for_scroll_in_list,-1,true,
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index 74618b1348..c73472a83c 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -52,7 +52,7 @@
#include "splash.h"
#if CONFIG_CODEC == SWCODEC
#include "dsp.h"
-#include "eq_menu.h"
+#include "menus/eq_menu.h"
#include "pcmbuf.h"
#ifdef HAVE_RECORDING
#include "enc_config.h"