summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/menus/eq_menu.c95
1 files changed, 50 insertions, 45 deletions
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
index 9b8c2e3e6b..2b4e9ad8a8 100644
--- a/apps/menus/eq_menu.c
+++ b/apps/menus/eq_menu.c
@@ -66,7 +66,7 @@ void eq_precut_format(char* buffer, size_t buffer_size, int value, const char* u
66/* 66/*
67 * Settings functions 67 * Settings functions
68 */ 68 */
69void eq_apply(void) 69static void eq_apply(void)
70{ 70{
71 int i; 71 int i;
72 dsp_set_eq(global_settings.eq_enabled); 72 dsp_set_eq(global_settings.eq_enabled);
@@ -76,37 +76,52 @@ void eq_apply(void)
76 dsp_set_eq_coefs(i); 76 dsp_set_eq_coefs(i);
77 } 77 }
78} 78}
79int enable_callback(int action, const struct menu_item_ex *this_item)
80{
81 (void)this_item;
82 if (action == ACTION_EXIT_MENUITEM)
83 eq_apply();
84 return action;
85}
86MENUITEM_SETTING(eq_enable, &global_settings.eq_enabled, enable_callback);
87MENUITEM_SETTING(eq_precut, &global_settings.eq_precut, enable_callback);
88 79
89int dsp_set_coefs_callback(int action, const struct menu_item_ex *this_item) 80static int eq_setting_callback(int action, const struct menu_item_ex *this_item)
90{ 81{
91 (void)this_item; 82 switch (action)
92 if (action == ACTION_EXIT_MENUITEM)
93 { 83 {
94 /* for now, set every band... figure out a better way later */ 84 case ACTION_ENTER_MENUITEM:
95 int i=0; 85 action = lowlatency_callback(action, this_item);
96 for (i=0; i<5; i++) 86 break;
97 dsp_set_eq_coefs(i); 87 case ACTION_EXIT_MENUITEM:
88 eq_apply();
89 action = lowlatency_callback(action, this_item);
90 break;
98 } 91 }
92
99 return action; 93 return action;
100} 94}
101 95MENUITEM_SETTING(eq_enable, &global_settings.eq_enabled, eq_setting_callback);
102char* gainitem_get_name(int selected_item, void * data, char *buffer) 96MENUITEM_SETTING(eq_precut, &global_settings.eq_precut, eq_setting_callback);
97
98MENUITEM_SETTING(cutoff_0, &global_settings.eq_band0_cutoff, eq_setting_callback);
99MENUITEM_SETTING(cutoff_1, &global_settings.eq_band1_cutoff, eq_setting_callback);
100MENUITEM_SETTING(cutoff_2, &global_settings.eq_band2_cutoff, eq_setting_callback);
101MENUITEM_SETTING(cutoff_3, &global_settings.eq_band3_cutoff, eq_setting_callback);
102MENUITEM_SETTING(cutoff_4, &global_settings.eq_band4_cutoff, eq_setting_callback);
103
104MENUITEM_SETTING(q_0, &global_settings.eq_band0_q, eq_setting_callback);
105MENUITEM_SETTING(q_1, &global_settings.eq_band1_q, eq_setting_callback);
106MENUITEM_SETTING(q_2, &global_settings.eq_band2_q, eq_setting_callback);
107MENUITEM_SETTING(q_3, &global_settings.eq_band3_q, eq_setting_callback);
108MENUITEM_SETTING(q_4, &global_settings.eq_band4_q, eq_setting_callback);
109
110MENUITEM_SETTING(gain_0, &global_settings.eq_band0_gain, eq_setting_callback);
111MENUITEM_SETTING(gain_1, &global_settings.eq_band1_gain, eq_setting_callback);
112MENUITEM_SETTING(gain_2, &global_settings.eq_band2_gain, eq_setting_callback);
113MENUITEM_SETTING(gain_3, &global_settings.eq_band3_gain, eq_setting_callback);
114MENUITEM_SETTING(gain_4, &global_settings.eq_band4_gain, eq_setting_callback);
115
116static char* gainitem_get_name(int selected_item, void * data, char *buffer)
103{ 117{
104 (void)selected_item; 118 (void)selected_item;
105 int *setting = (int*)data; 119 int *setting = (int*)data;
106 snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_GAIN_ITEM), *setting); 120 snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_GAIN_ITEM), *setting);
107 return buffer; 121 return buffer;
108} 122}
109int gainitem_speak_item(int selected_item, void * data) 123
124static int gainitem_speak_item(int selected_item, void * data)
110{ 125{
111 (void)selected_item; 126 (void)selected_item;
112 int *setting = (int*)data; 127 int *setting = (int*)data;
@@ -115,32 +130,16 @@ int gainitem_speak_item(int selected_item, void * data)
115 return 0; 130 return 0;
116} 131}
117 132
118int do_option(void* param) 133static int do_option(void * param)
119{ 134{
120 const struct menu_item_ex *setting = (const struct menu_item_ex*)param; 135 const struct menu_item_ex *setting = (const struct menu_item_ex*)param;
136 lowlatency_callback(ACTION_ENTER_MENUITEM, setting);
121 do_setting_from_menu(setting); 137 do_setting_from_menu(setting);
122 eq_apply(); 138 eq_apply();
139 lowlatency_callback(ACTION_EXIT_MENUITEM, setting);
123 return 0; 140 return 0;
124} 141}
125 142
126MENUITEM_SETTING(cutoff_0, &global_settings.eq_band0_cutoff, dsp_set_coefs_callback);
127MENUITEM_SETTING(cutoff_1, &global_settings.eq_band1_cutoff, dsp_set_coefs_callback);
128MENUITEM_SETTING(cutoff_2, &global_settings.eq_band2_cutoff, dsp_set_coefs_callback);
129MENUITEM_SETTING(cutoff_3, &global_settings.eq_band3_cutoff, dsp_set_coefs_callback);
130MENUITEM_SETTING(cutoff_4, &global_settings.eq_band4_cutoff, dsp_set_coefs_callback);
131
132MENUITEM_SETTING(q_0, &global_settings.eq_band0_q, dsp_set_coefs_callback);
133MENUITEM_SETTING(q_1, &global_settings.eq_band1_q, dsp_set_coefs_callback);
134MENUITEM_SETTING(q_2, &global_settings.eq_band2_q, dsp_set_coefs_callback);
135MENUITEM_SETTING(q_3, &global_settings.eq_band3_q, dsp_set_coefs_callback);
136MENUITEM_SETTING(q_4, &global_settings.eq_band4_q, dsp_set_coefs_callback);
137
138MENUITEM_SETTING(gain_0, &global_settings.eq_band0_gain, dsp_set_coefs_callback);
139MENUITEM_SETTING(gain_1, &global_settings.eq_band1_gain, dsp_set_coefs_callback);
140MENUITEM_SETTING(gain_2, &global_settings.eq_band2_gain, dsp_set_coefs_callback);
141MENUITEM_SETTING(gain_3, &global_settings.eq_band3_gain, dsp_set_coefs_callback);
142MENUITEM_SETTING(gain_4, &global_settings.eq_band4_gain, dsp_set_coefs_callback);
143
144MENUITEM_FUNCTION_DYNTEXT(gain_item_0, MENU_FUNC_USEPARAM, 143MENUITEM_FUNCTION_DYNTEXT(gain_item_0, MENU_FUNC_USEPARAM,
145 do_option, (void*)&gain_0, 144 do_option, (void*)&gain_0,
146 gainitem_get_name, gainitem_speak_item, 145 gainitem_get_name, gainitem_speak_item,
@@ -170,14 +169,16 @@ static const struct menu_item_ex *band_items[3][3] = {
170 { &cutoff_2, &q_2, &gain_2 }, 169 { &cutoff_2, &q_2, &gain_2 },
171 { &cutoff_3, &q_3, &gain_3 } 170 { &cutoff_3, &q_3, &gain_3 }
172}; 171};
173char* centerband_get_name(int selected_item, void * data, char *buffer) 172
173static char* centerband_get_name(int selected_item, void * data, char *buffer)
174{ 174{
175 (void)selected_item; 175 (void)selected_item;
176 int band = (intptr_t)data; 176 int band = (intptr_t)data;
177 snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_BAND_PEAK), band); 177 snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_BAND_PEAK), band);
178 return buffer; 178 return buffer;
179} 179}
180int centerband_speak_item(int selected_item, void * data) 180
181static int centerband_speak_item(int selected_item, void * data)
181{ 182{
182 (void)selected_item; 183 (void)selected_item;
183 int band = (intptr_t)data; 184 int band = (intptr_t)data;
@@ -185,7 +186,8 @@ int centerband_speak_item(int selected_item, void * data)
185 talk_number(band, true); 186 talk_number(band, true);
186 return 0; 187 return 0;
187} 188}
188int do_center_band_menu(void* param) 189
190static int do_center_band_menu(void* param)
189{ 191{
190 int band = (intptr_t)param; 192 int band = (intptr_t)param;
191 struct menu_item_ex menu; 193 struct menu_item_ex menu;
@@ -202,6 +204,7 @@ int do_center_band_menu(void* param)
202 do_menu(&menu, NULL, NULL, false); 204 do_menu(&menu, NULL, NULL, false);
203 return 0; 205 return 0;
204} 206}
207
205MAKE_MENU(band_0_menu, ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), NULL, 208MAKE_MENU(band_0_menu, ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), NULL,
206 Icon_EQ, &cutoff_0, &q_0, &gain_0); 209 Icon_EQ, &cutoff_0, &q_0, &gain_0);
207MENUITEM_FUNCTION_DYNTEXT(band_1_menu, MENU_FUNC_USEPARAM, 210MENUITEM_FUNCTION_DYNTEXT(band_1_menu, MENU_FUNC_USEPARAM,
@@ -586,6 +589,7 @@ bool eq_menu_graphical(void)
586 screens[i].setfont(FONT_UI); 589 screens[i].setfont(FONT_UI);
587 screens[i].clear_display(); 590 screens[i].clear_display();
588 } 591 }
592
589 return result; 593 return result;
590} 594}
591 595
@@ -609,14 +613,15 @@ bool eq_browse_presets(void)
609} 613}
610 614
611MENUITEM_FUNCTION(eq_graphical, 0, ID2P(LANG_EQUALIZER_GRAPHICAL), 615MENUITEM_FUNCTION(eq_graphical, 0, ID2P(LANG_EQUALIZER_GRAPHICAL),
612 (int(*)(void))eq_menu_graphical, NULL, NULL, 616 (int(*)(void))eq_menu_graphical, NULL, lowlatency_callback,
613 Icon_EQ); 617 Icon_EQ);
614MENUITEM_FUNCTION(eq_save, 0, ID2P(LANG_EQUALIZER_SAVE), 618MENUITEM_FUNCTION(eq_save, 0, ID2P(LANG_EQUALIZER_SAVE),
615 (int(*)(void))eq_save_preset, NULL, NULL, Icon_NOICON); 619 (int(*)(void))eq_save_preset, NULL, NULL, Icon_NOICON);
616MENUITEM_FUNCTION(eq_browse, 0, ID2P(LANG_EQUALIZER_BROWSE), 620MENUITEM_FUNCTION(eq_browse, 0, ID2P(LANG_EQUALIZER_BROWSE),
617 (int(*)(void))eq_browse_presets, NULL, NULL, Icon_NOICON); 621 (int(*)(void))eq_browse_presets, NULL, lowlatency_callback,
622 Icon_NOICON);
618 623
619MAKE_MENU(equalizer_menu, ID2P(LANG_EQUALIZER), lowlatency_callback, Icon_EQ, 624MAKE_MENU(equalizer_menu, ID2P(LANG_EQUALIZER), NULL, Icon_EQ,
620 &eq_enable, &eq_graphical, &eq_precut, &gain_menu, 625 &eq_enable, &eq_graphical, &eq_precut, &gain_menu,
621 &advanced_eq_menu_, &eq_save, &eq_browse); 626 &advanced_eq_menu_, &eq_save, &eq_browse);
622 627