📄 ring.c
字号:
#include "demohs.h"
#include "hal.h"
#include <audio.h>
#ifdef DEV_BOARD_HS
#include <pio.h>
#endif
static const audio_note twilight[] =
{
AUDIO_TEMPO(180), AUDIO_VOLUME(64), AUDIO_TIMBRE(sine),
AUDIO_NOTE(E7, QUAVER),
AUDIO_NOTE(F7, QUAVER),
AUDIO_NOTE(E7, QUAVER),
AUDIO_NOTE(C7, QUAVER),
AUDIO_NOTE(E7, QUAVER),
AUDIO_NOTE(F7, QUAVER),
AUDIO_NOTE(E7, QUAVER),
AUDIO_NOTE(C7, QUAVER),
AUDIO_END
};
#ifdef DEV_BOARD_HS
static Delay delayRingPlay(TimerHandle h)
{
/* keep the compiler happy */
h=h;
/* play the ring tone */
hsState.AudioRingHandle = AudioPlay(twilight);
return D_NEVER;
}
#endif
/*
ringInd
Called by the headset framework to tell us that a RING command has
been received over RFCOMM (state =1) or that the ring duration has
expired (state = 0)
*/
void ringInd(const HS_RING_IND_T * ind)
{
#ifdef DEV_BOARD_HS
if(ind->state)
{
/* enable the codec */
PioSet(PIO_CODEC, CODEC_ON);
/* small delay */
TimerAdd(D_mSEC(100), delayRingPlay);
}
else
{
if (!hsState.scoConnected)
{
/*
disable the codec only if there is no sco up otherwise
we'll be in trouble
*/
PioSet(PIO_CODEC, CODEC_OFF);
}
}
#else
if (ind->state)
hsState.AudioRingHandle = AudioPlay(twilight);
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -