From e64fb43cb7dc73383952e169ea1755878e609ea7 Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Sun, 16 Feb 2020 23:57:36 +0100 Subject: [PATCH 1/9] New method for handling custom alarms --- src/extended_audio.c | 25 +++++++++++++++++++++++-- src/music.h | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/extended_audio.c b/src/extended_audio.c index bb9cd1e406..1794739bff 100644 --- a/src/extended_audio.c +++ b/src/extended_audio.c @@ -248,8 +248,29 @@ int AUDIO_AddQueue(u16 music) { printf("Voice: mp3 length is zero\n"); return 0; } - - audio_queue[num_audio++] = music; + + int new_num_audio = -1; + +#if USE_NEW_CUSTOM_ALARM_MODE + u32 t = CLOCK_getms(); + + // Replace the last custom alarm id, if there is already one + if(voice_map[music].id>=CUSTOM_ALARM_ID) + { + u32 id = voice_map[audio_queue[next_audio-1]].id; + if(id==0 || id>=CUSTOM_ALARM_ID) // Only skip welcome message or custom alarms + audio_queue_time = t + CUSTOM_ALARM_IGNORE_MS; // Do not consume the audio right away (prevent triggering transitional sounds) + + for(u8 i=next_audio; i=CUSTOM_ALARM_ID) + new_num_audio = i; + } +#endif + + if(new_num_audio < 0) + audio_queue[num_audio++] = music; // Add to queue + else + audio_queue[new_num_audio] = music; // Replace queue item, do not enqueue custom sounds return 1; } diff --git a/src/music.h b/src/music.h index 91507d780a..4543bbf916 100644 --- a/src/music.h +++ b/src/music.h @@ -37,6 +37,8 @@ enum Music { #endif #define VOICE_UNIT_OFFSET 130 #define CUSTOM_ALARM_ID 200 // start of custom MP3 IDs +#define USE_NEW_CUSTOM_ALARM_MODE 1 // if this is 0, all the custom alarms are enqueued and never skipped +#define CUSTOM_ALARM_IGNORE_MS 200 // ignore custom alarms if the switch was faster than this value (requires USE_NEW_CUSTOM_ALARM_MODE) #define VOICE_DEC_SEP 110 // MP3 ID of DECSEP = 110 + MUSIC_TOTAL #define NUM_STICKS 4 #define NUM_AUX_KNOBS (INP_HAS_CALIBRATION - NUM_STICKS) // Exclude sticks From 25789829eeba1bd6d74af2aa802ba9686cfa7c9f Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Mon, 17 Feb 2020 00:17:48 +0100 Subject: [PATCH 2/9] Update extended_audio.c --- src/extended_audio.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/extended_audio.c b/src/extended_audio.c index 1794739bff..b402d946f9 100644 --- a/src/extended_audio.c +++ b/src/extended_audio.c @@ -248,29 +248,29 @@ int AUDIO_AddQueue(u16 music) { printf("Voice: mp3 length is zero\n"); return 0; } - + int new_num_audio = -1; - + #if USE_NEW_CUSTOM_ALARM_MODE u32 t = CLOCK_getms(); - + // Replace the last custom alarm id, if there is already one - if(voice_map[music].id>=CUSTOM_ALARM_ID) + if (voice_map[music].id >= CUSTOM_ALARM_ID) { u32 id = voice_map[audio_queue[next_audio-1]].id; - if(id==0 || id>=CUSTOM_ALARM_ID) // Only skip welcome message or custom alarms - audio_queue_time = t + CUSTOM_ALARM_IGNORE_MS; // Do not consume the audio right away (prevent triggering transitional sounds) - - for(u8 i=next_audio; i=CUSTOM_ALARM_ID) + if (id == 0 || id >= CUSTOM_ALARM_ID) // Only skip welcome message or custom alarms + audio_queue_time = t + CUSTOM_ALARM_IGNORE_MS; // Do not consume the audio right away (prevent triggering transitional sounds) + + for (u8 i = next_audio; i < num_audio; i++) + if (voice_map[audio_queue[i]].id >= CUSTOM_ALARM_ID) new_num_audio = i; } #endif - - if(new_num_audio < 0) - audio_queue[num_audio++] = music; // Add to queue + + if (new_num_audio < 0) + audio_queue[num_audio++] = music; // Add to queue else - audio_queue[new_num_audio] = music; // Replace queue item, do not enqueue custom sounds + audio_queue[new_num_audio] = music; // Replace queue item, do not enqueue custom sounds return 1; } From ccc48717e407067731ef0d201ad936cba35b8283 Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Mon, 17 Feb 2020 00:17:55 +0100 Subject: [PATCH 3/9] Update music.h --- src/music.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/music.h b/src/music.h index 4543bbf916..092396698e 100644 --- a/src/music.h +++ b/src/music.h @@ -37,8 +37,8 @@ enum Music { #endif #define VOICE_UNIT_OFFSET 130 #define CUSTOM_ALARM_ID 200 // start of custom MP3 IDs -#define USE_NEW_CUSTOM_ALARM_MODE 1 // if this is 0, all the custom alarms are enqueued and never skipped -#define CUSTOM_ALARM_IGNORE_MS 200 // ignore custom alarms if the switch was faster than this value (requires USE_NEW_CUSTOM_ALARM_MODE) +#define USE_NEW_CUSTOM_ALARM_MODE 1 // if this is 0, all the custom alarms are enqueued and never skipped +#define CUSTOM_ALARM_IGNORE_MS 200 // ignore custom alarms if the switch was faster than this value (requires USE_NEW_CUSTOM_ALARM_MODE) #define VOICE_DEC_SEP 110 // MP3 ID of DECSEP = 110 + MUSIC_TOTAL #define NUM_STICKS 4 #define NUM_AUX_KNOBS (INP_HAS_CALIBRATION - NUM_STICKS) // Exclude sticks From b42928aa63dad5a384bd8689fe998b529ceaf7ed Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Mon, 17 Feb 2020 09:09:56 +0100 Subject: [PATCH 4/9] Using MUSIC_STARTUP instead of 0 for Welcome message --- src/extended_audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extended_audio.c b/src/extended_audio.c index b402d946f9..7ab0c60309 100644 --- a/src/extended_audio.c +++ b/src/extended_audio.c @@ -258,7 +258,7 @@ int AUDIO_AddQueue(u16 music) { if (voice_map[music].id >= CUSTOM_ALARM_ID) { u32 id = voice_map[audio_queue[next_audio-1]].id; - if (id == 0 || id >= CUSTOM_ALARM_ID) // Only skip welcome message or custom alarms + if (id == MUSIC_STARTUP || id >= CUSTOM_ALARM_ID) // Only skip welcome message or custom alarms audio_queue_time = t + CUSTOM_ALARM_IGNORE_MS; // Do not consume the audio right away (prevent triggering transitional sounds) for (u8 i = next_audio; i < num_audio; i++) From 25a02e79a6ccfd948f17f8c77a36a0ee5d888589 Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Sun, 9 Aug 2020 01:50:31 +0200 Subject: [PATCH 5/9] Wait for button release for exiting --- src/pages/128x64x1/advanced/mixer_curves.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/128x64x1/advanced/mixer_curves.c b/src/pages/128x64x1/advanced/mixer_curves.c index 78f09b9526..f3a2f01208 100644 --- a/src/pages/128x64x1/advanced/mixer_curves.c +++ b/src/pages/128x64x1/advanced/mixer_curves.c @@ -95,9 +95,10 @@ void PAGE_EditCurvesInit(int page) static unsigned action_cb(u32 button, unsigned flags, void *data) { (void)data; - if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) { + if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS) || (flags & BUTTON_RELEASE)) { if (CHAN_ButtonIsPressed(button, BUT_EXIT)) { - PAGE_Pop(); + if (flags & BUTTON_RELEASE) + PAGE_Pop(); } else if (CHAN_ButtonIsPressed(button, BUT_ENTER) && (flags & BUTTON_LONGPRESS)) { // long press enter = save without exiting if (edit->pointnum < 0) From abfe933f90a87ceb92690ae2a7fc690a4273f769 Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Sun, 9 Aug 2020 02:49:56 +0200 Subject: [PATCH 6/9] Change title to label because it is not selectable --- src/pages/128x64x1/advanced/mixer_curves.c | 3 ++- src/pages/128x64x1/guiobj.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/128x64x1/advanced/mixer_curves.c b/src/pages/128x64x1/advanced/mixer_curves.c index 78f09b9526..4af8020e1b 100644 --- a/src/pages/128x64x1/advanced/mixer_curves.c +++ b/src/pages/128x64x1/advanced/mixer_curves.c @@ -58,7 +58,8 @@ void PAGE_EditCurvesInit(int page) } edit->curve = *curve; - GUI_CreateTextSelectPlate(&gui->name, NAME_X, 0, NAME_W, HEADER_HEIGHT, &TEXTSEL_FONT, NULL, set_curvename_cb, NULL); + //GUI_CreateTextSelectPlate(&gui->name, NAME_X, 0, NAME_W, HEADER_HEIGHT, &TEXTSEL_FONT, NULL, set_curvename_cb, NULL); + GUI_CreateLabelBox(&gui->title, NAME_X, 0 , NAME_W, HEADER_HEIGHT, &LABEL_FONT, GUI_Localize, NULL, _tr(CURVE_GetName(tempstring, curve))); GUI_CreateButtonPlateText(&gui->save, SAVE_X, 0, SAVE_W, HEADER_WIDGET_HEIGHT, &BUTTON_FONT , GUI_Localize, okcancel_cb, _tr_noop("Save")); // Draw a line if (UNDERLINE) diff --git a/src/pages/128x64x1/guiobj.h b/src/pages/128x64x1/guiobj.h index 7bb24cd28d..b631a85b14 100644 --- a/src/pages/128x64x1/guiobj.h +++ b/src/pages/128x64x1/guiobj.h @@ -270,7 +270,8 @@ struct crsfdevice_obj { /****Advanced ****/ struct advcurve_obj { - guiTextSelect_t name; + //guiTextSelect_t name; + guiLabel_t title; guiButton_t save; guiRect_t rect; guiLabel_t pointlbl; From 7edb5de283b851a20a839287fbc9d8629512bda0 Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Sun, 9 Aug 2020 02:50:08 +0200 Subject: [PATCH 7/9] This function is not used anymore --- src/pages/common/advanced/_mixer_curves.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/common/advanced/_mixer_curves.c b/src/pages/common/advanced/_mixer_curves.c index ca72f3ef22..9888361073 100644 --- a/src/pages/common/advanced/_mixer_curves.c +++ b/src/pages/common/advanced/_mixer_curves.c @@ -17,7 +17,7 @@ static struct advcurve_obj * const gui = &gui_objs.u.advcurve; static struct curve_edit * const edit = &pagemem.u.mixer_page.edit; static void okcancel_cb(guiObject_t *obj, const void *data); -static const char *set_curvename_cb(guiObject_t *obj, int dir, void *data); +//static const char *set_curvename_cb(guiObject_t *obj, int dir, void *data); static const char *set_pointnum_cb(guiObject_t *obj, int dir, void *data); static const char *set_expopoint_cb(guiObject_t *obj, int dir, void *data); static const char *set_value_cb(guiObject_t *obj, int dir, void *data); @@ -42,7 +42,7 @@ s32 show_curve_cb(s32 xval, void *data) return yval; } -static const char *set_curvename_cb(guiObject_t *obj, int dir, void *data) +/*static const char *set_curvename_cb(guiObject_t *obj, int dir, void *data) { (void)data; (void)obj; @@ -58,7 +58,7 @@ static const char *set_curvename_cb(guiObject_t *obj, int dir, void *data) } } return _tr(CURVE_GetName(tempstring, curve)); -} +}*/ static void okcancel_cb(guiObject_t *obj, const void *data) { (void)obj; From 493f7b6a8397a50ffaf5c584bc020518445cba82 Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Sun, 9 Aug 2020 02:50:27 +0200 Subject: [PATCH 8/9] Value selected by default --- src/pages/128x64x1/advanced/mixer_curves.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/128x64x1/advanced/mixer_curves.c b/src/pages/128x64x1/advanced/mixer_curves.c index 4af8020e1b..4f199ac818 100644 --- a/src/pages/128x64x1/advanced/mixer_curves.c +++ b/src/pages/128x64x1/advanced/mixer_curves.c @@ -90,7 +90,7 @@ void PAGE_EditCurvesInit(int page) CHAN_MAX_VALUE, CHAN_MAX_VALUE, 0, 0, //CHAN_MAX_VALUE / 4, CHAN_MAX_VALUE / 4, show_curve_cb, NULL, touch_cb, &edit->curve); - GUI_SetSelected((guiObject_t *)&gui->point); + GUI_SetSelected((guiObject_t *)&gui->value); } static unsigned action_cb(u32 button, unsigned flags, void *data) From 580947fb2fb05283af452f6e0c80bab3e4fea7de Mon Sep 17 00:00:00 2001 From: Erwin Ried <1091420+eried@users.noreply.github.com> Date: Sun, 9 Aug 2020 03:06:44 +0200 Subject: [PATCH 9/9] Space on comments --- src/pages/128x64x1/advanced/mixer_curves.c | 2 +- src/pages/128x64x1/guiobj.h | 2 +- src/pages/common/advanced/_mixer_curves.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/128x64x1/advanced/mixer_curves.c b/src/pages/128x64x1/advanced/mixer_curves.c index 4f199ac818..abdfbbf648 100644 --- a/src/pages/128x64x1/advanced/mixer_curves.c +++ b/src/pages/128x64x1/advanced/mixer_curves.c @@ -58,7 +58,7 @@ void PAGE_EditCurvesInit(int page) } edit->curve = *curve; - //GUI_CreateTextSelectPlate(&gui->name, NAME_X, 0, NAME_W, HEADER_HEIGHT, &TEXTSEL_FONT, NULL, set_curvename_cb, NULL); + // GUI_CreateTextSelectPlate(&gui->name, NAME_X, 0, NAME_W, HEADER_HEIGHT, &TEXTSEL_FONT, NULL, set_curvename_cb, NULL); GUI_CreateLabelBox(&gui->title, NAME_X, 0 , NAME_W, HEADER_HEIGHT, &LABEL_FONT, GUI_Localize, NULL, _tr(CURVE_GetName(tempstring, curve))); GUI_CreateButtonPlateText(&gui->save, SAVE_X, 0, SAVE_W, HEADER_WIDGET_HEIGHT, &BUTTON_FONT , GUI_Localize, okcancel_cb, _tr_noop("Save")); // Draw a line diff --git a/src/pages/128x64x1/guiobj.h b/src/pages/128x64x1/guiobj.h index b631a85b14..9b0dbb97a1 100644 --- a/src/pages/128x64x1/guiobj.h +++ b/src/pages/128x64x1/guiobj.h @@ -270,7 +270,7 @@ struct crsfdevice_obj { /****Advanced ****/ struct advcurve_obj { - //guiTextSelect_t name; + // guiTextSelect_t name; guiLabel_t title; guiButton_t save; guiRect_t rect; diff --git a/src/pages/common/advanced/_mixer_curves.c b/src/pages/common/advanced/_mixer_curves.c index 9888361073..fc8cb64e82 100644 --- a/src/pages/common/advanced/_mixer_curves.c +++ b/src/pages/common/advanced/_mixer_curves.c @@ -17,7 +17,7 @@ static struct advcurve_obj * const gui = &gui_objs.u.advcurve; static struct curve_edit * const edit = &pagemem.u.mixer_page.edit; static void okcancel_cb(guiObject_t *obj, const void *data); -//static const char *set_curvename_cb(guiObject_t *obj, int dir, void *data); +// static const char *set_curvename_cb(guiObject_t *obj, int dir, void *data); static const char *set_pointnum_cb(guiObject_t *obj, int dir, void *data); static const char *set_expopoint_cb(guiObject_t *obj, int dir, void *data); static const char *set_value_cb(guiObject_t *obj, int dir, void *data);