summaryrefslogtreecommitdiffstats
path: root/apps/menus/eq_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/menus/eq_menu.c')
-rw-r--r--apps/menus/eq_menu.c91
1 files changed, 49 insertions, 42 deletions
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
index 49d35c133b..59dcc59ff0 100644
--- a/apps/menus/eq_menu.c
+++ b/apps/menus/eq_menu.c
@@ -49,6 +49,9 @@
#include "exported_menus.h"
#include "pcmbuf.h"
#include "option_select.h"
+#include "string-extra.h"
+
+static void eq_apply(void);
/*
* Utility functions
@@ -68,6 +71,12 @@ const char* eq_precut_format(char* buffer, size_t buffer_size, int value, const
return buffer;
}
+void eq_enabled_option_callback(bool enabled)
+{
+ (void)enabled;
+ eq_apply();
+}
+
/*
* Settings functions
*/
@@ -145,9 +154,9 @@ static int32_t get_dec_talkid(int value, int unit)
static const struct int_setting gain_int_setting = {
.option_callback = NULL,
.unit = UNIT_DB,
+ .step = EQ_GAIN_STEP,
.min = EQ_GAIN_MIN,
.max = EQ_GAIN_MAX,
- .step = EQ_GAIN_STEP,
.formatter = db_format,
.get_talk_id = get_dec_talkid,
};
@@ -155,9 +164,9 @@ static const struct int_setting gain_int_setting = {
static const struct int_setting q_int_setting = {
.option_callback = NULL,
.unit = UNIT_INT,
+ .step = EQ_Q_STEP,
.min = EQ_Q_MIN,
.max = EQ_Q_MAX,
- .step = EQ_Q_STEP,
.formatter = eq_q_format,
.get_talk_id = get_dec_talkid,
};
@@ -165,9 +174,9 @@ static const struct int_setting q_int_setting = {
static const struct int_setting cutoff_int_setting = {
.option_callback = NULL,
.unit = UNIT_HERTZ,
+ .step = EQ_CUTOFF_STEP,
.min = EQ_CUTOFF_MIN,
.max = EQ_CUTOFF_MAX,
- .step = EQ_CUTOFF_STEP,
.formatter = NULL,
.get_talk_id = NULL,
};
@@ -213,8 +222,8 @@ static int eq_do_simple_menu(void * param)
}
return 0;
}
-MENUITEM_FUNCTION(gain_menu, 0, ID2P(LANG_EQUALIZER_GAIN), eq_do_simple_menu,
- NULL, NULL, Icon_Submenu);
+MENUITEM_FUNCTION(gain_menu, 0, ID2P(LANG_EQUALIZER_GAIN),
+ eq_do_simple_menu, NULL, Icon_Submenu);
static void selection_to_banditem(int selection, int expanded_band, int *band, int *item)
{
@@ -239,14 +248,12 @@ static void selection_to_banditem(int selection, int expanded_band, int *band, i
static char *advancedmenu_item_get_name(int selected_item, void *data, char *buffer, size_t len)
{
- (void)len;
int band;
int item;
- char *lang = NULL;
+ int lang = -1;
selection_to_banditem(selected_item, *(intptr_t*)data, &band, &item);
- strcpy(buffer, "\t");
switch (item)
{
case 0: /* Band title */
@@ -256,27 +263,34 @@ static char *advancedmenu_item_get_name(int selected_item, void *data, char *buf
return str(LANG_EQUALIZER_BAND_HIGH_SHELF);
else
{
- snprintf(buffer, MAX_PATH, str(LANG_EQUALIZER_BAND_PEAK), band);
+ snprintf(buffer, len, str(LANG_EQUALIZER_BAND_PEAK), band);
return buffer;
}
break;
case 1: /* cutoff */
if (band == 0)
- lang = str(LANG_EQUALIZER_BAND_CUTOFF);
+ lang = LANG_EQUALIZER_BAND_CUTOFF;
else if (band == EQ_NUM_BANDS - 1)
- lang = str(LANG_EQUALIZER_BAND_CUTOFF);
+ lang = LANG_EQUALIZER_BAND_CUTOFF;
else
- lang = str(LANG_EQUALIZER_BAND_CENTER);
+ lang = LANG_EQUALIZER_BAND_CENTER;
break;
case 2: /* Q */
- lang = str(LANG_EQUALIZER_BAND_Q);
+ lang = LANG_EQUALIZER_BAND_Q;
break;
case 3: /* Gain */
- lang = str(LANG_GAIN);
+ lang = LANG_GAIN;
break;
}
- return strcat(buffer, lang);;
+ if(lang < 0)
+ buffer[0] = 0;
+ else {
+ buffer[0] = '\t';
+ strmemccpy(&buffer[1], str(lang), len - 1);
+ }
+
+ return buffer;
}
static int advancedmenu_speak_item(int selected_item, void *data)
@@ -412,7 +426,7 @@ static int eq_do_advanced_menu(void * param)
return 0;
}
MENUITEM_FUNCTION(advanced_menu, 0, ID2P(LANG_EQUALIZER_ADVANCED),
- eq_do_advanced_menu, NULL, NULL, Icon_EQ);
+ eq_do_advanced_menu, NULL, Icon_EQ);
enum eq_slider_mode {
GAIN,
@@ -466,17 +480,18 @@ static int draw_eq_slider(struct screen * screen, int x, int y,
/* Print out the band label */
if (band == 0) {
screen->putsxy(x1, y1, "LS: ");
- screen->getstringsize("LS:", &w, &h);
+ /*screen->getstringsize("LS:", &w, &h); UNUSED*/
} else if (band == EQ_NUM_BANDS - 1) {
screen->putsxy(x1, y1, "HS: ");
- screen->getstringsize("HS:", &w, &h);
+ /*screen->getstringsize("HS:", &w, &h); UNUSED*/
} else {
snprintf(buf, sizeof(buf), "PK%d:", band);
screen->putsxy(x1, y1, buf);
- screen->getstringsize(buf, &w, &h);
+ /*screen->getstringsize(buf, &w, &h); UNUSED*/
}
- screen->getstringsize("A", &w, &h);
+ w = screen->getstringsize("A", NULL, &h);
+
x1 += 5*w; /* 4 chars for label + 1 space = 5 */
/* Print out gain part of status line (left justify after label) */
@@ -489,7 +504,7 @@ static int draw_eq_slider(struct screen * screen, int x, int y,
abs_gain / EQ_USER_DIVISOR, abs_gain % EQ_USER_DIVISOR,
screen->lcdwidth >= 160 ? "dB" : "");
screen->putsxy(x1, y1, buf);
- screen->getstringsize(buf, &w, &h);
+ w = screen->getstringsize(buf, NULL, NULL);
x1 += w;
/* Print out Q part of status line (right justify) */
@@ -500,7 +515,7 @@ static int draw_eq_slider(struct screen * screen, int x, int y,
snprintf(buf, sizeof(buf), "%d.%d%s", q / EQ_USER_DIVISOR,
q % EQ_USER_DIVISOR, screen->lcdwidth >= 160 ? " Q" : "");
- screen->getstringsize(buf, &w, &h);
+ w = screen->getstringsize(buf, NULL, NULL);
x2 = x + width - w - 2;
screen->putsxy(x2, y1, buf);
@@ -512,7 +527,7 @@ static int draw_eq_slider(struct screen * screen, int x, int y,
snprintf(buf, sizeof(buf), "%5d%s", cutoff,
screen->lcdwidth >= 160 ? "Hz" : "");
- screen->getstringsize(buf, &w, &h);
+ w = screen->getstringsize(buf, NULL, NULL);
x1 = x1 + (x2 - x1 - w)/2;
screen->putsxy(x1, y1, buf);
@@ -575,8 +590,7 @@ int eq_menu_graphical(void)
int *setting;
int current_band, x, y, step, fast_step, min, max;
enum eq_slider_mode mode;
- char buf[24];
- int w, h, height, start_item, nb_eq_sliders[NB_SCREENS];
+ int h, height, start_item, nb_eq_sliders[NB_SCREENS];
FOR_NB_SCREENS(i)
viewportmanager_theme_enable(i, false, NULL);
@@ -587,7 +601,7 @@ int eq_menu_graphical(void)
screens[i].clear_display();
/* Figure out how many sliders can be drawn on the screen */
- screens[i].getstringsize("A", &w, &h);
+ h = screens[i].getcharheight();
/* Total height includes margins (1), text, slider, and line selector (1) */
height = 3 + h + 1 + SCROLLBAR_SIZE + 3;
@@ -623,10 +637,8 @@ int eq_menu_graphical(void)
min = EQ_GAIN_MIN;
max = EQ_GAIN_MAX;
- snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
+ screens[i].putsxyf(0, 0, str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
str(LANG_SYSFONT_GAIN), "(dB)");
-
- screens[i].putsxy(0, 0, buf);
} else if (mode == CUTOFF) {
/* cutoff */
setting = &global_settings.eq_band_settings[current_band].cutoff;
@@ -636,10 +648,8 @@ int eq_menu_graphical(void)
min = EQ_CUTOFF_MIN;
max = EQ_CUTOFF_MAX;
- snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
+ screens[i].putsxyf(0, 0, str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
str(LANG_SYSFONT_EQUALIZER_BAND_CUTOFF), "(Hz)");
-
- screens[i].putsxy(0, 0, buf);
} else {
/* Q */
setting = &global_settings.eq_band_settings[current_band].q;
@@ -649,10 +659,8 @@ int eq_menu_graphical(void)
min = EQ_Q_MIN;
max = EQ_Q_MAX;
- snprintf(buf, sizeof(buf), str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
+ screens[i].putsxyf(0, 0, str(LANG_SYSFONT_EQUALIZER_EDIT_MODE),
str(LANG_SYSFONT_EQUALIZER_BAND_Q), "");
-
- screens[i].putsxy(0, 0, buf);
}
/* Draw scrollbar if needed */
@@ -660,7 +668,7 @@ int eq_menu_graphical(void)
{
if (current_band == 0) {
start_item = 0;
- } else if (current_band == 9) {
+ } else if (current_band == EQ_NUM_BANDS - 1) {
start_item = EQ_NUM_BANDS - nb_eq_sliders[i];
} else {
start_item = current_band - 1;
@@ -775,13 +783,12 @@ static int eq_save_preset(void)
static struct browse_folder_info eqs = { EQS_DIR, SHOW_CFG };
MENUITEM_FUNCTION(eq_graphical, 0, ID2P(LANG_EQUALIZER_GRAPHICAL),
- eq_menu_graphical, NULL, lowlatency_callback,
- Icon_EQ);
+ eq_menu_graphical, lowlatency_callback, Icon_EQ);
MENUITEM_FUNCTION(eq_save, 0, ID2P(LANG_EQUALIZER_SAVE),
- eq_save_preset, NULL, NULL, Icon_NOICON);
-MENUITEM_FUNCTION(eq_browse, MENU_FUNC_USEPARAM, ID2P(LANG_EQUALIZER_BROWSE),
- browse_folder, (void*)&eqs, lowlatency_callback,
- Icon_NOICON);
+ eq_save_preset, NULL, Icon_NOICON);
+MENUITEM_FUNCTION_W_PARAM(eq_browse, 0, ID2P(LANG_EQUALIZER_BROWSE),
+ browse_folder, (void*)&eqs,
+ lowlatency_callback, Icon_NOICON);
MAKE_MENU(equalizer_menu, ID2P(LANG_EQUALIZER), NULL, Icon_EQ,
&eq_enable, &eq_graphical, &eq_precut, &gain_menu,