Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New method for handling custom alarms #961

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
23 changes: 22 additions & 1 deletion src/extended_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,28 @@ int AUDIO_AddQueue(u16 music) {
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 == 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++)
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
else
audio_queue[new_num_audio] = music; // Replace queue item, do not enqueue custom sounds
return 1;
}

Expand Down
2 changes: 2 additions & 0 deletions src/music.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/pages/128x64x1/guiobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/common/advanced/_mixer_curves.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand Down