summaryrefslogtreecommitdiff
path: root/apps/eq_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/eq_menu.c')
-rw-r--r--apps/eq_menu.c78
1 files changed, 63 insertions, 15 deletions
diff --git a/apps/eq_menu.c b/apps/eq_menu.c
index 0e3355fcd9..b1f458a9e9 100644
--- a/apps/eq_menu.c
+++ b/apps/eq_menu.c
@@ -49,7 +49,10 @@
49/* Key definitions */ 49/* Key definitions */
50#if (CONFIG_KEYPAD == IRIVER_H100_PAD || \ 50#if (CONFIG_KEYPAD == IRIVER_H100_PAD || \
51 CONFIG_KEYPAD == IRIVER_H300_PAD) 51 CONFIG_KEYPAD == IRIVER_H300_PAD)
52 52
53#define EQ_BTN_MODIFIER BUTTON_ON
54#define EQ_BTN_DECREMENT BUTTON_LEFT
55#define EQ_BTN_INCREMENT BUTTON_RIGHT
53#define EQ_BTN_NEXT_BAND BUTTON_DOWN 56#define EQ_BTN_NEXT_BAND BUTTON_DOWN
54#define EQ_BTN_PREV_BAND BUTTON_UP 57#define EQ_BTN_PREV_BAND BUTTON_UP
55#define EQ_BTN_CHANGE_MODE BUTTON_SELECT 58#define EQ_BTN_CHANGE_MODE BUTTON_SELECT
@@ -57,23 +60,37 @@
57 60
58#elif (CONFIG_KEYPAD == IPOD_4G_PAD) 61#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
59 62
60#define EQ_BTN_NEXT_BAND BUTTON_SCROLL_FWD 63#define EQ_BTN_DECREMENT BUTTON_SCROLL_BACK
61#define EQ_BTN_PREV_BAND BUTTON_SCROLL_BACK 64#define EQ_BTN_INCREMENT BUTTON_SCROLL_FWD
65#define EQ_BTN_NEXT_BAND BUTTON_RIGHT
66#define EQ_BTN_PREV_BAND BUTTON_LEFT
62#define EQ_BTN_CHANGE_MODE BUTTON_SELECT 67#define EQ_BTN_CHANGE_MODE BUTTON_SELECT
63#define EQ_BTN_EXIT BUTTON_MENU 68#define EQ_BTN_EXIT BUTTON_MENU
64 69
70#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
71
72#define EQ_BTN_DECREMENT BUTTON_LEFT
73#define EQ_BTN_INCREMENT BUTTON_RIGHT
74#define EQ_BTN_NEXT_BAND BUTTON_DOWN
75#define EQ_BTN_PREV_BAND BUTTON_UP
76#define EQ_BTN_CHANGE_MODE BUTTON_REC
77#define EQ_BTN_EXIT BUTTON_MENU
78
65#endif 79#endif
66 80
67 81
68#define EQ_CUTOFF_MIN 20 82#define EQ_CUTOFF_MIN 20
69#define EQ_CUTOFF_MAX 22040 83#define EQ_CUTOFF_MAX 22040
70#define EQ_CUTOFF_STEP 10 84#define EQ_CUTOFF_STEP 10
85#define EQ_CUTOFF_FAST_STEP 100
71#define EQ_GAIN_MIN (-240) 86#define EQ_GAIN_MIN (-240)
72#define EQ_GAIN_MAX 240 87#define EQ_GAIN_MAX 240
73#define EQ_GAIN_STEP 1 88#define EQ_GAIN_STEP 1
89#define EQ_GAIN_FAST_STEP 10
74#define EQ_Q_MIN 5 90#define EQ_Q_MIN 5
75#define EQ_Q_MAX 64 91#define EQ_Q_MAX 64
76#define EQ_Q_STEP 1 92#define EQ_Q_STEP 1
93#define EQ_Q_FAST_STEP 10
77 94
78#define EQ_USER_DIVISOR 10 95#define EQ_USER_DIVISOR 10
79 96
@@ -104,6 +121,16 @@ static void eq_q_format(char* buffer, int buffer_size, int value, const char* un
104#define eq_make_gain_label(buf, bufsize, frequency) snprintf((buf), \ 121#define eq_make_gain_label(buf, bufsize, frequency) snprintf((buf), \
105 (bufsize), str(LANG_EQUALIZER_GAIN_ITEM), (frequency)) 122 (bufsize), str(LANG_EQUALIZER_GAIN_ITEM), (frequency))
106 123
124#define eq_set_center(band) \
125static bool eq_set_band ## band ## _center(void) \
126{ \
127 bool result = set_int(str(LANG_EQUALIZER_BAND_CENTER), "Hertz", UNIT_HERTZ, \
128 &global_settings.eq_band ## band ## _cutoff, NULL, \
129 EQ_CUTOFF_STEP, EQ_CUTOFF_MIN, EQ_CUTOFF_MAX, NULL); \
130 dsp_eq_update_data(global_settings.eq_enabled); \
131 return result; \
132}
133
107#define eq_set_cutoff(band) \ 134#define eq_set_cutoff(band) \
108static bool eq_set_band ## band ## _cutoff(void) \ 135static bool eq_set_band ## band ## _cutoff(void) \
109{ \ 136{ \
@@ -135,9 +162,9 @@ static bool eq_set_band ## band ## _gain(void) \
135} 162}
136 163
137eq_set_cutoff(0); 164eq_set_cutoff(0);
138eq_set_cutoff(1); 165eq_set_center(1);
139eq_set_cutoff(2); 166eq_set_center(2);
140eq_set_cutoff(3); 167eq_set_center(3);
141eq_set_cutoff(4); 168eq_set_cutoff(4);
142 169
143eq_set_q(0); 170eq_set_q(0);
@@ -209,7 +236,7 @@ static bool eq_set_band1(void)
209 int m; 236 int m;
210 bool result; 237 bool result;
211 static const struct menu_item items[] = { 238 static const struct menu_item items[] = {
212 { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_set_band1_cutoff }, 239 { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_set_band1_center },
213 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band1_q }, 240 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band1_q },
214 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band1_gain }, 241 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band1_gain },
215 }; 242 };
@@ -227,7 +254,7 @@ static bool eq_set_band2(void)
227 int m; 254 int m;
228 bool result; 255 bool result;
229 static const struct menu_item items[] = { 256 static const struct menu_item items[] = {
230 { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_set_band2_cutoff }, 257 { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_set_band2_center },
231 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band2_q }, 258 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band2_q },
232 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band2_gain }, 259 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band2_gain },
233 }; 260 };
@@ -245,7 +272,7 @@ static bool eq_set_band3(void)
245 int m; 272 int m;
246 bool result; 273 bool result;
247 static const struct menu_item items[] = { 274 static const struct menu_item items[] = {
248 { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_set_band3_cutoff }, 275 { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_set_band3_center },
249 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band3_q }, 276 { ID2P(LANG_EQUALIZER_BAND_Q), eq_set_band3_q },
250 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band3_gain }, 277 { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band3_gain },
251 }; 278 };
@@ -470,7 +497,7 @@ bool eq_menu_graphical(void)
470 bool has_changed = false; 497 bool has_changed = false;
471 int button; 498 int button;
472 int *setting; 499 int *setting;
473 int current_band, y, step, min, max, voice_unit; 500 int current_band, y, step, fast_step, min, max, voice_unit;
474 enum eq_slider_mode mode; 501 enum eq_slider_mode mode;
475 enum eq_type current_type; 502 enum eq_type current_type;
476 char buf[24]; 503 char buf[24];
@@ -497,6 +524,7 @@ bool eq_menu_graphical(void)
497 setting += current_band * 3; 524 setting += current_band * 3;
498 525
499 step = EQ_GAIN_STEP; 526 step = EQ_GAIN_STEP;
527 fast_step = EQ_GAIN_FAST_STEP;
500 min = EQ_GAIN_MIN; 528 min = EQ_GAIN_MIN;
501 max = EQ_GAIN_MAX; 529 max = EQ_GAIN_MAX;
502 voice_unit = UNIT_DB; 530 voice_unit = UNIT_DB;
@@ -511,6 +539,7 @@ bool eq_menu_graphical(void)
511 setting += current_band * 3; 539 setting += current_band * 3;
512 540
513 step = EQ_CUTOFF_STEP; 541 step = EQ_CUTOFF_STEP;
542 fast_step = EQ_CUTOFF_FAST_STEP;
514 min = EQ_CUTOFF_MIN; 543 min = EQ_CUTOFF_MIN;
515 max = EQ_CUTOFF_MAX; 544 max = EQ_CUTOFF_MAX;
516 voice_unit = UNIT_HERTZ; 545 voice_unit = UNIT_HERTZ;
@@ -525,6 +554,7 @@ bool eq_menu_graphical(void)
525 setting += current_band * 3; 554 setting += current_band * 3;
526 555
527 step = EQ_Q_STEP; 556 step = EQ_Q_STEP;
557 fast_step = EQ_Q_FAST_STEP;
528 min = EQ_Q_MIN; 558 min = EQ_Q_MIN;
529 max = EQ_Q_MAX; 559 max = EQ_Q_MAX;
530 voice_unit = UNIT_INT; 560 voice_unit = UNIT_INT;
@@ -537,25 +567,43 @@ bool eq_menu_graphical(void)
537 567
538 screens[SCREEN_MAIN].update(); 568 screens[SCREEN_MAIN].update();
539 569
540 button = button_get_w_tmo(HZ/10); 570 button = button_get(true);
541 571
542 switch (button) { 572 switch (button) {
543 case BUTTON_LEFT: 573 case EQ_BTN_DECREMENT:
544 case BUTTON_LEFT | BUTTON_REPEAT: 574 case EQ_BTN_DECREMENT | BUTTON_REPEAT:
545 *(setting) -= step; 575 *(setting) -= step;
546 has_changed = true; 576 has_changed = true;
547 if (*(setting) < min) 577 if (*(setting) < min)
548 *(setting) = min; 578 *(setting) = min;
549 break; 579 break;
550 580
551 case BUTTON_RIGHT: 581 case EQ_BTN_INCREMENT:
552 case BUTTON_RIGHT | BUTTON_REPEAT: 582 case EQ_BTN_INCREMENT | BUTTON_REPEAT:
553 *(setting) += step; 583 *(setting) += step;
554 has_changed = true; 584 has_changed = true;
555 if (*(setting) > max) 585 if (*(setting) > max)
556 *(setting) = max; 586 *(setting) = max;
557 break; 587 break;
558 588
589#ifdef EQ_BTN_MODIFIER
590 case EQ_BTN_MODIFIER | EQ_BTN_INCREMENT:
591 case EQ_BTN_MODIFIER | EQ_BTN_INCREMENT | BUTTON_REPEAT:
592 *(setting) += fast_step;
593 has_changed = true;
594 if (*(setting) > max)
595 *(setting) = max;
596 break;
597
598 case EQ_BTN_MODIFIER | EQ_BTN_DECREMENT:
599 case EQ_BTN_MODIFIER | EQ_BTN_DECREMENT | BUTTON_REPEAT:
600 *(setting) -= fast_step;
601 has_changed = true;
602 if (*(setting) < min)
603 *(setting) = min;
604 break;
605#endif
606
559 case EQ_BTN_PREV_BAND: 607 case EQ_BTN_PREV_BAND:
560 case EQ_BTN_PREV_BAND | BUTTON_REPEAT: 608 case EQ_BTN_PREV_BAND | BUTTON_REPEAT:
561 current_band--; 609 current_band--;